]> git.openstreetmap.org Git - rails.git/blob - test/models/oauth_token_test.rb
Merge remote-tracking branch 'upstream/pull/4523'
[rails.git] / test / models / oauth_token_test.rb
1 require "test_helper"
2
3 class OauthTokenTest < ActiveSupport::TestCase
4   ##
5   # check that after calling invalidate! on a token, it is invalid.
6   def test_token_invalidation
7     tok = OauthToken.new
8     assert_not_predicate tok, :invalidated?, "Token should be created valid."
9     tok.invalidate!
10     assert_predicate tok, :invalidated?, "Token should now be invalid."
11   end
12
13   ##
14   # check that an authorized token is authorised and can be invalidated
15   def test_token_authorisation
16     tok = RequestToken.create(:client_application => create(:client_application))
17     assert_not_predicate tok, :authorized?, "Token should be created unauthorised."
18     tok.authorize!(create(:user))
19     assert_predicate tok, :authorized?, "Token should now be authorised."
20     tok.invalidate!
21     assert_not_predicate tok, :authorized?, "Token should now be invalid."
22   end
23 end