From: Steve Baker Date: Thu, 18 Jul 2013 21:48:40 +0000 (+1200) Subject: Set tenant headers from ec2 authentication. X-Git-Tag: 2014.1~348^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c8af819c7fc55c98c4b4871a44fa8b4d4964668e;p=openstack-build%2Fheat-build.git Set tenant headers from ec2 authentication. Without this, ec2token middleware on its own doesn't set enough headers to perform heat requests. Change-Id: I7a0867196741c0df222d491fb1bfbe203158032c --- diff --git a/heat/api/aws/ec2token.py b/heat/api/aws/ec2token.py index 4ad18507..cf125803 100644 --- a/heat/api/aws/ec2token.py +++ b/heat/api/aws/ec2token.py @@ -159,6 +159,8 @@ class EC2Token(wsgi.Middleware): result = json.loads(response) try: token_id = result['access']['token']['id'] + tenant = result['access']['token']['tenant']['name'] + tenant_id = result['access']['token']['tenant']['id'] logger.info("AWS authentication successful.") except (AttributeError, KeyError): logger.info("AWS authentication failure.") @@ -181,6 +183,8 @@ class EC2Token(wsgi.Middleware): 'signature': signature}} req.headers['X-Auth-EC2-Creds'] = json.dumps(ec2_creds) req.headers['X-Auth-Token'] = token_id + req.headers['X-Tenant-Name'] = tenant + req.headers['X-Tenant-Id'] = tenant_id req.headers['X-Auth-URL'] = self._conf_get('auth_uri') req.headers['X-Auth-EC2_URL'] = keystone_ec2_uri return self.application diff --git a/heat/tests/test_api_ec2token.py b/heat/tests/test_api_ec2token.py index c73b7149..955babdb 100644 --- a/heat/tests/test_api_ec2token.py +++ b/heat/tests/test_api_ec2token.py @@ -221,7 +221,9 @@ class Ec2TokenTest(HeatTestCase): 'HTTP_AUTHORIZATION': auth_str} dummy_req = self._dummy_GET_request(environ=req_env) - ok_resp = json.dumps({'access': {'token': {'id': 123}}}) + ok_resp = json.dumps({'access': {'token': { + 'id': 123, + 'tenant': {'name': 'tenant', 'id': 'abcd1234'}}}}) self._stub_http_connection(headers={'Authorization': auth_str}, response=ok_resp) self.m.ReplayAll() @@ -310,7 +312,9 @@ class Ec2TokenTest(HeatTestCase): 'PATH_INFO': '/v1'} dummy_req = self._dummy_GET_request(params, req_env) - ok_resp = json.dumps({'access': {'token': {'id': 123}}}) + ok_resp = json.dumps({'access': {'token': { + 'id': 123, + 'tenant': {'name': 'tenant', 'id': 'abcd1234'}}}}) self._stub_http_connection(response=ok_resp, params={'AWSAccessKeyId': 'foo'}) self.m.ReplayAll()