Skip to content

Commit b7dd18d

Browse files
test(webhook): fix HMAC verification setup and remove env destructuring in tests
1 parent fbf48db commit b7dd18d

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

functions/slack/test/integration.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const crypto = require('crypto');
1919
const supertest = require('supertest');
2020
const functionsFramework = require('@google-cloud/functions-framework/testing');
2121

22-
const {SLACK_SECRET} = process.env;
22+
process.env.SLACK_SECRET = 'testsecret';
2323
const SLACK_TIMESTAMP = Date.now();
2424

2525
require('../index');
@@ -30,7 +30,7 @@ const generateSignature = query => {
3030
const buf = Buffer.from(body);
3131
const plaintext = `v0:${SLACK_TIMESTAMP}:${buf}`;
3232

33-
const hmac = crypto.createHmac('sha256', SLACK_SECRET);
33+
const hmac = crypto.createHmac('sha256', process.env.SLACK_SECRET);
3434
hmac.update(plaintext);
3535
const ciphertext = hmac.digest('hex');
3636

functions/slack/test/unit.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const getSample = () => {
4848
googleapis: googleapis,
4949
kgsearch: kgsearch,
5050
config: config,
51-
eventsApi: eventsApi,
5251
},
5352
};
5453
};

0 commit comments

Comments
 (0)