]> git.openstreetmap.org Git - rails.git/blob - test/models/oauth_token_test.rb
Notes: show first comment as marker tooltip
[rails.git] / test / models / oauth_token_test.rb
1 require "test_helper"
2
3 class OauthTokenTest < ActiveSupport::TestCase
4   api_fixtures
5
6   ##
7   # check that after calling invalidate! on a token, it is invalid.
8   def test_token_invalidation
9     tok = OauthToken.new
10     assert_equal false, tok.invalidated?, "Token should be created valid."
11     tok.invalidate!
12     assert_equal true, tok.invalidated?, "Token should now be invalid."
13   end
14
15   ##
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."
22     tok.invalidate!
23     assert_equal false, tok.authorized?, "Token should now be invalid."
24   end
25 end