allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [13/44] git commit: [#5271] Added test for disabled user
Date Tue, 27 Nov 2012 13:46:06 GMT
[#5271] Added test for disabled user

Signed-off-by: Cory Johns <johnsca@geek.net>


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

Branch: refs/heads/cj/4691
Commit: fbd5912b2a1afefea59edbadea5dad25b50aad52
Parents: 2b2049f
Author: Cory Johns <johnsca@geek.net>
Authored: Tue Nov 13 16:35:07 2012 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Tue Nov 13 16:42:56 2012 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/basetest_project_root.py |    6 +++-
 Allura/allura/tests/functional/test_auth.py        |   17 ++++++++++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fbd5912b/Allura/allura/controllers/basetest_project_root.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/basetest_project_root.py b/Allura/allura/controllers/basetest_project_root.py
index c45d64d..2c25f5f 100644
--- a/Allura/allura/controllers/basetest_project_root.py
+++ b/Allura/allura/controllers/basetest_project_root.py
@@ -104,8 +104,10 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
     def __call__(self, environ, start_response):
         c.app = None
         c.project = M.Project.query.get(shortname='test', neighborhood_id=self.p_nbhd._id)
-        c.user = plugin.AuthenticationProvider.get(request).by_username(
-            environ.get('username', 'test-admin'))
+        auth = plugin.AuthenticationProvider.get(request)
+        user = auth.by_username(environ.get('username', 'test-admin'))
+        environ['beaker.session']['userid'] = user._id
+        c.user = auth.authenticate_request()
         return WsgiDispatchController.__call__(self, environ, start_response)
 
 class DispatchTest(object):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/fbd5912b/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 3493594..94d221e 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -9,7 +9,7 @@ from pylons import c
 from allura.tests import TestController
 from allura.tests import decorators as td
 from allura import model as M
-from ming.orm.ormsession import ThreadLocalORMSession
+from ming.orm.ormsession import ThreadLocalORMSession, session
 from allura.lib import oid_helper
 
 
@@ -359,3 +359,18 @@ class TestAuth(TestController):
     def test_default_lookup(self):
         # Make sure that default _lookup() throws 404
         self.app.get('/auth/foobar', status=404)
+
+    def test_disabled_user(self):
+        user = M.User.query.get(username='test-admin')
+        sess = session(user)
+        assert not user.disabled
+        r = self.app.get('/p/test/admin/', extra_environ={'username':'test-admin'})
+        assert_equal(r.status_int, 200, 'Redirect to %s' % r.location)
+        user.disabled = True
+        sess.save(user)
+        sess.flush()
+        user = M.User.query.get(username='test-admin')
+        assert user.disabled
+        r = self.app.get('/p/test/admin/', extra_environ={'username':'test-admin'})
+        assert_equal(r.status_int, 302)
+        assert_equal(r.location, 'http://localhost/auth/?return_to=%2Fp%2Ftest%2Fadmin%2F')


Mime
View raw message