Commit 239bcdf4 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[web test] extract a set_auth_mode method from init_authentication and use it...

[web test] extract a set_auth_mode method from init_authentication and use it in test_fb_login_concept to avoid bad test interaction

--HG--
branch : stable
parent 923013173031
...@@ -662,13 +662,16 @@ class CubicWebTC(TestCase): ...@@ -662,13 +662,16 @@ class CubicWebTC(TestCase):
""" """
return self.expect_redirect(lambda x: self.app_publish(x, path), req) return self.expect_redirect(lambda x: self.app_publish(x, path), req)
def init_authentication(self, authmode, anonuser=None): def set_auth_mode(self, authmode, anonuser=None):
self.set_option('auth-mode', authmode) self.set_option('auth-mode', authmode)
self.set_option('anonymous-user', anonuser) self.set_option('anonymous-user', anonuser)
if anonuser is None: if anonuser is None:
self.config.anonymous_credential = None self.config.anonymous_credential = None
else: else:
self.config.anonymous_credential = (anonuser, anonuser) self.config.anonymous_credential = (anonuser, anonuser)
def init_authentication(self, authmode, anonuser=None):
self.set_auth_mode(authmode, anonuser)
req = self.request() req = self.request()
origsession = req.session origsession = req.session
req.session = req.cnx = None req.session = req.cnx = None
......
...@@ -315,8 +315,7 @@ class ApplicationTC(CubicWebTC): ...@@ -315,8 +315,7 @@ class ApplicationTC(CubicWebTC):
def test_fb_login_concept(self): def test_fb_login_concept(self):
"""see data/views.py""" """see data/views.py"""
self.set_option('auth-mode', 'cookie') self.set_auth_mode('cookie', 'anon')
self.set_option('anonymous-user', 'anon')
self.login('anon') self.login('anon')
req = self.request() req = self.request()
origcnx = req.cnx origcnx = req.cnx
...@@ -325,6 +324,7 @@ class ApplicationTC(CubicWebTC): ...@@ -325,6 +324,7 @@ class ApplicationTC(CubicWebTC):
self.failIf(req.cnx is origcnx) self.failIf(req.cnx is origcnx)
self.assertEqual(req.user.login, 'turlututu') self.assertEqual(req.user.login, 'turlututu')
self.failUnless('turlututu' in page, page) self.failUnless('turlututu' in page, page)
req.cnx.close() # avoid warning
# authentication tests #################################################### # authentication tests ####################################################
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment