Merge "Skip the services with no endpoints when parsing service catalog"
This commit is contained in:
commit
536a8701ed
|
@ -261,6 +261,11 @@ class OpenStackAuditApi(object):
|
||||||
|
|
||||||
default_endpoint = None
|
default_endpoint = None
|
||||||
for endp in catalog:
|
for endp in catalog:
|
||||||
|
if not endp['endpoints']:
|
||||||
|
self._log.warning(
|
||||||
|
'Skipping service %s as it have no endpoints.',
|
||||||
|
endp['name'])
|
||||||
|
continue
|
||||||
endpoint_urls = endp['endpoints'][0]
|
endpoint_urls = endp['endpoints'][0]
|
||||||
admin_urlparse = urlparse.urlparse(
|
admin_urlparse = urlparse.urlparse(
|
||||||
endpoint_urls.get('adminURL', ''))
|
endpoint_urls.get('adminURL', ''))
|
||||||
|
|
|
@ -303,6 +303,23 @@ class AuditApiLogicTest(base.BaseAuditMiddlewareTest):
|
||||||
payload = self.get_payload('GET', url, environ=env_headers)
|
payload = self.get_payload('GET', url, environ=env_headers)
|
||||||
self.assertEqual((payload['target']['addresses'][0]['url']), "unknown")
|
self.assertEqual((payload['target']['addresses'][0]['url']), "unknown")
|
||||||
|
|
||||||
|
def test_service_with_no_endpoints(self):
|
||||||
|
env_headers = {'HTTP_X_SERVICE_CATALOG':
|
||||||
|
'''[{"endpoints_links": [],
|
||||||
|
"endpoints": [],
|
||||||
|
"type": "foo",
|
||||||
|
"name": "bar"}]''',
|
||||||
|
'HTTP_X_USER_ID': 'user_id',
|
||||||
|
'HTTP_X_USER_NAME': 'user_name',
|
||||||
|
'HTTP_X_AUTH_TOKEN': 'token',
|
||||||
|
'HTTP_X_PROJECT_ID': 'tenant_id',
|
||||||
|
'HTTP_X_IDENTITY_STATUS': 'Confirmed',
|
||||||
|
'REQUEST_METHOD': 'GET'}
|
||||||
|
|
||||||
|
url = 'http://public_host:8774/v2/' + str(uuid.uuid4()) + '/servers'
|
||||||
|
payload = self.get_payload('GET', url, environ=env_headers)
|
||||||
|
self.assertEqual(payload['target']['name'], "unknown")
|
||||||
|
|
||||||
def test_no_auth_token(self):
|
def test_no_auth_token(self):
|
||||||
# Test cases where API requests such as Swift list public containers
|
# Test cases where API requests such as Swift list public containers
|
||||||
# which does not require an auth token. In these cases, CADF event
|
# which does not require an auth token. In these cases, CADF event
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
[`bug 1800017 <https://bugs.launchpad.net/keystonemiddleware/+bug/1800017>`_]
|
||||||
|
Fix audit middleware service catalog parsing for the scenario where a
|
||||||
|
service does not contain any endpoints. In that case, we should just skip
|
||||||
|
over that service.
|
Loading…
Reference in New Issue