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
This commit is contained in:
Lance Bragstad 2017-06-13 15:42:11 +00:00
parent a83257f756
commit b272068e52
2 changed files with 9 additions and 10 deletions

View File

@ -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(

View File

@ -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'