Skip to content

Commit 56ee27e

Browse files
committed
tests: verify the remaining wehbook validations
There are more things that are checked than just the HTTP method. Let's verify that those checks are able to dismiss invalid requests, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 4d81bf4 commit 56ee27e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

__tests__/index.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,21 @@ test('reject requests other than webhook payloads', async () => {
2424
}
2525

2626
await expectInvalidWebhook('Unexpected method: GET')
27+
28+
context.log = jest.fn()
29+
context.req.method = 'POST'
30+
context.req.headers = {
31+
'content-type': 'text/plain'
32+
}
33+
await expectInvalidWebhook('Unexpected content type: text/plain')
34+
35+
context.req.headers['content-type'] = 'application/json'
36+
await expectInvalidWebhook('Missing X-Hub-Signature')
37+
38+
context.req.headers['x-hub-signature-256'] = 'invalid'
39+
await expectInvalidWebhook('Unexpected X-Hub-Signature format: invalid')
40+
41+
context.req.headers['x-hub-signature-256'] = 'sha256=incorrect'
42+
context.req.rawBody = '# empty'
43+
await expectInvalidWebhook('Incorrect X-Hub-Signature')
2744
})

0 commit comments

Comments
 (0)