You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/02/27 23:32:53 UTC

[1/6] git commit: [#7029] ticket:521 added tests for auth providers additional_url functionality

Repository: incubator-allura
Updated Branches:
  refs/heads/master b38dcbf2a -> af77bf36e


[#7029] ticket:521 added tests for auth providers additional_url functionality


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

Branch: refs/heads/master
Commit: a02701ed7df6b891aa87ea05d94b7c8a8c77b81f
Parents: c09a54a
Author: tramzzz <st...@gmail.com>
Authored: Thu Jan 23 01:00:54 2014 +0200
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Feb 27 21:12:49 2014 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_auth.py | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a02701ed/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index bd6a4e2..ad4eab7 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -69,6 +69,14 @@ class TestAuth(TestController):
             username='test-usera', password='foo'))
         assert 'Invalid login' in str(r), r.showbrowser()
 
+    def test_auth_additional(self):
+        class TestProvider(plugin.LocalAuthenticationProvider):
+            def additional_url(self):
+                return ['/auth/send_verification_link',]
+
+        r = self.app.post('/auth/do_login', params=dict(
+                username='test-user', password='foo'))
+
     @td.with_user_project('test-admin')
     def test_prefs(self):
         r = self.app.get('/auth/preferences/',


[3/6] git commit: [#7029] ticket:521 comment not finished test

Posted by jo...@apache.org.
[#7029] ticket:521 comment not finished test


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

Branch: refs/heads/master
Commit: a49a5c72469e3d0429d548c63c769dfa26101a11
Parents: a02701e
Author: tramzzz <st...@gmail.com>
Authored: Tue Feb 4 11:56:11 2014 +0200
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Feb 27 21:14:40 2014 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_auth.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a49a5c72/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index ad4eab7..ec7d554 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -35,6 +35,7 @@ from allura.tests import TestController
 from allura.tests import decorators as td
 from allura import model as M
 from ming.orm.ormsession import ThreadLocalORMSession, session
+from allura.controllers import BaseController
 from tg import config
 from mock import patch
 from allura.lib import plugin
@@ -69,13 +70,13 @@ class TestAuth(TestController):
             username='test-usera', password='foo'))
         assert 'Invalid login' in str(r), r.showbrowser()
 
-    def test_auth_additional(self):
-        class TestProvider(plugin.LocalAuthenticationProvider):
-            def additional_url(self):
-                return ['/auth/send_verification_link',]
+    #def test_auth_additional(self):
+    #    class TestControl(BaseController):
+    #        def additional_url(self):
+     #           return ['/auth/send_verification_link',]
 
-        r = self.app.post('/auth/do_login', params=dict(
-                username='test-user', password='foo'))
+     #   r = self.app.post('/auth/do_login', params=dict(
+     #           username='test-user', password='foo'))
 
     @td.with_user_project('test-admin')
     def test_prefs(self):


[5/6] git commit: [#7029] ticket:521 Improve docstring for additional_urls

Posted by jo...@apache.org.
[#7029] ticket:521 Improve docstring for additional_urls


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

Branch: refs/heads/master
Commit: a738f1be7edb4fa85e1604e1504599031070a58d
Parents: 663ceca
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Feb 24 10:57:47 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Feb 27 21:15:21 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a738f1be/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 072d829..cfd9170 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -985,7 +985,14 @@ class UserPreferencesProvider(object):
 
     def additional_urls(self):
         '''
-        :return: [[str url, function], ]
+        Returns list of additional routes for AuthProvider.
+
+        No additional routes by default. Subclasses migth override this.
+
+        For example: [('newroute', newroute_handler), ] will add
+        'newroute' attribute to AuthProvider, which will be set to newroute_handler.
+
+        newroutehandler is a usual controller method (decorated with @exposed and other stuff).
         '''
         return []
 


[6/6] git commit: [#7029] Added auto-discovery of new user preference pages

Posted by jo...@apache.org.
[#7029] Added auto-discovery of new user preference pages

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/master
Commit: af77bf36e5ca56871fb4a8852e20afd2fb94a7c7
Parents: a738f1b
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Feb 27 22:32:11 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Feb 27 22:32:11 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py                 | 32 ++++++++++++++++++------
 Allura/allura/tests/functional/test_auth.py | 18 ++++++++++++-
 2 files changed, 41 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/af77bf36/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index cfd9170..d61f35f 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -987,14 +987,30 @@ class UserPreferencesProvider(object):
         '''
         Returns list of additional routes for AuthProvider.
 
-        No additional routes by default. Subclasses migth override this.
-
-        For example: [('newroute', newroute_handler), ] will add
-        'newroute' attribute to AuthProvider, which will be set to newroute_handler.
-
-        newroutehandler is a usual controller method (decorated with @exposed and other stuff).
-        '''
-        return []
+        By default, scans the provider for @expose()ed methods, which are
+        added as pages with the same name as the method.  Note that if you
+        want the new pages to show up in the menu on the various auth pages,
+        you will also need to add it to the list returned by
+        `AuthenticationProvider.account_navigation`.
+
+        If you want to override this behavior, you can override this method
+        and manually return a list of (page_name, handler) tuple pairs.  Note,
+        however, that this could break future subclasses of your providers'
+        ability to extend the list.
+
+        For example: `[('newroute', newroute_handler)]` will add 'newroute'
+        attribute to the auth controller, which will be set to `newroute_handler`.
+
+        `newroute_handler` must be decorated with @expose(), but does not have
+        to live on the provider.
+        '''
+        urls = []
+        for attr_name in dir(self):
+            attr_value = getattr(self, attr_name)
+            decoration = getattr(attr_value, 'decoration', None)
+            if getattr(decoration, 'exposed', False):
+                urls.append((attr_name, attr_value))
+        return urls
 
 
 class LocalUserPreferencesProvider(UserPreferencesProvider):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/af77bf36/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index bd6a4e2..8e36f5e 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -35,7 +35,7 @@ from allura.tests import TestController
 from allura.tests import decorators as td
 from allura import model as M
 from ming.orm.ormsession import ThreadLocalORMSession, session
-from tg import config
+from tg import config, expose
 from mock import patch
 from allura.lib import plugin
 
@@ -605,6 +605,22 @@ class TestPreferences(TestController):
             username='test-admin').get_pref('disable_user_messages')
 
 
+    @td.with_user_project('test-admin')
+    def test_additional_page(self):
+        class MyPP(plugin.UserPreferencesProvider):
+            def not_page(self):
+                return 'not page'
+            @expose()
+            def new_page(self):
+                return 'new page'
+
+        with mock.patch.object(plugin.UserPreferencesProvider, 'get') as upp_get:
+            upp_get.return_value = MyPP()
+            r = self.app.get('/auth/new_page')
+            assert_equal(r.body, 'new page')
+            self.app.get('/auth/not_page', status=404)
+
+
 class TestPasswordReset(TestController):
 
     @patch('allura.tasks.mail_tasks.sendmail')


[2/6] git commit: ticket:521 add but no test

Posted by jo...@apache.org.
ticket:521 add but no test


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

Branch: refs/heads/master
Commit: c09a54ade3f512cbaecb8dd37f4c7624a08e42c2
Parents: b38dcbf
Author: tramzzz <st...@gmail.com>
Authored: Mon Jan 20 16:03:10 2014 +0200
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Feb 27 21:12:49 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 3 +++
 Allura/allura/lib/plugin.py       | 4 ++++
 2 files changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c09a54ad/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 87e0c44..24a989a 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -76,6 +76,9 @@ class AuthController(BaseController):
         self.user_info = UserInfoController()
         self.subscriptions = SubscriptionsController()
         self.oauth = OAuthController()
+        urls = plugin.UserPreferencesProvider.get().additional_urls()
+        for u, method in urls:
+            setattr(self, u, method)
 
     @expose()
     def prefs(self, *args, **kwargs):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c09a54ad/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 7773bf0..b692078 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -983,6 +983,9 @@ class UserPreferencesProvider(object):
         '''
         raise NotImplementedError, 'find_by_display_name'
 
+    def additional_urls(self):
+        return []
+
 
 class LocalUserPreferencesProvider(UserPreferencesProvider):
 
@@ -1011,6 +1014,7 @@ class LocalUserPreferencesProvider(UserPreferencesProvider):
         return users
 
 
+
 class AdminExtension(object):
 
     """


[4/6] git commit: [#7029] ticket:521 test for additional urls in auth

Posted by jo...@apache.org.
[#7029] ticket:521 test for additional urls in auth


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

Branch: refs/heads/master
Commit: 663cecada7a2ccefd5dc07aea733b9f69f3c64a0
Parents: a49a5c7
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Tue Feb 18 02:25:05 2014 +0400
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Feb 27 21:15:21 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py                     |  4 ++-
 Allura/allura/tests/functional/test_auth.py     |  9 ------
 .../allura/tests/unit/controllers/test_auth.py  | 31 ++++++++++++++++++++
 3 files changed, 34 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/663cecad/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index b692078..072d829 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -984,6 +984,9 @@ class UserPreferencesProvider(object):
         raise NotImplementedError, 'find_by_display_name'
 
     def additional_urls(self):
+        '''
+        :return: [[str url, function], ]
+        '''
         return []
 
 
@@ -1014,7 +1017,6 @@ class LocalUserPreferencesProvider(UserPreferencesProvider):
         return users
 
 
-
 class AdminExtension(object):
 
     """

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/663cecad/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index ec7d554..bd6a4e2 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -35,7 +35,6 @@ from allura.tests import TestController
 from allura.tests import decorators as td
 from allura import model as M
 from ming.orm.ormsession import ThreadLocalORMSession, session
-from allura.controllers import BaseController
 from tg import config
 from mock import patch
 from allura.lib import plugin
@@ -70,14 +69,6 @@ class TestAuth(TestController):
             username='test-usera', password='foo'))
         assert 'Invalid login' in str(r), r.showbrowser()
 
-    #def test_auth_additional(self):
-    #    class TestControl(BaseController):
-    #        def additional_url(self):
-     #           return ['/auth/send_verification_link',]
-
-     #   r = self.app.post('/auth/do_login', params=dict(
-     #           username='test-user', password='foo'))
-
     @td.with_user_project('test-admin')
     def test_prefs(self):
         r = self.app.get('/auth/preferences/',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/663cecad/Allura/allura/tests/unit/controllers/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/controllers/test_auth.py b/Allura/allura/tests/unit/controllers/test_auth.py
new file mode 100644
index 0000000..c35c708
--- /dev/null
+++ b/Allura/allura/tests/unit/controllers/test_auth.py
@@ -0,0 +1,31 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+
+from mock import patch
+from allura.controllers.auth import AuthController
+
+
+@patch('allura.lib.plugin.LocalUserPreferencesProvider.additional_urls')
+def test_auth_additional(additional_urls):
+
+    def test_function():
+        return 'test'
+
+    additional_urls.return_value = [['test', test_function], ]
+    auth = AuthController()
+    assert auth.test()== 'test'
\ No newline at end of file