Commit 240f1acc authored by Simon Chabot's avatar Simon Chabot
Browse files

fix(deprecation): base64 encodestring is deprecated use encodebytes

https://docs.python.org/3.8/library/base64.html#base64.encodestring

encodestring is dropped in python3.9 (released today \o/)

--HG--
branch : 3.28
parent e86d65ac2666
......@@ -1617,7 +1617,7 @@ generator_entity_headers = {
'Content-Language': (generateList, singleHeader),
'Content-Length': (unique, str, singleHeader),
'Content-Location': (unique, str, singleHeader),
'Content-MD5': (base64.encodestring, lambda x: x.strip("\n"), singleHeader),
'Content-MD5': (base64.encodebytes, lambda x: x.strip("\n"), singleHeader),
'Content-Range': (generateContentRange, singleHeader),
'Content-Type': (generateContentType, singleHeader),
'Expires': (generateDateTime, singleHeader),
......
......@@ -640,7 +640,7 @@ class ApplicationTC(CubicWebTC):
self.app.handle_request(req)
self.assertEqual(401, req.status_out)
clear_cache(req, 'get_authorization')
authstr = base64.encodestring(('%s:%s' % (self.admlogin, self.admpassword)).encode('ascii'))
authstr = base64.encodebytes(('%s:%s' % (self.admlogin, self.admpassword)).encode('ascii'))
req.set_request_header('Authorization', 'basic %s' % authstr.decode('ascii'))
self.assertAuthSuccess(req)
req._url = 'logout'
......@@ -717,10 +717,10 @@ class ApplicationTC(CubicWebTC):
def test_http_auth_anon_allowed(self):
req = self.init_authentication('http', 'anon')
self._test_auth_anon(req)
authstr = base64.encodestring(b'toto:pouet')
authstr = base64.encodebytes(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)).encode('ascii'))
authstr = base64.encodebytes(('%s:%s' % (self.admlogin, self.admpassword)).encode('ascii'))
req.set_request_header('Authorization', 'basic %s' % authstr.decode('ascii'))
self.assertAuthSuccess(req)
req._url = 'logout'
......
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