From: Monty Taylor Date: Sat, 5 Dec 2015 04:54:22 +0000 (-0500) Subject: Pull project out of request in addition to tenant X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=9670dbd93ce7246282ca4343c3f701e8c20a232b;p=openstack-build%2Fneutron-build.git Pull project out of request in addition to tenant Keystone V3 renamed tenant to project. In order to deal with keystone V3, start pulling X-Project-Id from the headers. Since keystonemiddleware authtoken sets both X-Project-* and X-Tenant-*, we don't need to look up X-Tenant-*. Don't do anything with renaming the internal variables - that will come later. Change-Id: I5e27cf6a54fb603b81d41b8b4f085d59354627fb Depends-On: I1f754a9a949ef92f4e427a91bbd1b1e73e86c8c4 Closes-Bug: #1503428 --- diff --git a/neutron/pecan_wsgi/hooks/context.py b/neutron/pecan_wsgi/hooks/context.py index 5aaa2e846..7c3f9a339 100644 --- a/neutron/pecan_wsgi/hooks/context.py +++ b/neutron/pecan_wsgi/hooks/context.py @@ -24,8 +24,10 @@ class ContextHook(hooks.PecanHook): The following HTTP request headers are used: X-User-Id or X-User: Used for context.user_id. - X-Tenant-Id or X-Tenant: - Used for context.tenant. + X-Project-Id: + Used for context.tenant_id. + X-Project-Name: + Used for context.tenant_name. X-Auth-Token: Used for context.auth_token. X-Roles: @@ -40,8 +42,8 @@ class ContextHook(hooks.PecanHook): user_id = state.request.headers.get('X-User-Id') user_id = state.request.headers.get('X-User', user_id) user_name = state.request.headers.get('X-User-Name', '') - tenant_id = state.request.headers.get('X-Tenant-Id') - tenant_name = state.request.headers.get('X-Tenant-Name') + tenant_id = state.request.headers.get('X-Project-Id') + tenant_name = state.request.headers.get('X-Project-Name') auth_token = state.request.headers.get('X-Auth-Token') roles = state.request.headers.get('X-Roles', '').split(',') roles = [r.strip() for r in roles] diff --git a/neutron/tests/functional/pecan_wsgi/test_functional.py b/neutron/tests/functional/pecan_wsgi/test_functional.py index 1082df82a..96c420749 100644 --- a/neutron/tests/functional/pecan_wsgi/test_functional.py +++ b/neutron/tests/functional/pecan_wsgi/test_functional.py @@ -79,18 +79,18 @@ class TestV2Controller(PecanFunctionalTest): params={'port': {'network_id': self.port['network_id'], 'admin_state_up': True, 'tenant_id': 'tenid'}}, - headers={'X-Tenant-Id': 'tenid'}) + headers={'X-Project-Id': 'tenid'}) self.assertEqual(response.status_int, 201) def test_put(self): response = self.app.put_json('/v2.0/ports/%s.json' % self.port['id'], params={'port': {'name': 'test'}}, - headers={'X-Tenant-Id': 'tenid'}) + headers={'X-Project-Id': 'tenid'}) self.assertEqual(response.status_int, 200) def test_delete(self): response = self.app.delete('/v2.0/ports/%s.json' % self.port['id'], - headers={'X-Tenant-Id': 'tenid'}) + headers={'X-Project-Id': 'tenid'}) self.assertEqual(response.status_int, 204) def test_plugin_initialized(self): @@ -195,7 +195,7 @@ class TestRequestPopulatingHooks(PecanFunctionalTest): def test_context_set_in_request(self): self.app.get('/v2.0/ports.json', - headers={'X-Tenant-Id': 'tenant_id'}) + headers={'X-Project-Id': 'tenant_id'}) self.assertEqual('tenant_id', self.req_stash['context'].tenant_id) def test_core_resource_identified(self): @@ -222,7 +222,7 @@ class TestEnforcementHooks(PecanFunctionalTest): params={'port': {'network_id': self.port['network_id'], 'admin_state_up': True, 'tenant_id': 'tenid2'}}, - headers={'X-Tenant-Id': 'tenid'}) + headers={'X-Project-Id': 'tenid'}) self.assertEqual(response.status_int, 200) def test_quota_enforcement(self):