Stop trying to use identity URI if dashboard URL exists

At the moment, if dashboard_url is overridden, we still try to
make a request to introspect based-off the identity URI which
isn't correct behaviour.

This patch short-circuits this entire behaviour if there's a
dashboard_url provided.

Change-Id: Ifeaec3337e5155ad1f5adeca85fce00b611a631d
This commit is contained in:
Mohammed Naser 2021-04-16 21:22:45 -04:00
parent 33b2a939b5
commit d4c30061e5
2 changed files with 20 additions and 5 deletions

View File

@ -22,7 +22,10 @@ from config_tempest import constants as C
def configure_horizon(conf, **kwargs):
"""Derive the horizon URIs from the identity's URI."""
"""Verify horizon is working (fallback to introspect from identity URI)"""
if conf.has_option("dashboard", "dashboard_url"):
base = conf.get("dashboard", "dashboard_url")
else:
uri = conf.get('identity', 'uri')
u = urllib.parse.urlparse(uri)
base = '%s://%s%s' % (u.scheme, u.netloc.replace(

View File

@ -28,6 +28,18 @@ class TestConfigTempest(BaseConfigTempestTest):
super(TestConfigTempest, self).setUp()
self.conf = self._get_conf("v2.0", "v3")
def test_configure_horizon_overridden(self):
mock_function = mock.Mock(return_value=True)
self.useFixture(MonkeyPatch('six.moves.urllib.request.urlopen',
mock_function))
self.conf.set("dashboard", "dashboard_url", "http://172.16.52.151")
horizon.configure_horizon(self.conf)
self.assertEqual(self.conf.get('service_available', 'horizon'), "True")
self.assertEqual(self.conf.get('dashboard', 'dashboard_url'),
"http://172.16.52.151/")
self.assertEqual(self.conf.get('dashboard', 'login_url'),
"http://172.16.52.151/auth/login/")
def test_configure_horizon_ipv4(self):
mock_function = mock.Mock(return_value=True)
self.useFixture(MonkeyPatch('six.moves.urllib.request.urlopen',