def test_mdx_certs(): sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"]) http = HTTPBase(verify=False, ca_bundle=None) mdx = MetaDataMDX(quote_plus, ONTS.values(), ATTRCONV, "http://pyff-test.nordu.net", sec_config, None, http) foo = mdx.certs("https://idp.umu.se/saml2/idp/metadata.php", "idpsso") assert len(foo) == 1
def test_mdx_certs(): sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"]) http = HTTPBase(verify=False, ca_bundle=None) mdx = MetaDataMDX(ONTS.values(), ATTRCONV, "http://pyff-test.nordu.net", sec_config, None, http) foo = mdx.certs("https://idp.umu.se/saml2/idp/metadata.php", "idpsso") assert len(foo) == 1
def test_mdx_service(): entity_id = "http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php" url = "http://mdx.example.com/entities/{}".format( quote_plus(MetaDataMDX.sha1_entity_transform(entity_id))) responses.add(responses.GET, url, body=TEST_METADATA_STRING, status=200, content_type=SAML_METADATA_CONTENT_TYPE) mdx = MetaDataMDX("http://mdx.example.com") sso_loc = mdx.service(entity_id, "idpsso_descriptor", "single_sign_on_service") assert sso_loc[BINDING_HTTP_REDIRECT][0]["location"] == "http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php" certs = mdx.certs(entity_id, "idpsso") assert len(certs) == 1
def test_mdx_service(): entity_id = "http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php" url = "http://mdx.example.com/entities/{}".format( parse.quote_plus(MetaDataMDX.sha1_entity_transform(entity_id))) responses.add(responses.GET, url, body=TEST_METADATA_STRING, status=200, content_type=SAML_METADATA_CONTENT_TYPE) mdx = MetaDataMDX("http://mdx.example.com") sso_loc = mdx.service(entity_id, "idpsso_descriptor", "single_sign_on_service") assert sso_loc[BINDING_HTTP_REDIRECT][0]["location"] == "http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php" certs = mdx.certs(entity_id, "idpsso") assert len(certs) == 1
from django.conf import settings from djangosaml2idp.utils import repr_saml from saml2.attribute_converter import ac_factory from saml2.config import IdPConfig from saml2.mdstore import MetadataStore, MetaDataMDX from saml2.metadata import entity_descriptor try: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) except: BASE_DIR = os.getcwd() print('BASE_DIR is', BASE_DIR) conf = IdPConfig() # conf.load_file("idp_conf_mdb") conf.load(copy.deepcopy(settings.SAML_IDP_CONFIG)) mdx = MetaDataMDX("https://ds.testunical.it") mdx.service("https://sp1.testunical.it/saml2/metadata/", "spsso_descriptor", 'assertion_consumer_service') mdx.certs("https://sp1.testunical.it/saml2/metadata/", "spsso", use="signing") mdx.single_sign_on_service("https://idp1.testunical.it/idp/metadata") mdx.service("https://idp1.testunical.it/idp/metadata", 'idpsso', 'sso_service') mdx.certs("https://idp1.testunical.it/idp/metadata", "idpsso", use="encryption") # all metadata as a dict here: mdx.entity