Skip to content

Commit fc5e181

Browse files
test(webhook): fix signature mocks and assert error details explicitly in unit tests
1 parent 4a417ad commit fc5e181

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

functions/slack/test/unit.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const getSample = () => {
5555
const getMocks = () => {
5656
const req = {
5757
headers: {
58-
'x-slack-signature': 'v0=fakesignature',
58+
'x-slack-signature': 'v0=' + 'a'.repeat(64),
5959
'x-slack-request-timestamp': `${Math.floor(Date.now() / 1000)}`,
6060
},
6161
query: {},
@@ -141,7 +141,11 @@ describe('functions_slack_request functions_slack_search functions_verify_webhoo
141141
try {
142142
await kgSearch(mocks.req, mocks.res);
143143
} catch (err) {
144-
assert.deepStrictEqual(err, error);
144+
assert.deepStrictEqual(err.code, 401);
145+
assert.deepStrictEqual(
146+
err.message,
147+
'Invalid Slack signature (length mismatch)'
148+
);
145149
assert.strictEqual(mocks.res.status.callCount, 1);
146150
assert.deepStrictEqual(mocks.res.status.firstCall.args, [500]);
147151
assert.strictEqual(mocks.res.send.callCount, 1);

0 commit comments

Comments
 (0)