signature-acd 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/signature/request.rb +3 -1
- data/lib/signature/version.rb +1 -1
- data/spec/signature_spec.rb +8 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cd79059dee3c952532a5b0ee029e3aeade4d270
|
4
|
+
data.tar.gz: 9856979b8e32d931a44120a31d571b313dde2ea5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5270e2afbf5ef9c9e58220e5c28018240ebc71d82fedc6213e80fc8a6fe2bbcf812df148d36e64439841067f1ba4325ba02dbb42d602ed02940be20525dfa95c
|
7
|
+
data.tar.gz: 1651658443a3b8db5e5e7c49d259c0e7da10b97cb8cc28317bb5aac7d50bfae67162e56ca0760fce589011e37545a648dd6532685c2a72c02aba5698c62048a5
|
data/lib/signature/request.rb
CHANGED
@@ -36,7 +36,9 @@ module Signature
|
|
36
36
|
hh = {}
|
37
37
|
headers.each do |k,v|
|
38
38
|
if match = k.upcase.match(AUTH_HEADER_PREFIX_REGEX)
|
39
|
-
|
39
|
+
mindex = match[1] if match[1]
|
40
|
+
mindex ||= match[2]
|
41
|
+
hh[mindex.downcase.gsub!('-', '_')] = v if mindex
|
40
42
|
end
|
41
43
|
end
|
42
44
|
hh
|
data/lib/signature/version.rb
CHANGED
data/spec/signature_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path('../spec_helper', __FILE__)
|
|
2
2
|
|
3
3
|
describe Signature do
|
4
4
|
before :each do
|
5
|
-
Time.stub
|
5
|
+
Time.stub(:now).and_return(Time.at(1234))
|
6
6
|
|
7
7
|
@token = Signature::Token.new('key', 'secret')
|
8
8
|
|
@@ -178,15 +178,15 @@ describe Signature do
|
|
178
178
|
|
179
179
|
it "should raise error if timestamp has expired (default of 600s)" do
|
180
180
|
request = Signature::Request.new('POST', '/some/path', @params)
|
181
|
-
Time.stub
|
181
|
+
Time.stub(:now).and_return(Time.at(1234 + 599))
|
182
182
|
request.authenticate_by_token!(@token).should == true
|
183
|
-
Time.stub
|
183
|
+
Time.stub(:now).and_return(Time.at(1234 - 599))
|
184
184
|
request.authenticate_by_token!(@token).should == true
|
185
|
-
Time.stub
|
185
|
+
Time.stub(:now).and_return(Time.at(1234 + 600))
|
186
186
|
lambda {
|
187
187
|
request.authenticate_by_token!(@token)
|
188
188
|
}.should raise_error("Timestamp expired: Given timestamp (1970-01-01T00:20:34Z) not within 600s of server time (1970-01-01T00:30:34Z)")
|
189
|
-
Time.stub
|
189
|
+
Time.stub(:now).and_return(Time.at(1234 - 600))
|
190
190
|
lambda {
|
191
191
|
request.authenticate_by_token!(@token)
|
192
192
|
}.should raise_error("Timestamp expired: Given timestamp (1970-01-01T00:20:34Z) not within 600s of server time (1970-01-01T00:10:34Z)")
|
@@ -195,9 +195,9 @@ describe Signature do
|
|
195
195
|
it "should be possible to customize the timeout grace period" do
|
196
196
|
grace = 10
|
197
197
|
request = Signature::Request.new('POST', '/some/path', @params)
|
198
|
-
Time.stub
|
198
|
+
Time.stub(:now).and_return(Time.at(1234 + grace - 1))
|
199
199
|
request.authenticate_by_token!(@token, grace).should == true
|
200
|
-
Time.stub
|
200
|
+
Time.stub(:now).and_return(Time.at(1234 + grace))
|
201
201
|
lambda {
|
202
202
|
request.authenticate_by_token!(@token, grace)
|
203
203
|
}.should raise_error("Timestamp expired: Given timestamp (1970-01-01T00:20:34Z) not within 10s of server time (1970-01-01T00:20:44Z)")
|
@@ -205,7 +205,7 @@ describe Signature do
|
|
205
205
|
|
206
206
|
it "should be possible to skip timestamp check by passing nil" do
|
207
207
|
request = Signature::Request.new('POST', '/some/path', @params)
|
208
|
-
Time.stub
|
208
|
+
Time.stub(:now).and_return(Time.at(1234 + 1000))
|
209
209
|
request.authenticate_by_token!(@token, nil).should == true
|
210
210
|
end
|
211
211
|
|