summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Whitacre <chad@zetaweb.com>2014-09-17 10:26:29 -0400
committerChad Whitacre <chad@zetaweb.com>2014-09-17 10:26:29 -0400
commitabf6bd5e9c413ad7f538f86604c0d1c29494882e (patch)
tree443c592182bfaabaa2e80a115d8d9c78b4b1350c
parent8fcceae9ef2d6e3c0cdf38b12ac71bc538dd6432 (diff)
downloadoauthlib-abf6bd5e9c413ad7f538f86604c0d1c29494882e.tar.gz
Failing test for URL-encoded access tokens
Facebook doesn't use JSON, see https://github.com/idan/oauthlib/issues/267.
-rw-r--r--tests/oauth2/rfc6749/test_parameters.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/oauth2/rfc6749/test_parameters.py b/tests/oauth2/rfc6749/test_parameters.py
index e1d0364..3c25115 100644
--- a/tests/oauth2/rfc6749/test_parameters.py
+++ b/tests/oauth2/rfc6749/test_parameters.py
@@ -118,6 +118,21 @@ class ParameterTests(TestCase):
'scope': ['abc', 'def']
}
+ url_encoded_response = ('access_token=2YotnFZFEjr1zCsicMWpAA'
+ '&token_type=example'
+ '&expires_in=3600'
+ '&refresh_token=tGzv3JOkF0XG5Qx2TlKWIA'
+ '&example_parameter=example_value'
+ '&scope=abc def')
+
+ url_encoded_error = 'error=invalid_request'
+
+ url_encoded_notoken = ('token_type=example'
+ '&expires_in=3600'
+ '&refresh_token=tGzv3JOkF0XG5Qx2TlKWIA'
+ '&example_parameter=example_value')
+
+
def test_prepare_grant_uri(self):
"""Verify correct authorization URI construction."""
self.assertURLEqual(prepare_grant_uri(**self.auth_grant), self.auth_grant_uri)
@@ -166,3 +181,10 @@ class ParameterTests(TestCase):
self.assertRaises(InvalidRequestError, parse_token_response, self.json_error)
self.assertRaises(MissingTokenError, parse_token_response, self.json_notoken)
self.assertRaises(Warning, parse_token_response, self.json_response, scope='aaa')
+
+ def test_url_encoded_token_response(self):
+ """Verify correct parameter parsing and validation for token responses. """
+ self.assertEqual(parse_token_response(self.url_encoded_response), self.json_dict)
+ self.assertRaises(InvalidRequestError, parse_token_response, self.url_encoded_error)
+ self.assertRaises(MissingTokenError, parse_token_response, self.url_encoded_notoken)
+ self.assertRaises(Warning, parse_token_response, self.url_encoded_response, scope='aaa')