]> git.openstreetmap.org Git - rails.git/blob - test/unit/oauth_token_test.rb
ff03537910ea9d99a91f07c7121dc808346c4a1c
[rails.git] / test / unit / oauth_token_test.rb
1 require File.dirname(__FILE__) + '/../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({
19       :client_application => client_applications(:oauth_web_app)
20     }, :without_protection => true)
21     assert_equal false, tok.authorized?, "Token should be created unauthorised."
22     tok.authorize!(users(:public_user))
23     assert_equal true, tok.authorized?, "Token should now be authorised."
24     tok.invalidate!
25     assert_equal false, tok.authorized?, "Token should now be invalid."
26   end
27
28 end