diff options
author | Johan Lundberg <lundberg@sunet.se> | 2021-12-07 18:20:49 +0100 |
---|---|---|
committer | Johan Lundberg <lundberg@sunet.se> | 2021-12-07 18:20:49 +0100 |
commit | e311ae82cf4c90b441e13adc55cd3f5074161bf8 (patch) | |
tree | 59935701c27ac5333d2ee4974d3c75857cab6605 /tests/test_37_entity_categories.py | |
parent | 72e69e43f555e3f37e8a21a89ac1f34402700a31 (diff) | |
download | pysaml2-e311ae82cf4c90b441e13adc55cd3f5074161bf8.tar.gz |
implement entity category https://myacademicid.org/entity-categories/esi for swamid
Diffstat (limited to 'tests/test_37_entity_categories.py')
-rw-r--r-- | tests/test_37_entity_categories.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/test_37_entity_categories.py b/tests/test_37_entity_categories.py index 64b674d1..c988d72c 100644 --- a/tests/test_37_entity_categories.py +++ b/tests/test_37_entity_categories.py @@ -278,3 +278,51 @@ def test_filter_ava_required_attributes_with_no_friendly_name(): ava = policy.filter(ava, entity_id, required=required, optional=optional) assert _eq(list(ava.keys()), ["eduPersonTargetedID"]) + + +def test_filter_ava_esi_coco(): + entity_id = "https://esi-coco.example.edu/saml2/metadata/" + mds = MetadataStore(ATTRCONV, sec_config, disable_ssl_certificate_validation=True) + mds.imp( + [ + { + "class": "saml2.mdstore.MetaDataFile", + "metadata": [(full_path("entity_esi_and_coco_sp.xml"),)] + } + ] + ) + + policy_conf = { + "default": { + "lifetime": {"minutes": 15}, + "entity_categories": ["swamid"] + } + } + policy = Policy(policy_conf, mds) + + ava = { + "givenName": ["Test"], + "sn": ["Testsson"], + "mail": ["test@example.com"], + "c": ["SE"], + "schacHomeOrganization": ["example.com"], + "eduPersonScopedAffiliation": ["student@example.com"], + "schacPersonalUniqueCode": [ + "urn:schac:personalUniqueCode:int:esi:ladok.se:externtstudentuid-00000000-1111-2222-3333-444444444444" + ] + } + + ava = policy.filter(ava, entity_id) + + assert _eq(list(ava.keys()), [ + 'mail', + 'givenName', + 'sn', + 'c', + 'schacHomeOrganization', + 'eduPersonScopedAffiliation', + 'schacPersonalUniqueCode' + ]) + assert _eq(ava["mail"], ["test@example.com"]) + assert _eq(ava["schacPersonalUniqueCode"], + ["urn:schac:personalUniqueCode:int:esi:ladok.se:externtstudentuid-00000000-1111-2222-3333-444444444444"]) |