summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-10-28 11:39:32 +0000
committerGerrit Code Review <review@openstack.org>2018-10-28 11:39:32 +0000
commit536a8701ed21fa5ac77ea649ee911646d94a9046 (patch)
tree5e8269638672c404932a7d85323464602626e3c4
parent55b61427911a84ebac27604e0ca50ded8eae60f9 (diff)
parent6779838a242b222672721407cc320672ab24067a (diff)
Merge "Skip the services with no endpoints when parsing service catalog"
-rw-r--r--keystonemiddleware/audit/_api.py5
-rw-r--r--keystonemiddleware/tests/unit/audit/test_audit_api.py17
-rw-r--r--releasenotes/notes/bug-1800017-0e5a9b8f62b5ca60.yaml7
3 files changed, 29 insertions, 0 deletions
diff --git a/keystonemiddleware/audit/_api.py b/keystonemiddleware/audit/_api.py
index d05d732..e692151 100644
--- a/keystonemiddleware/audit/_api.py
+++ b/keystonemiddleware/audit/_api.py
@@ -261,6 +261,11 @@ class OpenStackAuditApi(object):
261 261
262 default_endpoint = None 262 default_endpoint = None
263 for endp in catalog: 263 for endp in catalog:
264 if not endp['endpoints']:
265 self._log.warning(
266 'Skipping service %s as it have no endpoints.',
267 endp['name'])
268 continue
264 endpoint_urls = endp['endpoints'][0] 269 endpoint_urls = endp['endpoints'][0]
265 admin_urlparse = urlparse.urlparse( 270 admin_urlparse = urlparse.urlparse(
266 endpoint_urls.get('adminURL', '')) 271 endpoint_urls.get('adminURL', ''))
diff --git a/keystonemiddleware/tests/unit/audit/test_audit_api.py b/keystonemiddleware/tests/unit/audit/test_audit_api.py
index 367d7d0..1512e9d 100644
--- a/keystonemiddleware/tests/unit/audit/test_audit_api.py
+++ b/keystonemiddleware/tests/unit/audit/test_audit_api.py
@@ -303,6 +303,23 @@ class AuditApiLogicTest(base.BaseAuditMiddlewareTest):
303 payload = self.get_payload('GET', url, environ=env_headers) 303 payload = self.get_payload('GET', url, environ=env_headers)
304 self.assertEqual((payload['target']['addresses'][0]['url']), "unknown") 304 self.assertEqual((payload['target']['addresses'][0]['url']), "unknown")
305 305
306 def test_service_with_no_endpoints(self):
307 env_headers = {'HTTP_X_SERVICE_CATALOG':
308 '''[{"endpoints_links": [],
309 "endpoints": [],
310 "type": "foo",
311 "name": "bar"}]''',
312 'HTTP_X_USER_ID': 'user_id',
313 'HTTP_X_USER_NAME': 'user_name',
314 'HTTP_X_AUTH_TOKEN': 'token',
315 'HTTP_X_PROJECT_ID': 'tenant_id',
316 'HTTP_X_IDENTITY_STATUS': 'Confirmed',
317 'REQUEST_METHOD': 'GET'}
318
319 url = 'http://public_host:8774/v2/' + str(uuid.uuid4()) + '/servers'
320 payload = self.get_payload('GET', url, environ=env_headers)
321 self.assertEqual(payload['target']['name'], "unknown")
322
306 def test_no_auth_token(self): 323 def test_no_auth_token(self):
307 # Test cases where API requests such as Swift list public containers 324 # Test cases where API requests such as Swift list public containers
308 # which does not require an auth token. In these cases, CADF event 325 # which does not require an auth token. In these cases, CADF event
diff --git a/releasenotes/notes/bug-1800017-0e5a9b8f62b5ca60.yaml b/releasenotes/notes/bug-1800017-0e5a9b8f62b5ca60.yaml
new file mode 100644
index 0000000..0b1c75f
--- /dev/null
+++ b/releasenotes/notes/bug-1800017-0e5a9b8f62b5ca60.yaml
@@ -0,0 +1,7 @@
1---
2fixes:
3 - |
4 [`bug 1800017 <https://bugs.launchpad.net/keystonemiddleware/+bug/1800017>`_]
5 Fix audit middleware service catalog parsing for the scenario where a
6 service does not contain any endpoints. In that case, we should just skip
7 over that service.