Merge "Add encoding to keys in compute_signature"
This commit is contained in:
commit
2a6b0bfde5
@ -48,7 +48,7 @@ def compute_signature(message, secret):
|
||||
# Skip any existing signature value, which would not have
|
||||
# been part of the original message.
|
||||
continue
|
||||
digest_maker.update(name)
|
||||
digest_maker.update(six.text_type(name).encode('utf-8'))
|
||||
digest_maker.update(six.text_type(value).encode('utf-8'))
|
||||
return digest_maker.hexdigest()
|
||||
|
||||
|
@ -111,6 +111,16 @@ class TestSignature(base.BaseTestCase):
|
||||
jsondata = jsonutils.loads(jsonutils.dumps(data))
|
||||
self.assertTrue(utils.verify_signature(jsondata, 'not-so-secret'))
|
||||
|
||||
def test_verify_unicode_symbols(self):
|
||||
data = {u'a\xe9\u0437': 'A',
|
||||
'b': u'B\xe9\u0437'
|
||||
}
|
||||
data['message_signature'] = utils.compute_signature(
|
||||
data,
|
||||
'not-so-secret')
|
||||
jsondata = jsonutils.loads(jsonutils.dumps(data))
|
||||
self.assertTrue(utils.verify_signature(jsondata, 'not-so-secret'))
|
||||
|
||||
def test_besteffort_compare_digest(self):
|
||||
hash1 = "f5ac3fe42b80b80f979825d177191bc5"
|
||||
hash2 = "f5ac3fe42b80b80f979825d177191bc5"
|
||||
|
Loading…
Reference in New Issue
Block a user