Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 6ff34e0

Browse files
authored
Skip the SAML tests if xmlsec1 isn't available. (#8905)
1 parent 43bf3c5 commit 6ff34e0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

changelog.d/8905.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Skip the SAML tests if the requirements (`pysaml2` and `xmlsec1`) aren't available.

tests/handlers/test_saml.py

+23
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@
1919

2020
from tests.unittest import HomeserverTestCase, override_config
2121

22+
# Check if we have the dependencies to run the tests.
23+
try:
24+
import saml2.config
25+
from saml2.sigver import SigverError
26+
27+
has_saml2 = True
28+
29+
# pysaml2 can be installed and imported, but might not be able to find xmlsec1.
30+
config = saml2.config.SPConfig()
31+
try:
32+
config.load({"metadata": {}})
33+
has_xmlsec1 = True
34+
except SigverError:
35+
has_xmlsec1 = False
36+
except ImportError:
37+
has_saml2 = False
38+
has_xmlsec1 = False
39+
2240
# These are a few constants that are used as config parameters in the tests.
2341
BASE_URL = "https://synapse/"
2442

@@ -86,6 +104,11 @@ def make_homeserver(self, reactor, clock):
86104

87105
return hs
88106

107+
if not has_saml2:
108+
skip = "Requires pysaml2"
109+
elif not has_xmlsec1:
110+
skip = "Requires xmlsec1"
111+
89112
def test_map_saml_response_to_user(self):
90113
"""Ensure that mapping the SAML response returned from a provider to an MXID works properly."""
91114
saml_response = FakeAuthnResponse({"uid": "test_user", "username": "test_user"})

0 commit comments

Comments
 (0)