From 809553ccb71f5c046454e5ce2ac90ab0757729f0 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Sun, 5 Oct 2014 09:21:55 -0400 Subject: Dispatch a blinker signal on scope change, instead of raising a warning See https://github.com/idan/oauthlib/pull/265 for rationale. In brief: raising any exception blows the stack, which is inappropriate for a non-error state. --- tests/oauth2/rfc6749/clients/test_web_application.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tests/oauth2/rfc6749/clients/test_web_application.py') diff --git a/tests/oauth2/rfc6749/clients/test_web_application.py b/tests/oauth2/rfc6749/clients/test_web_application.py index 0eac008..6f7b7e1 100644 --- a/tests/oauth2/rfc6749/clients/test_web_application.py +++ b/tests/oauth2/rfc6749/clients/test_web_application.py @@ -5,7 +5,7 @@ import datetime from mock import patch -from oauthlib import common +from oauthlib import common, signals from oauthlib.oauth2.rfc6749 import utils, errors from oauthlib.oauth2 import Client from oauthlib.oauth2 import WebApplicationClient @@ -128,4 +128,17 @@ 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") + scope_changes_recorded = [] + def record_scope_change(sender, message, old, new): + scope_changes_recorded.append((message, old, new)) + + signals.scope_changed.connect(record_scope_change) + try: + client.parse_request_body_response(self.token_json, scope="invalid") + self.assertEqual(len(scope_changes_recorded), 1) + message, old, new = scope_changes_recorded[0] + self.assertEqual(message, 'Scope has changed from "invalid" to "/profile".') + self.assertEqual(old, ['invalid']) + self.assertEqual(new, ['/profile']) + finally: + signals.scope_changed.disconnect(record_scope_change) -- cgit v1.2.1