allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [1/3] allura git commit: [#7805] ticket:696 Add convenient way to perform custom actions after token is fetched
Date Tue, 09 Dec 2014 14:17:08 GMT
Repository: allura
Updated Branches:
  refs/heads/ib/7805 [created] 9688bb55e


[#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/9688bb55
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/9688bb55
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/9688bb55

Branch: refs/heads/ib/7805
Commit: 9688bb55ebbd3975e700381321ad5139042004cb
Parents: 5cb3cdc
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Thu Dec 4 16:59:44 2014 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Tue Dec 9 09:36:49 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/9688bb55/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/9688bb55/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