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