spec/shared/authenticated.rb in ey-hmac-2.0.2 vs spec/shared/authenticated.rb in ey-hmac-2.1.0
- old
+ new
@@ -49,7 +49,27 @@
expect(Ey::Hmac.authenticate!(request, adapter: adapter) do |auth_id|
(auth_id == key_id) && key_secret
end).to be_falsey
}.to raise_exception(Ey::Hmac::MissingAuthorization)
end
+
+ context "when the server specifies an HMAC TTL" do
+ it "should not authenticate expired hmac" do
+ Ey::Hmac.sign!(request, key_id, key_secret, adapter: adapter)
+ expect {
+ Ey::Hmac.authenticate!(request, adapter: adapter, ttl: 0) do |auth_id|
+ (auth_id == key_id) && key_secret
+ end
+ }.to raise_exception(Ey::Hmac::ExpiredHmac)
+ end
+
+ it "should authenticate non-expired hmac" do
+ Ey::Hmac.sign!(request, key_id, key_secret, adapter: adapter)
+ expect {
+ Ey::Hmac.authenticate!(request, adapter: adapter, ttl: 100) do |auth_id|
+ (auth_id == key_id) && key_secret
+ end
+ }.to_not raise_exception
+ end
+ end
end
end