web/test/unittest_application.py
changeset 10779 6cef304aca4c
parent 10735 cb83ba66fa61
child 10780 a96ed0acc556
--- a/web/test/unittest_application.py	Tue Oct 06 11:14:15 2015 +0200
+++ b/web/test/unittest_application.py	Tue Oct 06 11:15:56 2015 +0200
@@ -317,8 +317,8 @@
         self.app.handle_request(req, 'login')
         self.assertEqual(401, req.status_out)
         clear_cache(req, 'get_authorization')
-        authstr = base64.encodestring('%s:%s' % (self.admlogin, self.admpassword))
-        req.set_request_header('Authorization', 'basic %s' % authstr)
+        authstr = base64.encodestring(('%s:%s' % (self.admlogin, self.admpassword)).encode('ascii'))
+        req.set_request_header('Authorization', 'basic %s' % authstr.decode('ascii'))
         self.assertAuthSuccess(req, origsession)
         self.assertRaises(LogOut, self.app_handle_request, req, 'logout')
         self.assertEqual(len(self.open_sessions), 0)
@@ -393,11 +393,11 @@
     def test_http_auth_anon_allowed(self):
         req, origsession = self.init_authentication('http', 'anon')
         self._test_auth_anon(req)
-        authstr = base64.encodestring('toto:pouet')
-        req.set_request_header('Authorization', 'basic %s' % authstr)
+        authstr = base64.encodestring(b'toto:pouet')
+        req.set_request_header('Authorization', 'basic %s' % authstr.decode('ascii'))
         self._test_anon_auth_fail(req)
-        authstr = base64.encodestring('%s:%s' % (self.admlogin, self.admpassword))
-        req.set_request_header('Authorization', 'basic %s' % authstr)
+        authstr = base64.encodestring(('%s:%s' % (self.admlogin, self.admpassword)).encode('ascii'))
+        req.set_request_header('Authorization', 'basic %s' % authstr.decode('ascii'))
         self.assertAuthSuccess(req, origsession)
         self.assertRaises(LogOut, self.app_handle_request, req, 'logout')
         self.assertEqual(len(self.open_sessions), 0)