From 124d16acbb27efdb76f8302c14d4fc257e548f92 Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Mon, 4 Apr 2022 15:49:34 -0300 Subject: [PATCH] Add test for ceph-dashboard SAML functionality --- .../charm_tests/ceph/dashboard/tests.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/zaza/openstack/charm_tests/ceph/dashboard/tests.py b/zaza/openstack/charm_tests/ceph/dashboard/tests.py index 5b88c42..06fc4a5 100644 --- a/zaza/openstack/charm_tests/ceph/dashboard/tests.py +++ b/zaza/openstack/charm_tests/ceph/dashboard/tests.py @@ -18,6 +18,7 @@ import collections import json import logging import requests +import tempfile import tenacity import uuid @@ -26,6 +27,17 @@ import zaza.openstack.charm_tests.test_utils as test_utils import zaza.openstack.utilities.openstack as openstack_utils +SAML_IDP_METADATA = ''' + + + + {} + + + +''' + + class CephDashboardTest(test_utils.BaseCharmTest): """Class for `ceph-dashboard` tests.""" @@ -211,3 +223,23 @@ class CephDashboardTest(test_utils.BaseCharmTest): 'ceph-dashboard', 'ceph config-key exists {}'.format(key)) self.assertEqual(check_out['Code'], '0') + + def test_saml(self): + """Check that the dashboard is accessible with SAML enabled.""" + if (openstack_utils.get_os_release() < + openstack_utils.get_os_release('focal_yoga')): + return + + url = self.get_master_dashboard_url() + with tempfile.NamedTemporaryFile(mode='w') as tmp, \ + open(self.local_ca_cert) as cert: + tmp.write(SAML_IDP_METADATA.format(cert.read())) + tmp.flush() + zaza.model.set_application_config( + 'ceph-dashboard', + { + 'saml-base-url': url, + 'saml-idp-metadata': 'file://{}'.format(tmp.name), + } + ) + self.access_dashboard(url)