summary refs log tree commit diff
path: root/tests/handlers/test_saml.py
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2020-12-09 12:23:30 -0500
committerGitHub <noreply@github.com>2020-12-09 12:23:30 -0500
commit6ff34e00d9bd4e8b0b91347a359b17abeaa22e5a (patch)
treef7faf3305a7736365f490560d1d5dc98101728c4 /tests/handlers/test_saml.py
parentCombine related media admin API docs (#8839) (diff)
downloadsynapse-6ff34e00d9bd4e8b0b91347a359b17abeaa22e5a.tar.xz
Skip the SAML tests if xmlsec1 isn't available. (#8905)
Diffstat (limited to 'tests/handlers/test_saml.py')
-rw-r--r--tests/handlers/test_saml.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/handlers/test_saml.py b/tests/handlers/test_saml.py
index 45dc17aba5..d21e5588ca 100644
--- a/tests/handlers/test_saml.py
+++ b/tests/handlers/test_saml.py
@@ -19,6 +19,24 @@ from synapse.handlers.sso import MappingException
 
 from tests.unittest import HomeserverTestCase, override_config
 
+# Check if we have the dependencies to run the tests.
+try:
+    import saml2.config
+    from saml2.sigver import SigverError
+
+    has_saml2 = True
+
+    # pysaml2 can be installed and imported, but might not be able to find xmlsec1.
+    config = saml2.config.SPConfig()
+    try:
+        config.load({"metadata": {}})
+        has_xmlsec1 = True
+    except SigverError:
+        has_xmlsec1 = False
+except ImportError:
+    has_saml2 = False
+    has_xmlsec1 = False
+
 # These are a few constants that are used as config parameters in the tests.
 BASE_URL = "https://synapse/"
 
@@ -86,6 +104,11 @@ class SamlHandlerTestCase(HomeserverTestCase):
 
         return hs
 
+    if not has_saml2:
+        skip = "Requires pysaml2"
+    elif not has_xmlsec1:
+        skip = "Requires xmlsec1"
+
     def test_map_saml_response_to_user(self):
         """Ensure that mapping the SAML response returned from a provider to an MXID works properly."""
         saml_response = FakeAuthnResponse({"uid": "test_user", "username": "test_user"})