1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/test/verified_key_with_expiration_test.rb

20 lines
712 B
Ruby
Raw Normal View History

2017-07-03 15:06:09 -04:00
require "test_helper"
require "active_support/core_ext/securerandom"
class ActiveVault::VerifiedKeyWithExpirationTest < ActiveSupport::TestCase
2017-07-03 15:06:09 -04:00
FIXTURE_KEY = SecureRandom.base58(24)
test "without expiration" do
encoded_key = ActiveVault::VerifiedKeyWithExpiration.encode(FIXTURE_KEY)
assert_equal FIXTURE_KEY, ActiveVault::VerifiedKeyWithExpiration.decode(encoded_key)
2017-07-03 15:06:09 -04:00
end
2017-07-03 15:12:11 -04:00
test "with expiration" do
encoded_key = ActiveVault::VerifiedKeyWithExpiration.encode(FIXTURE_KEY, expires_in: 1.minute)
assert_equal FIXTURE_KEY, ActiveVault::VerifiedKeyWithExpiration.decode(encoded_key)
2017-07-03 15:12:11 -04:00
travel 2.minutes
assert_nil ActiveVault::VerifiedKeyWithExpiration.decode(encoded_key)
2017-07-03 15:12:11 -04:00
end
2017-07-03 15:06:09 -04:00
end