diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-11-27 18:37:47 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-11-27 18:37:47 +0000 |
commit | eeb15df1ced108a486e61483c123ceb4c7c9e80d (patch) | |
tree | 13a67ac840ad4d84d1663a344031eeab343ba3e0 | |
parent | d3bcd1442c816df5b09adee781892a8a5370cba4 (diff) | |
parent | ca52652e5a14f2332bd91b0c5a57e98af872c8db (diff) | |
download | ceilometer-eeb15df1ced108a486e61483c123ceb4c7c9e80d.tar.gz |
Merge "Add encoding to keys in compute_signature" into stable/juno
-rw-r--r-- | ceilometer/publisher/utils.py | 2 | ||||
-rw-r--r-- | ceilometer/tests/publisher/test_utils.py | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/ceilometer/publisher/utils.py b/ceilometer/publisher/utils.py index 0a8e89cd..2974276b 100644 --- a/ceilometer/publisher/utils.py +++ b/ceilometer/publisher/utils.py @@ -55,7 +55,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() diff --git a/ceilometer/tests/publisher/test_utils.py b/ceilometer/tests/publisher/test_utils.py index 479fc5c9..b4b1b67d 100644 --- a/ceilometer/tests/publisher/test_utils.py +++ b/ceilometer/tests/publisher/test_utils.py @@ -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" |