|
1 | 1 | # -*- coding: utf-8 -*-
|
| 2 | +from pymongo.errors import ConnectionFailure |
2 | 3 |
|
3 | 4 | __author__ = 'rolandh'
|
4 | 5 |
|
@@ -55,43 +56,46 @@ def test_metadata():
|
55 | 56 | mds.imp({"local": [full_path("swamid-2.0.xml")]})
|
56 | 57 | assert len(mds) == 1 # One source
|
57 | 58 |
|
58 |
| - export_mdstore_to_mongo_db(mds, "metadata", "test") |
59 |
| - |
60 |
| - mdmdb = MetadataMDB(ONTS, ATTRCONV, "metadata", "test") |
61 |
| - # replace all metadata instances with this one |
62 |
| - mds.metadata = {"mongo_db": mdmdb} |
63 |
| - |
64 |
| - idps = mds.with_descriptor("idpsso") |
65 |
| - assert idps.keys() |
66 |
| - idpsso = mds.single_sign_on_service(UMU_IDP) |
67 |
| - assert len(idpsso) == 1 |
68 |
| - assert destinations(idpsso) == [ |
69 |
| - 'https://idp.umu.se/saml2/idp/SSOService.php'] |
70 |
| - |
71 |
| - _name = name(mds[UMU_IDP]) |
72 |
| - assert _name == u'Ume\xe5 University' |
73 |
| - certs = mds.certs(UMU_IDP, "idpsso", "signing") |
74 |
| - assert len(certs) == 1 |
75 |
| - |
76 |
| - sps = mds.with_descriptor("spsso") |
77 |
| - assert len(sps) == 417 |
78 |
| - |
79 |
| - wants = mds.attribute_requirement('https://connect.sunet.se/shibboleth') |
80 |
| - assert wants["optional"] == [] |
81 |
| - lnamn = [d_to_local_name(mds.attrc, attr) for attr in wants["required"]] |
82 |
| - assert _eq(lnamn, ['eduPersonPrincipalName', 'mail', 'givenName', 'sn', |
83 |
| - 'eduPersonScopedAffiliation', 'eduPersonAffiliation']) |
84 |
| - |
85 |
| - wants = mds.attribute_requirement( |
86 |
| - "https://gidp.geant.net/sp/module.php/saml/sp/metadata.php/default-sp") |
87 |
| - # Optional |
88 |
| - lnamn = [d_to_local_name(mds.attrc, attr) for attr in wants["optional"]] |
89 |
| - assert _eq(lnamn, ['displayName', 'commonName', 'schacHomeOrganization', |
90 |
| - 'eduPersonAffiliation', 'schacHomeOrganizationType']) |
91 |
| - # Required |
92 |
| - lnamn = [d_to_local_name(mds.attrc, attr) for attr in wants["required"]] |
93 |
| - assert _eq(lnamn, ['eduPersonTargetedID', 'mail', |
94 |
| - 'eduPersonScopedAffiliation']) |
| 59 | + try: |
| 60 | + export_mdstore_to_mongo_db(mds, "metadata", "test") |
| 61 | + except ConnectionFailure: |
| 62 | + pass |
| 63 | + else: |
| 64 | + mdmdb = MetadataMDB(ONTS, ATTRCONV, "metadata", "test") |
| 65 | + # replace all metadata instances with this one |
| 66 | + mds.metadata = {"mongo_db": mdmdb} |
| 67 | + |
| 68 | + idps = mds.with_descriptor("idpsso") |
| 69 | + assert idps.keys() |
| 70 | + idpsso = mds.single_sign_on_service(UMU_IDP) |
| 71 | + assert len(idpsso) == 1 |
| 72 | + assert destinations(idpsso) == [ |
| 73 | + 'https://idp.umu.se/saml2/idp/SSOService.php'] |
| 74 | + |
| 75 | + _name = name(mds[UMU_IDP]) |
| 76 | + assert _name == u'Ume\xe5 University' |
| 77 | + certs = mds.certs(UMU_IDP, "idpsso", "signing") |
| 78 | + assert len(certs) == 1 |
| 79 | + |
| 80 | + sps = mds.with_descriptor("spsso") |
| 81 | + assert len(sps) == 417 |
| 82 | + |
| 83 | + wants = mds.attribute_requirement('https://connect.sunet.se/shibboleth') |
| 84 | + assert wants["optional"] == [] |
| 85 | + lnamn = [d_to_local_name(mds.attrc, attr) for attr in wants["required"]] |
| 86 | + assert _eq(lnamn, ['eduPersonPrincipalName', 'mail', 'givenName', 'sn', |
| 87 | + 'eduPersonScopedAffiliation', 'eduPersonAffiliation']) |
| 88 | + |
| 89 | + wants = mds.attribute_requirement( |
| 90 | + "https://gidp.geant.net/sp/module.php/saml/sp/metadata.php/default-sp") |
| 91 | + # Optional |
| 92 | + lnamn = [d_to_local_name(mds.attrc, attr) for attr in wants["optional"]] |
| 93 | + assert _eq(lnamn, ['displayName', 'commonName', 'schacHomeOrganization', |
| 94 | + 'eduPersonAffiliation', 'schacHomeOrganizationType']) |
| 95 | + # Required |
| 96 | + lnamn = [d_to_local_name(mds.attrc, attr) for attr in wants["required"]] |
| 97 | + assert _eq(lnamn, ['eduPersonTargetedID', 'mail', |
| 98 | + 'eduPersonScopedAffiliation']) |
95 | 99 |
|
96 | 100 | if __name__ == "__main__":
|
97 | 101 | test_metadata()
|
0 commit comments