0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-14 09:13:49 +01:00

Skip the SAML tests if xmlsec1 isn't available. (#8905)

This commit is contained in:
Patrick Cloke 2020-12-09 12:23:30 -05:00 committed by GitHub
parent 43bf3c5178
commit 6ff34e00d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

1
changelog.d/8905.misc Normal file
View file

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

View file

@ -19,6 +19,24 @@ from synapse.handlers.sso import MappingException
from tests.unittest import HomeserverTestCase, override_config 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. # These are a few constants that are used as config parameters in the tests.
BASE_URL = "https://synapse/" BASE_URL = "https://synapse/"
@ -86,6 +104,11 @@ class SamlHandlerTestCase(HomeserverTestCase):
return hs return hs
if not has_saml2:
skip = "Requires pysaml2"
elif not has_xmlsec1:
skip = "Requires xmlsec1"
def test_map_saml_response_to_user(self): def test_map_saml_response_to_user(self):
"""Ensure that mapping the SAML response returned from a provider to an MXID works properly.""" """Ensure that mapping the SAML response returned from a provider to an MXID works properly."""
saml_response = FakeAuthnResponse({"uid": "test_user", "username": "test_user"}) saml_response = FakeAuthnResponse({"uid": "test_user", "username": "test_user"})