diff options
author | Ib Lundgren <ib.lundgren@gmail.com> | 2014-10-23 18:41:26 +0100 |
---|---|---|
committer | Ib Lundgren <ib.lundgren@gmail.com> | 2014-10-23 18:41:26 +0100 |
commit | ca4811b3087f9d34754d3debf839e247593b8a39 (patch) | |
tree | 5396418f60583be8d6350d594ac9842a73e173f2 /tests/oauth2/rfc6749/clients/test_web_application.py | |
parent | a144769a9a44c85eb17774e7a513ffc5a92a354d (diff) | |
download | oauthlib-ca4811b3087f9d34754d3debf839e247593b8a39.tar.gz |
Wrap OAuth2 tokens in a OAuth2Token class.
The OAuth2Token class allows for easy checking of scope
changes and might be extended with further convenience
methods in the future.
Additionally, the Warning raised on scope change will now
include a ``token`` parameter with a full OAuth 2 token
in case scope change is fine, which ideally it should be.
Users who don't want to catch a warning can instead
check the boolean token property ``token.scope_changed``. Note
that the warning must first be disabled by setting the
environment variable ``OAUTHLIB_RELAX_TOKEN_SCOPE``.
Diffstat (limited to 'tests/oauth2/rfc6749/clients/test_web_application.py')
-rw-r--r-- | tests/oauth2/rfc6749/clients/test_web_application.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/oauth2/rfc6749/clients/test_web_application.py b/tests/oauth2/rfc6749/clients/test_web_application.py index 6f7b7e1..103c166 100644 --- a/tests/oauth2/rfc6749/clients/test_web_application.py +++ b/tests/oauth2/rfc6749/clients/test_web_application.py @@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals import datetime +import os from mock import patch @@ -128,6 +129,12 @@ class WebApplicationClientTest(TestCase): self.assertEqual(client.token_type, response.get("token_type")) # Mismatching state + self.assertRaises(Warning, client.parse_request_body_response, self.token_json, scope="invalid") + os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE'] = '1' + token = client.parse_request_body_response(self.token_json, scope="invalid") + self.assertTrue(token.scope_changed) + del os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE'] + scope_changes_recorded = [] def record_scope_change(sender, message, old, new): scope_changes_recorded.append((message, old, new)) |