You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/02/16 12:44:39 UTC
[08/37] allura git commit: [#7831] minor code improvements, including:
[#7831] minor code improvements, including:
* disable_auth_magic=False should do what you expect
* set extra_environ on the app instead of on each request in the test
* assert_equal for more helpful failure output
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6face2df
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6face2df
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6face2df
Branch: refs/heads/ib/4542
Commit: 6face2dfee01a32bd1559f772a5b09c2d09c142b
Parents: 6bc50fe
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Feb 11 17:01:23 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Feb 11 17:10:21 2015 +0000
----------------------------------------------------------------------
Allura/allura/controllers/basetest_project_root.py | 8 ++++----
Allura/allura/tests/functional/test_auth.py | 12 ++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/6face2df/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 459a62f..f655437 100644
--- a/Allura/allura/controllers/basetest_project_root.py
+++ b/Allura/allura/controllers/basetest_project_root.py
@@ -25,6 +25,7 @@ from pylons import tmpl_context as c
from pylons import request
from webob import exc
from tg import expose
+from paste.deploy.converters import asbool
from allura.lib.base import WsgiDispatchController
from allura.lib.security import require, require_authenticated, require_access, has_access
@@ -118,7 +119,7 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
return app.root, remainder
def __call__(self, environ, start_response):
- """ Called from a turbo gears 'app' instance.
+ """ Called from a WebTest 'app' instance.
:param environ: Extra environment variables.
@@ -127,11 +128,10 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
c.app = None
c.project = M.Project.query.get(
shortname='test', neighborhood_id=self.p_nbhd._id)
- if 'disable_auth_magic' in environ:
- auth = plugin.AuthenticationProvider.get(request)
+ auth = plugin.AuthenticationProvider.get(request)
+ if asbool(environ.get('disable_auth_magic')):
c.user = auth.authenticate_request()
else:
- auth = plugin.AuthenticationProvider.get(request)
user = auth.by_username(environ.get('username', 'test-admin'))
if not user:
user = M.User.anonymous()
http://git-wip-us.apache.org/repos/asf/allura/blob/6face2df/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 bfd3c72..b71ffcd 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -75,19 +75,19 @@ class TestAuth(TestController):
assert 'Invalid login' in str(r), r.showbrowser()
def test_logout(self):
- environ = {'disable_auth_magic': "True"}
- r = self.app.get('/auth/', extra_environ=environ)
+ self.app.extra_environ = {'disable_auth_magic': 'True'}
+ r = self.app.get('/auth/')
f = r.forms[0]
f['username'] = 'test-user'
f['password'] = 'foo'
- r = f.submit().follow(extra_environ=environ)
+ r = f.submit().follow()
logged_in_session = r.session['_id']
- assert r.html.nav('a')[-1].string == "Log Out"
+ assert_equal(r.html.nav('a')[-1].string, "Log Out")
- r = self.app.get('/auth/logout', extra_environ=environ).follow(extra_environ=environ)
+ r = self.app.get('/auth/logout').follow()
logged_out_session = r.session['_id']
assert logged_in_session is not logged_out_session
- assert r.html.nav('a')[-1].string == 'Log In'
+ assert_equal(r.html.nav('a')[-1].string, 'Log In')
def test_track_login(self):
user = M.User.by_username('test-user')