You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2020/06/16 20:29:30 UTC
[allura] branch master updated: Handle oauth scope checks better
when no access granted at all yet
This is an automated email from the ASF dual-hosted git repository.
kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new 579c739 Handle oauth scope checks better when no access granted at all yet
579c739 is described below
commit 579c739b0d321ad6f3608822d4ac43f504c4bd58
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Tue Jun 16 13:30:25 2020 -0400
Handle oauth scope checks better when no access granted at all yet
---
ForgeImporters/forgeimporters/github/__init__.py | 2 ++
ForgeImporters/forgeimporters/github/tests/test_oauth.py | 1 +
2 files changed, 3 insertions(+)
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index a5e3ddb..12fda29 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -260,5 +260,7 @@ class GitHubOAuthMixin(object):
if not token:
return False
r = access_token_details(token)
+ if r.status_code == 404:
+ return False
scopes = r.json()['scopes']
return scope in scopes
diff --git a/ForgeImporters/forgeimporters/github/tests/test_oauth.py b/ForgeImporters/forgeimporters/github/tests/test_oauth.py
index 563869c..f0b617e 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_oauth.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_oauth.py
@@ -48,6 +48,7 @@ class TestGitHubOAuthMixin(TestController, TestCase):
@patch('forgeimporters.github.requests')
def test_oauth_has_access_no(self, req):
c.user.get_tool_data.return_value = 'some-token'
+ req.post.return_value = Mock(status_code=404, json=Mock(return_value={}))
self.assertFalse(self.mix.oauth_has_access('write:repo_hook'))
call_args = req.post.call_args[0]
self.assertEqual(call_args, ('https://api.github.com/applications/123456/token',))