Skip to content

Commit

Permalink
Make slack param validation handle empty messages (#60468)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote authored Mar 19, 2020
1 parent 8fd317c commit 27045e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const SecretsSchema = schema.object(secretsSchemaProps);
export type ActionParamsType = TypeOf<typeof ParamsSchema>;

const ParamsSchema = schema.object({
message: schema.string(),
message: schema.string({ minLength: 1 }),
});

// action type definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ export default function slackTest({ getService }: FtrProviderContext) {
expect(result.status).to.eql('ok');
});

it('should handle an empty message error', async () => {
const { body: result } = await supertest
.post(`/api/action/${simulatedActionId}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
params: {
message: '',
},
})
.expect(200);
expect(result.status).to.eql('error');
expect(result.message).to.match(/error validating action params: \[message\]: /);
});

it('should handle a 40x slack error', async () => {
const { body: result } = await supertest
.post(`/api/action/${simulatedActionId}/_execute`)
Expand Down

0 comments on commit 27045e0

Please sign in to comment.