Merge "Python 3: hmac requires bytes key/msg"

This commit is contained in:
Jenkins 2015-08-21 03:48:46 +00:00 committed by Gerrit Code Review
commit 40576ae09c
2 changed files with 7 additions and 3 deletions

View File

@ -269,9 +269,12 @@ class MetadataProxyHandler(object):
raise Exception(_('Unexpected response code: %s') % resp.status)
def _sign_instance_id(self, instance_id):
return hmac.new(self.conf.metadata_proxy_shared_secret,
instance_id,
hashlib.sha256).hexdigest()
secret = self.conf.metadata_proxy_shared_secret
if isinstance(secret, six.text_type):
secret = secret.encode('utf-8')
if isinstance(instance_id, six.text_type):
instance_id = instance_id.encode('utf-8')
return hmac.new(secret, instance_id, hashlib.sha256).hexdigest()
class UnixDomainMetadataProxy(object):

View File

@ -179,6 +179,7 @@ commands = python -m testtools.run \
neutron.tests.unit.api.rpc.handlers.test_dvr_rpc \
neutron.tests.unit.api.rpc.agentnotifiers.test_dhcp_rpc_agent_api \
neutron.tests.unit.api.v2.test_attributes \
neutron.tests.unit.agent.metadata.test_agent \
neutron.tests.unit.agent.metadata.test_driver \
neutron.tests.unit.agent.metadata.test_namespace_proxy \
neutron.tests.unit.agent.test_rpc \