-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(slack): Left-over fixes from interactive notifications (#774)
* fix(slack): Fix and enable signature verification for Slack callbacks * fix(slack): Remove token verification in favor of signature verification * fix(slack): Fix left-over refactored method call * chore(log): More debug logs * fix(test): Fix interactive notification tests
- Loading branch information
Showing
6 changed files
with
60 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ class SlackInteractiveNotificationServiceSpec extends Specification { | |
URLEncoder.encode(getClass().getResource("/slack/callbackRequestBody.txt").text) | ||
|
||
RequestEntity<String> request = new RequestEntity<>( | ||
slackRequestBody, new HttpHeaders(), HttpMethod.POST, new URI("/notifications/callbaks")) | ||
slackRequestBody, new HttpHeaders(), HttpMethod.POST, new URI("/notifications/callbacks")) | ||
|
||
slackAppService.verifyToken(*_) >> { } | ||
slackAppService.getUserInfo(*_) >> new SlackService.SlackUserInfo(email: "[email protected]") | ||
|
@@ -80,7 +80,7 @@ class SlackInteractiveNotificationServiceSpec extends Specification { | |
URLEncoder.encode(getClass().getResource("/slack/callbackRequestBody.txt").text) | ||
|
||
RequestEntity<String> request = new RequestEntity<>( | ||
slackRequestBody, new HttpHeaders(), HttpMethod.POST, new URI("/notifications/callbaks")) | ||
slackRequestBody, new HttpHeaders(), HttpMethod.POST, new URI("/notifications/callbacks")) | ||
|
||
slackAppService.verifyToken(*_) >> { } | ||
slackAppService.getUserInfo(*_) >> { throw new Exception("oops!") } | ||
|
@@ -106,7 +106,7 @@ class SlackInteractiveNotificationServiceSpec extends Specification { | |
given: | ||
String slackRequestBody = "content=suspicious" | ||
RequestEntity<String> request = new RequestEntity<>( | ||
slackRequestBody, new HttpHeaders(), HttpMethod.POST, new URI("/notifications/callbaks")) | ||
slackRequestBody, new HttpHeaders(), HttpMethod.POST, new URI("/notifications/callbacks")) | ||
|
||
when: | ||
service.parseInteractionCallback(request) | ||
|
@@ -115,15 +115,15 @@ class SlackInteractiveNotificationServiceSpec extends Specification { | |
thrown(InvalidRequestException) | ||
} | ||
|
||
def "failing to verify the token from Slack throws an exception"() { | ||
def "failing to verify the signature from Slack throws an exception"() { | ||
given: | ||
String slackRequestBody = "payload=" + | ||
URLEncoder.encode(getClass().getResource("/slack/callbackRequestBody.txt").text) | ||
|
||
RequestEntity<String> request = new RequestEntity<>( | ||
slackRequestBody, new HttpHeaders(), HttpMethod.POST, new URI("/notifications/callbaks")) | ||
slackRequestBody, new HttpHeaders(), HttpMethod.POST, new URI("/notifications/callbacks")) | ||
|
||
slackAppService.verifyToken(*_) >> { throw new InvalidRequestException() } | ||
slackAppService.verifySignature(*_) >> { throw new InvalidRequestException() } | ||
slackAppService.getUserInfo(*_) >> { } | ||
|
||
when: | ||
|
@@ -139,7 +139,7 @@ class SlackInteractiveNotificationServiceSpec extends Specification { | |
String slackRequestBody = "payload=" + URLEncoder.encode(payload, "UTF-8") | ||
|
||
RequestEntity<String> request = new RequestEntity<>( | ||
slackRequestBody, new HttpHeaders(), HttpMethod.POST, new URI("/notifications/callbaks")) | ||
slackRequestBody, new HttpHeaders(), HttpMethod.POST, new URI("/notifications/callbacks")) | ||
|
||
slackAppService.verifyToken(*_) >> { } | ||
slackAppService.getUserInfo(*_) >> { } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters