Commit 52911f70 authored by Jérome Perrin's avatar Jérome Perrin

bearer_token: py3

parent 0aa7b8da
...@@ -7,7 +7,7 @@ except KeyError: ...@@ -7,7 +7,7 @@ except KeyError:
key = context.getPortalObject().portal_preferences.getPreferredBearerTokenKey() key = context.getPortalObject().portal_preferences.getPreferredBearerTokenKey()
if context.Base_getHMAC(key, str(token_dict)) != token: if context.Base_getHMAC(key, str(token_dict).encode('utf-8')) != token:
# bizzare, not valid # bizzare, not valid
return None return None
......
...@@ -14,7 +14,7 @@ token = { ...@@ -14,7 +14,7 @@ token = {
'remote-addr': context.REQUEST.get('REMOTE_ADDR') 'remote-addr': context.REQUEST.get('REMOTE_ADDR')
} }
hmac = context.Base_getHMAC(key, str(token)) hmac = context.Base_getHMAC(key, str(token).encode('utf-8'))
context.Base_setBearerToken(hmac, token) context.Base_setBearerToken(hmac, token)
......
...@@ -108,7 +108,7 @@ class TestERP5BearerToken(ERP5TypeTestCase): ...@@ -108,7 +108,7 @@ class TestERP5BearerToken(ERP5TypeTestCase):
'remote-addr': self.portal.REQUEST.get('REMOTE_ADDR') 'remote-addr': self.portal.REQUEST.get('REMOTE_ADDR')
} }
hmac = self.portal.Base_getHMAC(self.portal.Base_getBearerTokenKey(), str( hmac = self.portal.Base_getHMAC(self.portal.Base_getBearerTokenKey(), str(
token)) token).encode('utf-8'))
self.portal.Base_setBearerToken(hmac, token) self.portal.Base_setBearerToken(hmac, token)
reference = self.getTokenCredential(self.portal.REQUEST) reference = self.getTokenCredential(self.portal.REQUEST)
self.assertEqual(reference, None) self.assertEqual(reference, None)
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