Merge "do parameter check before updating endpoint_group" into stable/juno

This commit is contained in:
Jenkins 2015-04-01 21:44:09 +00:00 committed by Gerrit Code Review
commit 14cb676dee
2 changed files with 12 additions and 1 deletions

View File

@ -180,9 +180,10 @@ class EndpointGroupV3Controller(_ControllerBase):
def update_endpoint_group(self, context, endpoint_group_id,
endpoint_group):
"""Update fixed values and/or extend the filters."""
if 'filters' in endpoint_group:
self._require_valid_filter(endpoint_group)
ref = self.endpoint_filter_api.update_endpoint_group(endpoint_group_id,
endpoint_group)
self._require_valid_filter(ref)
return EndpointGroupV3Controller.wrap_member(
context, ref)

View File

@ -753,6 +753,16 @@ class EndpointGroupCRUDTestCase(TestExtensionCase):
'endpoint_group_id': endpoint_group_id}
r = self.patch(url, body=body, expected_status=400)
# Perform a GET call to ensure that the content remains
# the same (as DEFAULT_ENDPOINT_GROUP_BODY) after attempting to update
# with an invalid filter
url = '/OS-EP-FILTER/endpoint_groups/%(endpoint_group_id)s' % {
'endpoint_group_id': endpoint_group_id}
r = self.get(url)
del r.result['endpoint_group']['id']
del r.result['endpoint_group']['links']
self.assertDictEqual(self.DEFAULT_ENDPOINT_GROUP_BODY, r.result)
def test_delete_endpoint_group(self):
"""GET /OS-EP-FILTER/endpoint_groups/{endpoint_group}