Skip to content

Commit ce2a152

Browse files
committed
Add tests for pysaml2 patches
1 parent 0cadca1 commit ce2a152

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/djangosaml2_spid/tests.py

+37
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,40 @@ def test_echo_attributes(self):
460460
b"No active SAML identity found. Are you "
461461
b"sure you have logged in via SAML?",
462462
)
463+
464+
465+
class TestSaml2Patches(unittest.TestCase):
466+
467+
def test_default_namespaces(self):
468+
oasis_default_nsmap = {
469+
'saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
470+
'samlp': 'urn:oasis:names:tc:SAML:2.0:protocol',
471+
'ds': 'http://www.w3.org/2000/09/xmldsig#',
472+
'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
473+
'xs': 'http://www.w3.org/2001/XMLSchema',
474+
'mdui': 'urn:oasis:names:tc:SAML:metadata:ui',
475+
'md': 'urn:oasis:names:tc:SAML:2.0:metadata',
476+
'xenc': 'http://www.w3.org/2001/04/xmlenc#',
477+
'alg': 'urn:oasis:names:tc:SAML:metadata:algsupport',
478+
'mdattr': 'urn:oasis:names:tc:SAML:metadata:attribute',
479+
'idpdisc': 'urn:oasis:names:tc:SAML:profiles:SSO:idp-discovery-protocol',
480+
}
481+
482+
for prefix, uri in oasis_default_nsmap.items():
483+
self.assertIn(uri, ElementTree._namespace_map)
484+
self.assertEqual(prefix, ElementTree._namespace_map[uri])
485+
486+
def test_disable_weak_xmlsec_algorithms(self):
487+
import saml2.metadata
488+
from saml2.algsupport import algorithm_support_in_metadata
489+
490+
self.assertIsNot(saml2.metadata.algorithm_support_in_metadata, algorithm_support_in_metadata)
491+
self.assertEqual(saml2.metadata.algorithm_support_in_metadata.__module__, 'djangosaml2_spid._saml2')
492+
493+
def test_add_xsd_date_type(self):
494+
from saml2.saml import AttributeValueBase
495+
self.assertEqual(AttributeValueBase.set_text.__module__, 'djangosaml2_spid._saml2')
496+
497+
def test_patch_response_verify(self):
498+
from saml2.response import StatusResponse
499+
self.assertEqual(StatusResponse._verify.__module__, 'djangosaml2_spid._saml2')

0 commit comments

Comments
 (0)