summaryrefslogtreecommitdiff
path: root/keystonemiddleware
diff options
context:
space:
mode:
authorGage Hugo <gagehugo@gmail.com>2019-08-24 12:48:41 -0500
committerGage Hugo <gagehugo@gmail.com>2019-12-20 14:37:43 -0600
commit7c33d8ebb67b0d85964a03660d6f34bbee8b7e58 (patch)
tree65c3d7905988eeba89d9560f467979dd4c2ccb63 /keystonemiddleware
parent7f006ec4096aa8b2ea1baefbdda908202071a959 (diff)
downloadkeystonemiddleware-7c33d8ebb67b0d85964a03660d6f34bbee8b7e58.tar.gz
Rename _v3_to_v2_catalog to _normalize_catalog8.0.0
This change renames the _v3_to_v2_catalog to _normalize_catalog as part of the v2 removal effort. Several services still rely on the converted catalog format, so this change maintains the conversion but removes the v2 association. Change-Id: Ic7bca16d8c6211d006fc2ba09dc2ecd83f8955db Partial-Bug: #1845539 Partial-Bug: #1777177
Diffstat (limited to 'keystonemiddleware')
-rw-r--r--keystonemiddleware/auth_token/_request.py24
-rw-r--r--keystonemiddleware/tests/unit/auth_token/test_request.py4
2 files changed, 12 insertions, 16 deletions
diff --git a/keystonemiddleware/auth_token/_request.py b/keystonemiddleware/auth_token/_request.py
index 269c3d3..cba28bf 100644
--- a/keystonemiddleware/auth_token/_request.py
+++ b/keystonemiddleware/auth_token/_request.py
@@ -16,20 +16,16 @@ from oslo_serialization import jsonutils
import webob
-def _v3_to_v2_catalog(catalog):
- """Convert a catalog to v2 format.
-
- X_SERVICE_CATALOG must be specified in v2 format. If you get a token
- that is in v3 convert it.
- """
- v2_services = []
+def _normalize_catalog(catalog):
+ """Convert a catalog to a compatible format."""
+ services = []
for v3_service in catalog:
# first copy over the entries we allow for the service
- v2_service = {'type': v3_service['type']}
+ service = {'type': v3_service['type']}
try:
- v2_service['name'] = v3_service['name']
+ service['name'] = v3_service['name']
except KeyError: # nosec
- # v3 service doesn't have a name, so v2_service doesn't either.
+ # v3 service doesn't have a name, move on.
pass
# now convert the endpoints. Because in v3 we specify region per
@@ -47,10 +43,10 @@ def _v3_to_v2_catalog(catalog):
interface_name = v3_endpoint['interface'].lower() + 'URL'
region[interface_name] = v3_endpoint['url']
- v2_service['endpoints'] = list(regions.values())
- v2_services.append(v2_service)
+ service['endpoints'] = list(regions.values())
+ services.append(service)
- return v2_services
+ return services
def _is_admin_project(auth_ref):
@@ -194,7 +190,7 @@ class _AuthTokenRequest(webob.Request):
catalog = auth_ref.service_catalog.catalog
if auth_ref.version == 'v3':
- catalog = _v3_to_v2_catalog(catalog)
+ catalog = _normalize_catalog(catalog)
c = jsonutils.dumps(catalog)
self.headers[self._SERVICE_CATALOG_HEADER] = c
diff --git a/keystonemiddleware/tests/unit/auth_token/test_request.py b/keystonemiddleware/tests/unit/auth_token/test_request.py
index bd8a7b3..011525f 100644
--- a/keystonemiddleware/tests/unit/auth_token/test_request.py
+++ b/keystonemiddleware/tests/unit/auth_token/test_request.py
@@ -224,7 +224,7 @@ class CatalogConversionTests(utils.TestCase):
auth_ref = access.create(body=token)
catalog_data = auth_ref.service_catalog.catalog
- catalog = _request._v3_to_v2_catalog(catalog_data)
+ catalog = _request._normalize_catalog(catalog_data)
self.assertEqual(1, len(catalog))
service = catalog[0]
@@ -248,7 +248,7 @@ class CatalogConversionTests(utils.TestCase):
auth_ref = access.create(body=token)
catalog_data = auth_ref.service_catalog.catalog
- catalog = _request._v3_to_v2_catalog(catalog_data)
+ catalog = _request._normalize_catalog(catalog_data)
self.assertEqual(1, len(catalog))
service = catalog[0]