-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve security by adding request signing (#34)
* Added request signing * rearranged things to reflect the order of checks * Updated README.rst * Updated screenshot * Fixed test request signature creation * Fixed Flask exception handling test * Added hash matching for Python 2.7.6 and add 2.7.6 to tox environments * Making hash comparisons work in 2.7.6, 2.7.7 and 3.6.5…
- Loading branch information
Showing
10 changed files
with
215 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ sudo: false | |
dist: trusty | ||
language: python | ||
python: | ||
- "2.7.6" | ||
- "2.7" | ||
- "3.3" | ||
- "3.4" | ||
|
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
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 |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import time | ||
import pytest | ||
from slackeventsapi import SlackEventAdapter | ||
|
||
ADAPTER = SlackEventAdapter('vFO9LARnLI7GflLR8tGqHgdy') | ||
|
||
ADAPTER = SlackEventAdapter('SIGNING_SECRET') | ||
|
||
def test_event_emission(client): | ||
# Events should trigger an event | ||
data = pytest.reaction_event_fixture | ||
|
||
@ADAPTER.on('reaction_added') | ||
def event_handler(event): | ||
assert event["reaction"] == 'grinning' | ||
|
||
data = pytest.reaction_event_fixture | ||
timestamp = int(time.time()) | ||
signature = pytest.create_signature(ADAPTER.signing_secret, timestamp, data) | ||
|
||
res = client.post( | ||
'/slack/events', | ||
data=data, | ||
content_type='application/json' | ||
content_type='application/json', | ||
headers={ | ||
'X-Slack-Request-Timestamp': timestamp, | ||
'X-Slack-Signature': signature | ||
} | ||
) | ||
|
||
assert res.status_code == 200 |
Oops, something went wrong.