def test_metadata_file(): sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"]) mds = MetadataStore(ATTRCONV, sec_config, disable_ssl_certificate_validation=True) mds.imp(METADATACONF["8"]) print(len(mds.keys())) assert len(mds.keys()) == 560
def test_load_external(): sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"]) mds = MetadataStore(ATTRCONV, sec_config, disable_ssl_certificate_validation=True) mds.imp(METADATACONF["10"]) print(mds) assert len(mds) == 1 # One source assert len(mds.keys()) > 1 # number of idps
def test_load_local_dir(): sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"]) mds = MetadataStore(ATTRCONV, sec_config, disable_ssl_certificate_validation=True) mds.imp(METADATACONF["9"]) print(mds) assert len(mds) == 3 # Three sources assert len(mds.keys()) == 4 # number of idps
def test_load_extern_incommon(): sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"]) mds = MetadataStore(ATTRCONV, sec_config, disable_ssl_certificate_validation=True) mds.imp(METADATACONF["10"]) print(mds) assert mds assert len(mds.keys())
def test_load_string(): sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"]) mds = MetadataStore(ATTRCONV, sec_config, disable_ssl_certificate_validation=True) mds.imp(METADATACONF["11"]) print(mds) assert len(mds.keys()) == 1 idps = mds.with_descriptor("idpsso") assert list(idps.keys()) == [ 'http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php'] certs = mds.certs( 'http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php', "idpsso", "signing") assert len(certs) == 1
def test_load_string(): sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"]) mds = MetadataStore(ATTRCONV, sec_config, disable_ssl_certificate_validation=True) mds.imp(METADATACONF["11"]) print(mds) assert len(mds.keys()) == 1 idps = mds.with_descriptor("idpsso") assert list(idps.keys()) == [ 'http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php' ] certs = mds.certs( 'http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php', "idpsso", "signing") assert len(certs) == 1
from contextlib import closing from saml2_tophat import sigver from saml2_tophat import config from saml2_tophat.assertion import Policy from saml2_tophat.attribute_converter import ac_factory from pathutils import full_path from saml2_tophat.mdstore import MetadataStore from saml2_tophat.server import Server ATTRCONV = ac_factory(full_path("attributemaps")) sec_config = config.Config() sec_config.xmlsec_binary = sigver.get_xmlsec_binary(["/opt/local/bin"]) __author__ = 'rolandh' MDS = MetadataStore(ATTRCONV, sec_config, disable_ssl_certificate_validation=True) MDS.imp([{"class": "saml2_tophat.mdstore.MetaDataMD", "metadata": [(full_path("swamid.md"),)]}]) def _eq(l1, l2): return set(l1) == set(l2) def test_filter_ava(): policy = Policy({ "default": { "lifetime": {"minutes": 15}, # "attribute_restrictions": None # means all I have
import os.path BASEDIR = os.path.abspath(os.path.dirname(__file__)) def full_path(local_file): return os.path.join(BASEDIR, local_file) def dotname(module): if not BASEDIR.endswith('tests'): return 'tests.' + module else: return module try: from saml2_tophat.sigver import get_xmlsec_binary except ImportError: get_xmlsec_binary = None if get_xmlsec_binary: xmlsec_path = get_xmlsec_binary(["/opt/local/bin"]) else: xmlsec_path = '/usr/bin/xmlsec1'
#!/usr/bin/env python # -*- coding: utf-8 -*- from saml2_tophat import BINDING_HTTP_REDIRECT, BINDING_URI from saml2_tophat import BINDING_HTTP_POST from saml2_tophat.saml import NAME_FORMAT_URI from saml2_tophat.saml import NAMEID_FORMAT_TRANSIENT from saml2_tophat.saml import NAMEID_FORMAT_PERSISTENT try: from saml2_tophat.sigver import get_xmlsec_binary except ImportError: get_xmlsec_binary = None if get_xmlsec_binary: xmlsec_path = get_xmlsec_binary(["/opt/local/bin"]) else: xmlsec_path = '/usr/bin/xmlsec1' #BASE = "http://lingon.ladok.umu.se:8088" #BASE = "http://lingon.catalogix.se:8088" BASE = "http://localhost:8088" CONFIG = { "entityid": "%s/idp.xml" % BASE, "description": "My IDP", "service": { "idp": { "name": "Rolands IdP", "endpoints": {
for alg in algs: if alg in DIGEST_METHODS: digest.append(alg) elif alg in SIGNING_METHODS: signing.append(alg) return {"digest": digest, "signing": signing} raise SystemError(p_err) def algorithm_support_in_metadata(xmlsec): if xmlsec is None: return [] support = get_algorithm_support(xmlsec) element_list = [] for alg in support["digest"]: element_list.append(DigestMethod(algorithm=DIGEST_METHODS[alg])) for alg in support["signing"]: element_list.append(SigningMethod(algorithm=SIGNING_METHODS[alg])) return element_list if __name__ == '__main__': xmlsec = get_xmlsec_binary() res = get_algorithm_support(xmlsec) print(res) for a in algorithm_support_in_metadata(xmlsec): print(a)
signing = [] for alg in algs: if alg in DIGEST_METHODS: digest.append(alg) elif alg in SIGNING_METHODS: signing.append(alg) return {"digest": digest, "signing": signing} raise SystemError(p_err) def algorithm_support_in_metadata(xmlsec): if xmlsec is None: return [] support = get_algorithm_support(xmlsec) element_list = [] for alg in support["digest"]: element_list.append(DigestMethod(algorithm=DIGEST_METHODS[alg])) for alg in support["signing"]: element_list.append(SigningMethod(algorithm=SIGNING_METHODS[alg])) return element_list if __name__ == '__main__': xmlsec = get_xmlsec_binary() res = get_algorithm_support(xmlsec) print(res) for a in algorithm_support_in_metadata(xmlsec): print(a)