diff options
author | Assain <assainjaleel20@gmail.com> | 2017-07-24 14:03:21 +0530 |
---|---|---|
committer | Assain <assainjaleel20@gmail.com> | 2017-07-24 14:57:24 +0530 |
commit | db5e6912daee39e54aaebe5295420dd1386e387e (patch) | |
tree | a1aded427e78e159481a41df194b10ba95461b6b /activesupport | |
parent | 2ee46434e0e8f81b1a852d7b190a2f7b0ba67228 (diff) | |
download | rails-db5e6912daee39e54aaebe5295420dd1386e387e.tar.gz rails-db5e6912daee39e54aaebe5295420dd1386e387e.tar.bz2 rails-db5e6912daee39e54aaebe5295420dd1386e387e.zip |
add metadata tests: verify method
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/test/message_verifier_test.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/test/message_verifier_test.rb b/activesupport/test/message_verifier_test.rb index d4a8ce762a..5ee4beb16a 100644 --- a/activesupport/test/message_verifier_test.rb +++ b/activesupport/test/message_verifier_test.rb @@ -99,6 +99,21 @@ class MessageVerifierMetadataTest < ActiveSupport::TestCase @verifier = ActiveSupport::MessageVerifier.new("Hey, I'm a secret!", verifier_options) end + def test_verify_raises_when_purpose_differs + assert_raise(ActiveSupport::MessageVerifier::InvalidSignature) do + @verifier.verify(@verifier.generate(@message, purpose: "payment"), purpose: "shipping") + end + end + + def test_verify_raises_when_expired + signed_message = @verifier.generate(@message, expires_in: 1.month) + + travel 2.months + assert_raise(ActiveSupport::MessageVerifier::InvalidSignature) do + @verifier.verify(signed_message) + end + end + private def generate(message, **options) @verifier.generate(message, options) |