1 require File.dirname(__FILE__) + '/../test_helper'
 
   3 class OauthTokenTest < ActiveSupport::TestCase
 
   7   # check that after calling invalidate! on a token, it is invalid.
 
   8   def test_token_invalidation
 
  10     assert_equal false, tok.invalidated?, "Token should be created valid."
 
  12     assert_equal true, tok.invalidated?, "Token should now be invalid."
 
  16   # check that an authorized token is authorised and can be invalidated
 
  17   def test_token_authorisation
 
  18     tok = RequestToken.create :client_application => client_applications(:oauth_web_app)
 
  19     assert_equal false, tok.authorized?, "Token should be created unauthorised."
 
  20     tok.authorize!(users(:public_user))
 
  21     assert_equal true, tok.authorized?, "Token should now be authorised."
 
  23     assert_equal false, tok.authorized?, "Token should now be invalid."
 
  27   # test that tokens can't be found unless they're authorised
 
  29     tok = client_applications(:oauth_web_app).create_request_token
 
  30     assert_equal false, tok.authorized?, "Token should be created unauthorised."
 
  31     assert_equal nil, OauthToken.find_token(tok.token), "Shouldn't be able to find unauthorised token"
 
  32     tok.authorize!(users(:public_user))
 
  33     assert_equal true, tok.authorized?, "Token should now be authorised."
 
  34     assert_not_equal nil, OauthToken.find_token(tok.token), "Should be able to find authorised token"