diff options
Diffstat (limited to 'tests/test_30_mdstore.py')
-rw-r--r-- | tests/test_30_mdstore.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/test_30_mdstore.py b/tests/test_30_mdstore.py index bfe261dd..bf54594e 100644 --- a/tests/test_30_mdstore.py +++ b/tests/test_30_mdstore.py @@ -3,6 +3,7 @@ import datetime import os import re +from re import compile as regex_compile from collections import OrderedDict from unittest.mock import Mock from unittest.mock import patch @@ -163,6 +164,10 @@ METADATACONF = { "class": "saml2.mdstore.MetaDataFile", "metadata": [(full_path("invalid_metadata_file.xml"),)], }], + "15": [{ + "class": "saml2.mdstore.MetaDataFile", + "metadata": [(full_path("idp_uiinfo.xml"),)], + }], } @@ -608,5 +613,50 @@ def test_extension(): assert mds.extension("entity2", "idpsso_descriptor", "test") +def test_shibmd_scope_no_regex_no_descriptor_type(): + mds = MetadataStore(ATTRCONV, sec_config, disable_ssl_certificate_validation=True) + mds.imp(METADATACONF["15"]) + + scopes = mds.sbibmd_scopes(entity_id='http://example.com/saml2/idp.xml') + all_scopes = list(scopes) + + expected = [ + { + "regexp": False, + "text": "descriptor-example.org", + }, + { + "regexp": True, + "text": regex_compile("descriptor-example[^0-9]*\.org"), + }, + ] + assert len(all_scopes) == 2 + assert all_scopes == expected + + +def test_shibmd_scope_no_regex_all_descriptors(): + mds = MetadataStore(ATTRCONV, sec_config, disable_ssl_certificate_validation=True) + mds.imp(METADATACONF["15"]) + + scopes = mds.sbibmd_scopes(entity_id='http://example.com/saml2/idp.xml', typ="idpsso_descriptor") + all_scopes = list(scopes) + expected = [ + { + "regexp": False, + "text": "descriptor-example.org", + }, + { + "regexp": True, + "text": regex_compile("descriptor-example[^0-9]*\.org"), + }, + { + "regexp": False, + "text": "idpssodescriptor-example.org", + }, + ] + assert len(all_scopes) == 3 + assert all_scopes == expected + + if __name__ == "__main__": test_metadata_extension_algsupport() |