3 class OauthNonceTest < ActiveSupport::TestCase
7 # the nonce has only one property, that it is a unique pair of
8 # string and timestamp.
9 def test_nonce_uniqueness
10 string = "0123456789ABCDEF"
11 timestamp = Time.now.to_i
13 nonce1 = OauthNonce.remember(string, timestamp)
14 assert_not_equal false, nonce1, "First nonce should be unique. Check your test database is empty."
16 nonce2 = OauthNonce.remember(string, timestamp)
17 assert_equal false, nonce2, "Shouldn't be able to remember the same nonce twice."
21 # nonces that are not current should be rejected
22 def test_nonce_not_current
23 string = "0123456789ABCDEF"
25 nonce1 = OauthNonce.remember(string, Time.now.to_i - 86430)
26 assert_equal false, nonce1, "Nonces over a day in the past should be rejected"
28 nonce2 = OauthNonce.remember(string, Time.now.to_i - 86370)
29 assert_not_equal false, nonce2, "Nonces under a day in the past should be rejected"