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 2012/11/13 17:35:22 UTC

git commit: [#5271] Added test for disabled user

Updated Branches:
  refs/heads/cj/5271 92f8967f6 -> 6b644e5fc


[#5271] Added test for disabled user

Signed-off-by: Cory Johns <jo...@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/6b644e5f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/6b644e5f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/6b644e5f

Branch: refs/heads/cj/5271
Commit: 6b644e5fcae626a3fc88523170c49777ac98af80
Parents: 92f8967
Author: Cory Johns <jo...@geek.net>
Authored: Tue Nov 13 16:35:07 2012 +0000
Committer: Cory Johns <jo...@geek.net>
Committed: Tue Nov 13 16:35:07 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/6b644e5f/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/6b644e5f/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')