{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/comments/46239390","id":46239390,"diff_hunk":"@@ -0,0 +1,107 @@\n+\"\"\"\n+Tests various flows through using the Authorization Endpoint.\n+\"\"\"\n+from urlparse import urlparse, parse_qs\n+\n+import ddt\n+import provider.oauth2.models\n+import provider.scope\n+\n+from oauth2_provider.tests.base import OAuth2TestCase, IDTokenTestCase\n+\n+\n+@ddt.ddt\n+class ImplicitFlowTestCase(IDTokenTestCase):\n+    \"\"\"\n+    Test OIDC-related extensions to the OAuth2 Authorization flows\n+    implemented by this package.\n+    \"\"\"\n+\n+    def _get_auth_payload(self, location):\n+        \"\"\"\n+        DRY helper.  Extract auth parameters from the redirect location as\n+        returned during the implicit flow.\n+        \"\"\"\n+        self.assertTrue(location.startswith(self.auth_client.redirect_uri + '#'))\n+        return {k: v[0] for k, v in parse_qs(urlparse(location).fragment).items()}\n+\n+    def _get_access_token(self, scope):\n+        \"\"\"\n+        DRY helper.  Find the access token generated during our auth request.\n+        \"\"\"\n+        return provider.oauth2.models.AccessToken.objects.get(\n+            user=self.user, client=self.auth_client, scope=provider.scope.to_int(*scope.split())\n+        )\n+\n+    @ddt.data(\n+        ('openid', 'id_token token'),\n+        ('openid', 'id_token'),\n+        ('openid profile', 'id_token'),\n+        ('openid profile email', 'id_token'),\n+    )\n+    @ddt.unpack\n+    def test_oidc_implicit_flow(self, scope, response_type):\n+        \"\"\"\n+        Ensure that valid permutations of scope and response_type result in\n+        correct OIDC behavior under the implicit flow.\n+        \"\"\"\n+        response = self.login_and_authorize(scope=scope, response_type=response_type, trusted=True)\n+        self.assertEqual(302, response.status_code)\n+        auth_payload = self._get_auth_payload(response['Location'])\n+\n+        # check state\n+        self.assertEqual(auth_payload['state'], 'some_state')\n+\n+        # check scope\n+        self.assertEqual(set(auth_payload['scope'].split()), set(scope.split()))\n+\n+        expected_token = self._get_access_token(scope)","path":"oauth2_provider/tests/test_authorization.py","position":58,"original_position":58,"commit_id":"7b59d50c05e3c095d84a8330255fbf8b45abb0e8","original_commit_id":"7b59d50c05e3c095d84a8330255fbf8b45abb0e8","user":{"login":"jimabramson","id":1349368,"avatar_url":"https://avatars.githubusercontent.com/u/1349368?v=3","gravatar_id":"","url":"https://api.github.com/users/jimabramson","html_url":"https://github.com/jimabramson","followers_url":"https://api.github.com/users/jimabramson/followers","following_url":"https://api.github.com/users/jimabramson/following{/other_user}","gists_url":"https://api.github.com/users/jimabramson/gists{/gist_id}","starred_url":"https://api.github.com/users/jimabramson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimabramson/subscriptions","organizations_url":"https://api.github.com/users/jimabramson/orgs","repos_url":"https://api.github.com/users/jimabramson/repos","events_url":"https://api.github.com/users/jimabramson/events{/privacy}","received_events_url":"https://api.github.com/users/jimabramson/received_events","type":"User","site_admin":false},"body":"in the test we need to fetch the underlying access token even if we don't expect it to be included in the response.   whether or not it is included in the response is still checked below (L61-66)","created_at":"2015-12-01T04:33:16Z","updated_at":"2015-12-01T04:33:16Z","html_url":"https://github.com/edx/edx-oauth2-provider/pull/34#discussion_r46239390","pull_request_url":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/comments/46239390"},"html":{"href":"https://github.com/edx/edx-oauth2-provider/pull/34#discussion_r46239390"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/34","id":51853132,"html_url":"https://github.com/edx/edx-oauth2-provider/pull/34","diff_url":"https://github.com/edx/edx-oauth2-provider/pull/34.diff","patch_url":"https://github.com/edx/edx-oauth2-provider/pull/34.patch","issue_url":"https://api.github.com/repos/edx/edx-oauth2-provider/issues/34","number":34,"state":"open","locked":false,"title":"Implement OIDC implicit flow.","user":{"login":"jimabramson","id":1349368,"avatar_url":"https://avatars.githubusercontent.com/u/1349368?v=3","gravatar_id":"","url":"https://api.github.com/users/jimabramson","html_url":"https://github.com/jimabramson","followers_url":"https://api.github.com/users/jimabramson/followers","following_url":"https://api.github.com/users/jimabramson/following{/other_user}","gists_url":"https://api.github.com/users/jimabramson/gists{/gist_id}","starred_url":"https://api.github.com/users/jimabramson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimabramson/subscriptions","organizations_url":"https://api.github.com/users/jimabramson/orgs","repos_url":"https://api.github.com/users/jimabramson/repos","events_url":"https://api.github.com/users/jimabramson/events{/privacy}","received_events_url":"https://api.github.com/users/jimabramson/received_events","type":"User","site_admin":false},"body":"ECOM-2440\r\n\r\ndepends on https://github.com/edx/django-oauth2-provider/pull/22 - will update setup/requirements when that has merged.\r\n\r\n@clintonb @nasthagiri  please review\r\n@justinabrahms FYI","created_at":"2015-11-25T22:28:22Z","updated_at":"2015-12-01T04:33:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bb25b6e35f2cdde9ce8252b04af877bb7df56071","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/34/commits","review_comments_url":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/34/comments","review_comment_url":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-oauth2-provider/issues/34/comments","statuses_url":"https://api.github.com/repos/edx/edx-oauth2-provider/statuses/7b59d50c05e3c095d84a8330255fbf8b45abb0e8","head":{"label":"edx:jsa/implicit2","ref":"jsa/implicit2","sha":"7b59d50c05e3c095d84a8330255fbf8b45abb0e8","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":23121224,"name":"edx-oauth2-provider","full_name":"edx/edx-oauth2-provider","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-oauth2-provider","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-oauth2-provider","forks_url":"https://api.github.com/repos/edx/edx-oauth2-provider/forks","keys_url":"https://api.github.com/repos/edx/edx-oauth2-provider/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-oauth2-provider/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-oauth2-provider/teams","hooks_url":"https://api.github.com/repos/edx/edx-oauth2-provider/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-oauth2-provider/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-oauth2-provider/events","assignees_url":"https://api.github.com/repos/edx/edx-oauth2-provider/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-oauth2-provider/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-oauth2-provider/tags","blobs_url":"https://api.github.com/repos/edx/edx-oauth2-provider/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-oauth2-provider/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-oauth2-provider/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-oauth2-provider/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-oauth2-provider/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-oauth2-provider/languages","stargazers_url":"https://api.github.com/repos/edx/edx-oauth2-provider/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-oauth2-provider/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-oauth2-provider/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-oauth2-provider/subscription","commits_url":"https://api.github.com/repos/edx/edx-oauth2-provider/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-oauth2-provider/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-oauth2-provider/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-oauth2-provider/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-oauth2-provider/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-oauth2-provider/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-oauth2-provider/merges","archive_url":"https://api.github.com/repos/edx/edx-oauth2-provider/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-oauth2-provider/downloads","issues_url":"https://api.github.com/repos/edx/edx-oauth2-provider/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-oauth2-provider/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-oauth2-provider/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-oauth2-provider/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-oauth2-provider/releases{/id}","created_at":"2014-08-19T18:31:59Z","updated_at":"2015-09-09T14:18:15Z","pushed_at":"2015-11-27T21:59:48Z","git_url":"git://github.com/edx/edx-oauth2-provider.git","ssh_url":"git@github.com:edx/edx-oauth2-provider.git","clone_url":"https://github.com/edx/edx-oauth2-provider.git","svn_url":"https://github.com/edx/edx-oauth2-provider","homepage":null,"size":120,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":1,"forks":9,"open_issues":1,"watchers":5,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"052313fde50287c6c57601304c952ca6fc8b7290","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":23121224,"name":"edx-oauth2-provider","full_name":"edx/edx-oauth2-provider","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-oauth2-provider","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-oauth2-provider","forks_url":"https://api.github.com/repos/edx/edx-oauth2-provider/forks","keys_url":"https://api.github.com/repos/edx/edx-oauth2-provider/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-oauth2-provider/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-oauth2-provider/teams","hooks_url":"https://api.github.com/repos/edx/edx-oauth2-provider/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-oauth2-provider/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-oauth2-provider/events","assignees_url":"https://api.github.com/repos/edx/edx-oauth2-provider/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-oauth2-provider/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-oauth2-provider/tags","blobs_url":"https://api.github.com/repos/edx/edx-oauth2-provider/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-oauth2-provider/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-oauth2-provider/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-oauth2-provider/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-oauth2-provider/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-oauth2-provider/languages","stargazers_url":"https://api.github.com/repos/edx/edx-oauth2-provider/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-oauth2-provider/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-oauth2-provider/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-oauth2-provider/subscription","commits_url":"https://api.github.com/repos/edx/edx-oauth2-provider/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-oauth2-provider/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-oauth2-provider/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-oauth2-provider/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-oauth2-provider/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-oauth2-provider/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-oauth2-provider/merges","archive_url":"https://api.github.com/repos/edx/edx-oauth2-provider/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-oauth2-provider/downloads","issues_url":"https://api.github.com/repos/edx/edx-oauth2-provider/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-oauth2-provider/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-oauth2-provider/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-oauth2-provider/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-oauth2-provider/releases{/id}","created_at":"2014-08-19T18:31:59Z","updated_at":"2015-09-09T14:18:15Z","pushed_at":"2015-11-27T21:59:48Z","git_url":"git://github.com/edx/edx-oauth2-provider.git","ssh_url":"git@github.com:edx/edx-oauth2-provider.git","clone_url":"https://github.com/edx/edx-oauth2-provider.git","svn_url":"https://github.com/edx/edx-oauth2-provider","homepage":null,"size":120,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":1,"forks":9,"open_issues":1,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/34"},"html":{"href":"https://github.com/edx/edx-oauth2-provider/pull/34"},"issue":{"href":"https://api.github.com/repos/edx/edx-oauth2-provider/issues/34"},"comments":{"href":"https://api.github.com/repos/edx/edx-oauth2-provider/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-oauth2-provider/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-oauth2-provider/statuses/7b59d50c05e3c095d84a8330255fbf8b45abb0e8"}}}}