コード例 #1
0
ファイル: test_30_metadata.py プロジェクト: paulftw/pysaml2
def test_incommon_1():
    md = metadata.MetaData(attrconv=ATTRCONV)
    md.import_metadata(_read_file(INCOMMON_METADATA), "-")
    print len(md.entity)
    assert len(md.entity) == 442
    idps = dict([(id, ent["idpsso"]) for id, ent in md.entity.items() if "idpsso" in ent])
    print idps.keys()
    assert len(idps) == 53  # !!!!???? < 10%
    assert md.single_sign_on_service("urn:mace:incommon:uiuc.edu") == []
    idpsso = md.single_sign_on_service("urn:mace:incommon:alaska.edu")
    assert len(idpsso) == 1
    print idpsso
    assert idpsso == ["https://idp.alaska.edu/idp/profile/SAML2/Redirect/SSO"]

    sps = dict([(id, ent["spsso"]) for id, ent in md.entity.items() if "spsso" in ent])

    acs_sp = []
    for nam, desc in sps.items():
        if desc[0].attribute_consuming_service:
            acs_sp.append(nam)

    assert len(acs_sp) == 0

    # Look for attribute authorities
    aas = dict([(id, ent["attribute_authority"]) for id, ent in md.entity.items() if "attribute_authority" in ent])

    print aas.keys()
    assert len(aas) == 53
コード例 #2
0
ファイル: test_30_metadata.py プロジェクト: paulftw/pysaml2
def test_swami_1():
    md = metadata.MetaData(attrconv=ATTRCONV)
    md.import_metadata(_read_file(SWAMI_METADATA), "-")
    print len(md.entity)
    assert len(md.entity)
    idps = dict([(id, ent["idpsso"]) for id, ent in md.entity.items() if "idpsso" in ent])
    print idps
    assert idps.keys()
    idpsso = md.single_sign_on_service("https://idp.umu.se/saml2/idp/metadata.php")
    assert md.name("https://idp.umu.se/saml2/idp/metadata.php") == (u"Ume\xe5 University (SAML2)")
    assert len(idpsso) == 1
    assert idpsso == ["https://idp.umu.se/saml2/idp/SSOService.php"]
    print md._loc_key["https://idp.umu.se/saml2/idp/SSOService.php"]
    ssocerts = md.certs("https://idp.umu.se/saml2/idp/SSOService.php", "signing")
    print ssocerts
    assert len(ssocerts) == 1
    sps = dict([(id, ent["spsso"]) for id, ent in md.entity.items() if "spsso" in ent])

    acs_sp = []
    for nam, desc in sps.items():
        if desc[0].attribute_consuming_service:
            acs_sp.append(nam)

    # print md.wants('https://www.diva-portal.org/shibboleth')
    wants = md.attribute_requirement("https://connect8.sunet.se/shibboleth")
    lnamn = [to_local_name(md.attrconv, attr) for attr in wants[1]]
    assert _eq(lnamn, ["mail", "givenName", "eduPersonPrincipalName", "sn", "eduPersonScopedAffiliation"])

    wants = md.attribute_requirement("https://beta.lobber.se/shibboleth")
    assert wants[0] == []
    lnamn = [to_local_name(md.attrconv, attr) for attr in wants[1]]
    assert _eq(
        lnamn,
        ["eduPersonScopedAffiliation", "eduPersonEntitlement", "eduPersonPrincipalName", "sn", "mail", "givenName"],
    )
コード例 #3
0
ファイル: test_30_metadata.py プロジェクト: paulftw/pysaml2
def test_switch_1():
    md = metadata.MetaData(attrconv=ATTRCONV)
    md.import_metadata(_read_file(SWITCH_METADATA), "-")
    print len(md.entity)
    assert len(md.entity) == 90
    idps = dict([(id, ent["idpsso"]) for id, ent in md.entity.items() if "idpsso" in ent])
    print idps.keys()
    idpsso = md.single_sign_on_service("https://aai-demo-idp.switch.ch/idp/shibboleth")
    assert len(idpsso) == 1
    print idpsso
    assert idpsso == ["https://aai-demo-idp.switch.ch/idp/profile/SAML2/Redirect/SSO"]
    assert len(idps) == 16
    aas = dict([(id, ent["attribute_authority"]) for id, ent in md.entity.items() if "attribute_authority" in ent])
    print aas.keys()
    aads = aas["https://aai-demo-idp.switch.ch/idp/shibboleth"]
    assert len(aads) == 1
    aad = aads[0]
    assert len(aad.attribute_service) == 1
    assert len(aad.name_id_format) == 2
    dual = dict([(id, ent) for id, ent in md.entity.items() if "idpsso" in ent and "spsso" in ent])
    print len(dual)
    assert len(dual) == 0