Handling of 'region' parameter as None

In V2 Endpoint creation it returns 500 error due to missing
'region'. So, changed the way of fetching the same parameter to handle
None case.

Change-Id: I5c9ef206193072da73d3990d5f77003124db8265
Closes-Bug: #1557166
This commit is contained in:
Kanika Singh 2016-04-12 15:18:30 +05:30 committed by Morgan Fainberg
parent 8d2aacdb1e
commit 3039e6c4bc
2 changed files with 13 additions and 3 deletions

View File

@ -177,7 +177,7 @@ class Endpoint(controller.V2Controller):
endpoint_ref['legacy_endpoint_id'] = legacy_endpoint_id
endpoint_ref['interface'] = interface
endpoint_ref['url'] = url
endpoint_ref['region_id'] = endpoint_ref.pop('region')
endpoint_ref['region_id'] = endpoint_ref.pop('region', None)
self.catalog_api.create_endpoint(endpoint_ref['id'],
endpoint_ref,
initiator=request.audit_initiator)

View File

@ -54,7 +54,8 @@ class V2CatalogTestCase(rest.RestfulTestCase):
service_id=SERVICE_FIXTURE,
publicurl='http://localhost:8080',
internalurl='http://localhost:8080',
adminurl='http://localhost:8080'):
adminurl='http://localhost:8080',
region='RegionOne'):
if service_id is SERVICE_FIXTURE:
service_id = self.service_id
@ -63,11 +64,12 @@ class V2CatalogTestCase(rest.RestfulTestCase):
'endpoint': {
'adminurl': adminurl,
'service_id': service_id,
'region': 'RegionOne',
'internalurl': internalurl,
'publicurl': publicurl
}
}
if region is not None:
body['endpoint']['region'] = region
r = self.admin_request(method='POST', token=self.get_scoped_token(),
path=path, expected_status=expected_status,
@ -87,6 +89,14 @@ class V2CatalogTestCase(rest.RestfulTestCase):
for field, value in req_body['endpoint'].items():
self.assertEqual(value, response.result['endpoint'][field])
def test_endpoint_create_without_region(self):
req_body, response = self._endpoint_create(region=None)
self.assertIn('endpoint', response.result)
self.assertIn('id', response.result['endpoint'])
self.assertNotIn('region', response.result['endpoint'])
for field, value in req_body['endpoint'].items():
self.assertEqual(value, response.result['endpoint'][field])
def test_pure_v3_endpoint_with_publicurl_visible_from_v2(self):
"""Test pure v3 endpoint can be fetched via v2.0 API.