allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [1/3] allura git commit: [#7805] ticket:696 Add convenient way to perform custom actions after token is fetched
Date Thu, 11 Dec 2014 19:15:43 GMT
Repository: allura
Updated Branches:
  refs/heads/master f2e4241ea -> 6bc42a205


[#7805] ticket:696 Add convenient way to perform custom actions after token is fetched


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6bc42a20
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6bc42a20
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6bc42a20

Branch: refs/heads/master
Commit: 6bc42a205d468b430f41e7b96672e039d83845f9
Parents: fbb7ba4
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Thu Dec 4 16:59:44 2014 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Dec 11 19:15:37 2014 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/__init__.py         | 6 ++++++
 ForgeImporters/forgeimporters/github/tests/test_oauth.py | 6 ++++++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6bc42a20/ForgeImporters/forgeimporters/github/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index e0a3dd5..fe501dd 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -214,8 +214,14 @@ class GitHubOAuthMixin(object):
         )
         c.user.set_tool_data('GitHubProjectImport',
                              token=token['access_token'])
+        self.oauth_callback_complete()
         redirect(session.get('github.oauth.redirect', '/'))
 
+    def oauth_callback_complete(self):
+        """Subclasses can implement this to perform additional actions when
+        token is retrieved"""
+        pass
+
     def oauth_has_access(self, scope):
         if not scope:
             return False

http://git-wip-us.apache.org/repos/asf/allura/blob/6bc42a20/ForgeImporters/forgeimporters/github/tests/test_oauth.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_oauth.py b/ForgeImporters/forgeimporters/github/tests/test_oauth.py
index c6fb8f3..584b403 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_oauth.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_oauth.py
@@ -52,3 +52,9 @@ class TestGitHubOAuthMixin(TestController, TestCase):
         self.assertFalse(self.mix.oauth_has_access('write:repo_hook'))
         req.head.return_value.headers = {'X-OAuth-Scopes': 'write:repo_hook, user'}
         self.assertTrue(self.mix.oauth_has_access('write:repo_hook'))
+
+    @patch('forgeimporters.github.OAuth2Session')
+    def test_oauth_callback_complete(self, oauth):
+        with patch.object(self.mix, 'oauth_callback_complete') as _mock:
+            self.mix.oauth_callback()
+            _mock.assert_called_once()


Mime
View raw message