Browse Source

Merge "Skip the services with no endpoints when parsing service catalog"

Zuul 5 months ago
parent
commit
536a8701ed

+ 5
- 0
keystonemiddleware/audit/_api.py View File

@@ -261,6 +261,11 @@ class OpenStackAuditApi(object):
261 261
 
262 262
         default_endpoint = None
263 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 269
             endpoint_urls = endp['endpoints'][0]
265 270
             admin_urlparse = urlparse.urlparse(
266 271
                 endpoint_urls.get('adminURL', ''))

+ 17
- 0
keystonemiddleware/tests/unit/audit/test_audit_api.py View File

@@ -303,6 +303,23 @@ class AuditApiLogicTest(base.BaseAuditMiddlewareTest):
303 303
         payload = self.get_payload('GET', url, environ=env_headers)
304 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 323
     def test_no_auth_token(self):
307 324
         # Test cases where API requests such as Swift list public containers
308 325
         # which does not require an auth token. In these cases, CADF event

+ 7
- 0
releasenotes/notes/bug-1800017-0e5a9b8f62b5ca60.yaml View File

@@ -0,0 +1,7 @@
1
+---
2
+fixes:
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.

Loading…
Cancel
Save