]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: disable saml2 tests when the dep is not there
authorNizamudeen A <nia@redhat.com>
Wed, 12 Mar 2025 08:32:10 +0000 (14:02 +0530)
committerNizamudeen A <nia@redhat.com>
Tue, 22 Jul 2025 03:44:58 +0000 (09:14 +0530)
Signed-off-by: Nizamudeen A <nia@redhat.com>
(cherry picked from commit 8acf8f7e4fe6d283212154857abd97b6e641de4d)
(cherry picked from commit 740df4666545c1e358757beeceba4bfbeed76e7c)

 Conflicts:
src/pybind/mgr/dashboard/controllers/saml2.py
 - kept the config options as it is in reef
src/pybind/mgr/dashboard/tox.ini
 - kept the file as is in reef

debian/control
src/pybind/mgr/dashboard/controllers/saml2.py
src/pybind/mgr/dashboard/tests/test_sso.py
src/pybind/mgr/dashboard/tox.ini

index ddba52be7bb00bdf1ad95887406208366d530176..e857269818f0d802be13f2d7635a4a964257dae6 100644 (file)
@@ -100,6 +100,7 @@ Build-Depends: automake,
                python3-prettytable <pkg.ceph.check>,
                python3-requests <pkg.ceph.check>,
                python3-scipy <pkg.ceph.check>,
+               python3-onelogin-saml2 <pkg.ceph.check>,
                python3-setuptools,
                python3-sphinx,
                python3-venv,
index c11b18a27bc7e7e41caf8272ebd13fa0889c3bd6..587b8af7632622d5e1bbcb7faa5c7aaa97d4e28f 100644 (file)
@@ -32,19 +32,10 @@ class Saml2(BaseController, ControllerAuthMixin):
             'post_data': post_data
         }
 
-    @staticmethod
-    def _check_python_saml():
-        if not python_saml_imported:
-            raise cherrypy.HTTPError(400, 'Required library not found: `python3-saml`')
-        try:
-            OneLogin_Saml2_Settings(mgr.SSO_DB.saml2.onelogin_settings)
-        except OneLogin_Saml2_Error:
-            raise cherrypy.HTTPError(400, 'Single Sign-On is not configured.')
-
     @Endpoint('POST', path="", version=None)
     @allow_empty_body
     def auth_response(self, **kwargs):
-        Saml2._check_python_saml()
+        check_python_saml()
         req = Saml2._build_req(self._request, kwargs)
         auth = OneLogin_Saml2_Auth(req, mgr.SSO_DB.saml2.onelogin_settings)
         auth.process_response()
@@ -84,20 +75,20 @@ class Saml2(BaseController, ControllerAuthMixin):
 
     @Endpoint(xml=True, version=None)
     def metadata(self):
-        Saml2._check_python_saml()
+        check_python_saml()
         saml_settings = OneLogin_Saml2_Settings(mgr.SSO_DB.saml2.onelogin_settings)
         return saml_settings.get_sp_metadata()
 
     @Endpoint(json_response=False, version=None)
     def login(self):
-        Saml2._check_python_saml()
+        check_python_saml()
         req = Saml2._build_req(self._request, {})
         auth = OneLogin_Saml2_Auth(req, mgr.SSO_DB.saml2.onelogin_settings)
         raise cherrypy.HTTPRedirect(auth.login())
 
     @Endpoint(json_response=False, version=None)
     def slo(self):
-        Saml2._check_python_saml()
+        check_python_saml()
         req = Saml2._build_req(self._request, {})
         auth = OneLogin_Saml2_Auth(req, mgr.SSO_DB.saml2.onelogin_settings)
         raise cherrypy.HTTPRedirect(auth.logout())
@@ -105,9 +96,18 @@ class Saml2(BaseController, ControllerAuthMixin):
     @Endpoint(json_response=False, version=None)
     def logout(self, **kwargs):
         # pylint: disable=unused-argument
-        Saml2._check_python_saml()
+        check_python_saml()
         JwtManager.reset_user()
         token = JwtManager.get_token_from_header()
         self._delete_token_cookie(token)
         url_prefix = prepare_url_prefix(mgr.get_module_option('url_prefix', default=''))
         raise cherrypy.HTTPRedirect("{}/#/login".format(url_prefix))
+
+
+def check_python_saml():
+    if not python_saml_imported:
+        raise cherrypy.HTTPError(400, 'Required library not found: `python3-saml`')
+    try:
+        OneLogin_Saml2_Settings(mgr.SSO_DB.saml2.onelogin_settings)
+    except OneLogin_Saml2_Error:
+        raise cherrypy.HTTPError(400, 'Single Sign-On is not configured.')
index e077dde19e18a65cb7a541c71aace5f81fefefef..b60e5e70fc7a138a76aa9a8e247a9d8906ff8fe7 100644 (file)
@@ -5,10 +5,17 @@ import errno
 import tempfile
 import unittest
 
+import pytest
+
+from ..controllers.saml2 import check_python_saml
 from ..services.sso import load_sso_db
 from ..tests import CLICommandTestMixin, CmdException
 
 
+@pytest.mark.skipif(
+    pytest.raises(Exception, check_python_saml),
+    reason="SAML dependency is missing"
+)
 class AccessControlTest(unittest.TestCase, CLICommandTestMixin):
     IDP_METADATA = '''<?xml version="1.0"?>
 <md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
index 5dca7e2c20bd35e0359cdc5af721659d1b16638f..da2664e26d690424872c489d1eac2dfcfee22985 100644 (file)
@@ -34,7 +34,6 @@ basepython=python3
 deps =
     {[base]deps}
     {[base-test]deps}
-    -rrequirements-extra.txt
 passenv =
     PYTHONPATH
 sitepackages = true