From b272068e52489ec2aea53be87637aea8510afe7b Mon Sep 17 00:00:00 2001 From: Lance Bragstad Date: Tue, 13 Jun 2017 15:42:11 +0000 Subject: [PATCH] Ensure the endpoint policy API supports HEAD This commit makes it so all endpoint policy GET APIs also support HEAD. Change-Id: Ib8eada4847506cc41eeb1e323752473608c38df5 Partial-Bug: 1696574 --- keystone/endpoint_policy/routers.py | 2 +- keystone/tests/unit/test_v3_endpoint_policy.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/keystone/endpoint_policy/routers.py b/keystone/endpoint_policy/routers.py index 4846bb1807..a3a9e2556a 100644 --- a/keystone/endpoint_policy/routers.py +++ b/keystone/endpoint_policy/routers.py @@ -40,7 +40,7 @@ class Routers(wsgi.RoutersBase): self._add_resource( mapper, endpoint_policy_controller, path='/policies/{policy_id}' + self.PATH_PREFIX + '/endpoints', - get_action='list_endpoints_for_policy', + get_head_action='list_endpoints_for_policy', rel=build_resource_relation(resource_name='policy_endpoints'), path_vars={'policy_id': json_home.Parameters.POLICY_ID}) self._add_resource( diff --git a/keystone/tests/unit/test_v3_endpoint_policy.py b/keystone/tests/unit/test_v3_endpoint_policy.py index f5b45fb60b..785db8d50f 100644 --- a/keystone/tests/unit/test_v3_endpoint_policy.py +++ b/keystone/tests/unit/test_v3_endpoint_policy.py @@ -113,17 +113,16 @@ class EndpointPolicyTestCase(test_v3.RestfulTestCase): self.assertValidPolicyResponse(r, ref=self.policy) def test_list_endpoints_for_policy(self): - """GET /policies/%(policy_id}/endpoints.""" - self.put('/policies/%(policy_id)s/OS-ENDPOINT-POLICY' - '/endpoints/%(endpoint_id)s' % { - 'policy_id': self.policy['id'], - 'endpoint_id': self.endpoint['id']}) - - r = self.get('/policies/%(policy_id)s/OS-ENDPOINT-POLICY' - '/endpoints' % { - 'policy_id': self.policy['id']}) + """GET & HEAD /policies/%(policy_id}/endpoints.""" + url = ( + '/policies/%(policy_id)s/OS-ENDPOINT-POLICY' + '/endpoints' % {'policy_id': self.policy['id']} + ) + self.put(url + '/' + self.endpoint['id']) + r = self.get(url) self.assertValidEndpointListResponse(r, ref=self.endpoint) self.assertThat(r.result.get('endpoints'), matchers.HasLength(1)) + self.head(url, expected_status=http_client.OK) def test_endpoint_association_cleanup_when_endpoint_deleted(self): url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY'