Commit 318a9d71 authored by David Douard's avatar David Douard
Browse files

Fix unit tests (new FakeRequest API)

Use FakeRequest.set_request_header.
parent d0cff13de5b8
......@@ -40,7 +40,7 @@ def setUpModule():
global secretfile
config = TrustAuthTC.config
home = config.apphome
print home
# print home
class TrustAuthTC(CubicWebTC):
......@@ -52,16 +52,19 @@ class TrustAuthTC(CubicWebTC):
def test_login(self):
req, origsession = self.init_authentication('http')
req._headers['x-remote-user'] = 'admin'
req.set_request_header('x-remote-user', 'admin', raw=True)
self.assertAuthSuccess(req, origsession)
self.assertRaises(LogOut, self.app_publish, req, 'logout')
self.assertEqual(len(self.open_sessions), 0)
def test_failed_login(self):
req, origsession = self.init_authentication('http')
req._headers['x-remote-user'] = 'toto'
req.set_request_header('x-remote-user', 'toto', raw=True)
self.assertAuthFailure(req)
req._headers['x-remote-user'] = 'admin'
req.set_request_header('x-remote-user', 'admin', raw=True)
self.assertAuthSuccess(req, origsession)
self.assertRaises(LogOut, self.app_publish, req, 'logout')
self.assertEqual(len(self.open_sessions), 0)
if __name__ == "__main__":
unittest_main()
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