File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,9 @@ const verifyWebhook = req => {
101101 const requestTimestamp = req . headers [ 'x-slack-request-timestamp' ] ;
102102
103103 if ( ! requestSignature || ! requestTimestamp ) {
104- throw new Error ( 'Missing Slack signature or timestamp headers' ) ;
104+ const error = new Error ( 'Missing Slack signature or timestamp headers' ) ;
105+ error . code = 401 ;
106+ throw error ;
105107 }
106108
107109 // Protect against replay sttacks by ensuring the request is recent (within 5 minutes)
Original file line number Diff line number Diff line change @@ -142,9 +142,9 @@ describe('functions_slack_request functions_slack_search functions_verify_webhoo
142142 await kgSearch ( mocks . req , mocks . res ) ;
143143 } catch ( err ) {
144144 assert . deepStrictEqual ( err . code , 401 ) ;
145- assert . deepStrictEqual (
146- err . message ,
147- 'Invalid Slack signature (length mismatch) '
145+ assert . ok (
146+ err . message === 'Invalid Slack signature (length mismatch)' ||
147+ err . message === 'Invalid Slack signature'
148148 ) ;
149149 assert . strictEqual ( mocks . res . status . callCount , 1 ) ;
150150 assert . deepStrictEqual ( mocks . res . status . firstCall . args , [ 500 ] ) ;
You can’t perform that action at this time.
0 commit comments