From 353c52ee0c26d36512494923c08919a86d862185 Mon Sep 17 00:00:00 2001 From: Johan Lundberg Date: Wed, 15 Dec 2021 11:50:12 +0100 Subject: correct swamid entity category setup for ESI and COCO updated test to reflect current usecase --- src/saml2/entity_category/swamid.py | 5 ++++- tests/entity_esi_and_coco_sp.xml | 1 + tests/test_37_entity_categories.py | 27 ++++++++++++++++++++------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/saml2/entity_category/swamid.py b/src/saml2/entity_category/swamid.py index 61525b70..ed0ac618 100644 --- a/src/saml2/entity_category/swamid.py +++ b/src/saml2/entity_category/swamid.py @@ -84,4 +84,7 @@ RELEASE = { (ESI, COCO): MYACADEMICID_ESI + GEANT_COCO, } -ONLY_REQUIRED = {COCO: True} +ONLY_REQUIRED = { + COCO: True, + (ESI, COCO): True, +} diff --git a/tests/entity_esi_and_coco_sp.xml b/tests/entity_esi_and_coco_sp.xml index db2fe474..a076535b 100644 --- a/tests/entity_esi_and_coco_sp.xml +++ b/tests/entity_esi_and_coco_sp.xml @@ -69,6 +69,7 @@ wHyaxzYldWmVC5omkgZeAdCGpJ316GQF8Zwg/yDOUzm4cvGeIESf1Q6ZxBwI6zGE esi-coco-SP ESI and COCO SP + diff --git a/tests/test_37_entity_categories.py b/tests/test_37_entity_categories.py index c988d72c..2f724644 100644 --- a/tests/test_37_entity_categories.py +++ b/tests/test_37_entity_categories.py @@ -298,6 +298,7 @@ def test_filter_ava_esi_coco(): "entity_categories": ["swamid"] } } + policy = Policy(policy_conf, mds) ava = { @@ -312,17 +313,29 @@ def test_filter_ava_esi_coco(): ] } - ava = policy.filter(ava, entity_id) + requested_attributes = [ + { + 'friendly_name': 'eduPersonScopedAffiliation', + 'name': '1.3.6.1.4.1.5923.1.1.1.9', + 'name_format': NAME_FORMAT_URI, + 'is_required': 'true' + }, + { + 'friendly_name': 'schacHomeOrganization', + 'name': '1.3.6.1.4.1.25178.1.2.9', + 'name_format': NAME_FORMAT_URI, + 'is_required': 'true' + } + ] + + ava = policy.filter(ava, entity_id, required=requested_attributes) assert _eq(list(ava.keys()), [ - 'mail', - 'givenName', - 'sn', - 'c', - 'schacHomeOrganization', 'eduPersonScopedAffiliation', + 'schacHomeOrganization', 'schacPersonalUniqueCode' ]) - assert _eq(ava["mail"], ["test@example.com"]) + assert _eq(ava["eduPersonScopedAffiliation"], ["student@example.com"]) + assert _eq(ava["schacHomeOrganization"], ["example.com"]) assert _eq(ava["schacPersonalUniqueCode"], ["urn:schac:personalUniqueCode:int:esi:ladok.se:externtstudentuid-00000000-1111-2222-3333-444444444444"]) -- cgit v1.2.1