From b1e0c9681a87f18adec8d7bfda8874c364a24e7b Mon Sep 17 00:00:00 2001 From: Nicco Date: Thu, 19 Feb 2015 14:29:27 -0300 Subject: [PATCH 1/3] Update setup.py adding tests_require option ;-) --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6b9594a..1638741 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,9 @@ setup( url='http://github.com/juanifioren/django-oidc-provider', author='Juan Ignacio Fiorentino', author_email='juanifioren@gmail.com', + + tests_require=[], + classifiers=[ 'Environment :: Web Environment', 'Framework :: Django', @@ -33,4 +36,4 @@ setup( install_requires=[ 'pyjwt==0.3.1', ], -) \ No newline at end of file +) From dedc70b05a2c0a93e41603162edbe5a626edcd4e Mon Sep 17 00:00:00 2001 From: juanifioren Date: Thu, 19 Feb 2015 15:45:51 -0300 Subject: [PATCH 2/3] Edit tests. --- README.rst | 2 +- ...low.py => test_authorization_code_flow.py} | 22 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) rename oidc_provider/tests/{test_code_flow.py => test_authorization_code_flow.py} (83%) diff --git a/README.rst b/README.rst index 5368202..69e8f57 100644 --- a/README.rst +++ b/README.rst @@ -8,7 +8,7 @@ OpenID Connect Provider implementation for Django. Read docs for more info. http Running tests ************* -Just run them as normal Django tests. +You need a Django project properly configured with the package. Then just run tests as normal. .. code:: diff --git a/oidc_provider/tests/test_code_flow.py b/oidc_provider/tests/test_authorization_code_flow.py similarity index 83% rename from oidc_provider/tests/test_code_flow.py rename to oidc_provider/tests/test_authorization_code_flow.py index d43ad39..8de1662 100644 --- a/oidc_provider/tests/test_code_flow.py +++ b/oidc_provider/tests/test_authorization_code_flow.py @@ -9,7 +9,7 @@ from oidc_provider.views import * import urllib -class CodeFlowTestCase(TestCase): +class AuthorizationCodeFlowTestCase(TestCase): def setUp(self): self.factory = RequestFactory() @@ -99,7 +99,9 @@ class CodeFlowTestCase(TestCase): self.assertEqual(is_next_ok, True) def test_authorize_user_consent(self): - url = self._create_authorize_url(response_type='code') + response_type = 'code' + + url = self._create_authorize_url(response_type=response_type) request = self.factory.get(url) # Simulate that the user is logged. @@ -107,4 +109,18 @@ class CodeFlowTestCase(TestCase): response = AuthorizeView.as_view()(request) - import pdb; pdb.set_trace() \ No newline at end of file + # Check if hidden inputs exists in the form, also + # check if their values are valid. + + input_html = '' + + to_check = { + 'client_id': self.client.client_id, + 'redirect_uri': self.client.default_redirect_uri, + 'response_type': response_type, + } + + for key, value in to_check.iteritems(): + is_input_ok = input_html.format(key, value) in response.content + self.assertEqual(is_input_ok, True, + msg='Hidden input for "'+key+'" fails.') From e40a62cecc9e8d4192bedb3ddcd091554051ab7f Mon Sep 17 00:00:00 2001 From: juanifioren Date: Fri, 20 Feb 2015 14:33:18 -0300 Subject: [PATCH 3/3] Add doc to tests. --- README.rst | 4 +++- oidc_provider/tests/test_authorization_code_flow.py | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 69e8f57..fa3719b 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,9 @@ Django OIDC Provider #################### -OpenID Connect Provider implementation for Django. Read docs for more info. https://github.com/juanifioren/django-oidc-provider/wiki +OpenID Connect Provider implementation for Django. + +Read docs for more info. https://github.com/juanifioren/django-oidc-provider/wiki ************* Running tests diff --git a/oidc_provider/tests/test_authorization_code_flow.py b/oidc_provider/tests/test_authorization_code_flow.py index 8de1662..8d118bf 100644 --- a/oidc_provider/tests/test_authorization_code_flow.py +++ b/oidc_provider/tests/test_authorization_code_flow.py @@ -99,6 +99,13 @@ class AuthorizationCodeFlowTestCase(TestCase): self.assertEqual(is_next_ok, True) def test_authorize_user_consent(self): + """ + Once the End-User is authenticated, the Authorization Server MUST + obtain an authorization decision before releasing information to + the Client. + + See: http://openid.net/specs/openid-connect-core-1_0.html#Consent + """ response_type = 'code' url = self._create_authorize_url(response_type=response_type)