From 61f9d66fc781ba6a2ceca3227fbfbd20082fa7d6 Mon Sep 17 00:00:00 2001 From: Martin Kopec Date: Wed, 18 Jul 2018 13:09:59 +0000 Subject: [PATCH] Fix identity URL parsing The identity URLs have a different rules for parsing, but the code before looked for word 'identity' in whole given URL to determine it was an identity URL. This can conflict with a URL hostname which can contain 'identity' too. The patch fixes that by looking for 'identity' only in URL.path (after hostname:port part). The patch also adds a new unit test for this case. Change-Id: I265f4d38d81dc74b05f2af9adb6fe33db876329c Story: 2002965 Task: 22970 --- config_tempest/services/services.py | 3 +-- config_tempest/tests/services/test_services.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/config_tempest/services/services.py b/config_tempest/services/services.py index 1a2ec521..c93b5d72 100644 --- a/config_tempest/services/services.py +++ b/config_tempest/services/services.py @@ -136,7 +136,7 @@ class Services(object): C.LOG.info("Service %s has no endpoints", name) else: url = ep[self.public_url] - if 'identity' in url: + if 'identity' in urllib.parse.urlparse(url).path: url = self.edit_identity_url(ep[self.public_url]) return url @@ -147,7 +147,6 @@ class Services(object): :type url: string :rtype: string """ - # self._clients.auth_provider.auth_url stores identity.uri(_v3) value # from TempestConf port = urllib.parse.urlparse(self._clients.auth_provider.auth_url).port diff --git a/config_tempest/tests/services/test_services.py b/config_tempest/tests/services/test_services.py index f01b4c84..f0b2b22b 100644 --- a/config_tempest/tests/services/test_services.py +++ b/config_tempest/tests/services/test_services.py @@ -106,6 +106,19 @@ class TestServices(BaseConfigTempestTest): url = services.parse_endpoints(ep, 'ServiceName') self.assertEqual('https://10.0.0.101:13000/identity/v2', url) + def test_parse_endpoints_not_ip_hostname(self): + services = self._create_services_instance() + services.public_url = "url" + url = "https://identity-my.cloud.com:35456/v2.0" + ep = { + 'url': url, + 'interface': 'public', + 'region': 'regioneOne', + } + services._clients.auth_provider.auth_url = "35456" + url_resp = services.parse_endpoints(ep, "ServiceName") + self.assertEqual(url, url_resp) + def test_edit_identity_url(self): services = self._create_services_instance() url_port = 'https://10.0.0.101:13000/v2.0'