Skip to content

Commit c08c95f

Browse files
authored
Merge pull request #369 from wedgex/support-rack-requests
Support rack requests in Slack::Events::Request
2 parents 1158c92 + 6b27461 commit c08c95f

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* [#368](https://github.com/slack-ruby/slack-ruby-client/pull/368): Removed `admin_conversations_whitelist` and `admin_conversations_disconnectShared` - [@dblock](https://github.com/dblock).
44
* [#359](https://github.com/slack-ruby/slack-ruby-client/pull/359): Handle non-JSON 500 errors - [@agrobbin](https://github.com/agrobbin).
55
* [#360](https://github.com/slack-ruby/slack-ruby-client/pull/360): Remove faye-websocket from the concurrency detection error message - [@dblock](https://github.com/dblock).
6+
* [#369](https://github.com/slack-ruby/slack-ruby-client/pull/369): Support rack requests in `Slack::Events::Request` - [@wedgex](https://github.com/wedgex).
67
* Your contribution here.
78

89
### 0.16.0 (2021/01/24)

lib/slack/events/request.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ def initialize(http_request, options = {})
1919

2020
# Request timestamp.
2121
def timestamp
22-
@timestamp ||= http_request.headers['X-Slack-Request-Timestamp']
22+
@timestamp ||= http_request.get_header('HTTP_X_SLACK_REQUEST_TIMESTAMP')
2323
end
2424

2525
# The signature is created by combining the signing secret with the body of the request
2626
# Slack is sending using a standard HMAC-SHA256 keyed hash.
2727
def signature
28-
@signature ||= http_request.headers['X-Slack-Signature']
28+
@signature ||= http_request.get_header('HTTP_X_SLACK_SIGNATURE')
2929
end
3030

3131
# Signature version.

spec/slack/events/request_spec.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
'"P7sFXA4o3HV2hTx4zb4zcQ9yrvuQs8pDh6EacOxmMRj0tJaXfQFF","type":"url_verification"}'
2222
end
2323
let(:http_request) do
24-
double(
25-
headers: {
26-
'X-Slack-Request-Timestamp' => timestamp,
27-
'X-Slack-Signature' => signature
28-
},
24+
request_double = double(
2925
body: StringIO.new(body)
3026
)
27+
28+
allow(request_double).to receive(:get_header).with('HTTP_X_SLACK_REQUEST_TIMESTAMP') { timestamp }
29+
allow(request_double).to receive(:get_header).with('HTTP_X_SLACK_SIGNATURE') { signature }
30+
31+
request_double
3132
end
3233

3334
after do

0 commit comments

Comments
 (0)