diff --git a/config_tempest/services/horizon.py b/config_tempest/services/horizon.py index 93f66ff8..e54f7fb1 100644 --- a/config_tempest/services/horizon.py +++ b/config_tempest/services/horizon.py @@ -13,8 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. + +from ssl import CertificateError + from six.moves import urllib +from config_tempest import constants as C + def configure_horizon(conf): """Derive the horizon URIs from the identity's URI.""" @@ -28,6 +33,11 @@ def configure_horizon(conf): urllib.request.urlopen(base) except urllib.error.URLError: has_horizon = False + except CertificateError as ex: + C.LOG.info('Certificate Error while discovering Horizon: %s', (ex)) + has_horizon = False + conf.set('service_available', 'horizon', str(has_horizon)) - conf.set('dashboard', 'dashboard_url', base + '/') - conf.set('dashboard', 'login_url', base + '/auth/login/') + if has_horizon: + conf.set('dashboard', 'dashboard_url', base + '/') + conf.set('dashboard', 'login_url', base + '/auth/login/') diff --git a/config_tempest/tests/services/test_horizon.py b/config_tempest/tests/services/test_horizon.py index 33e847ac..e5ba40bd 100644 --- a/config_tempest/tests/services/test_horizon.py +++ b/config_tempest/tests/services/test_horizon.py @@ -13,6 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +from ssl import CertificateError + from fixtures import MonkeyPatch import mock @@ -48,3 +50,13 @@ class TestConfigTempest(BaseConfigTempestTest): "http://[::1]/dashboard/") self.assertEqual(self.conf.get('dashboard', 'login_url'), "http://[::1]/dashboard/auth/login/") + + def test_configure_horizon_certificate_error(self): + mock_function = mock.Mock(return_value=True) + mock_function.side_effect = CertificateError + self.useFixture(MonkeyPatch('six.moves.urllib.request.urlopen', + mock_function)) + horizon.configure_horizon(self.conf) + self.assertEqual(self.conf.get('service_available', 'horizon'), + "False") + self.assertFalse(self.conf.has_section('dashboard'))