summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2021-12-15 13:11:28 +0200
committerGitHub <noreply@github.com>2021-12-15 13:11:28 +0200
commit3b5b7c70241315d2794ace3d4e13116495a7b4e3 (patch)
tree52af1b868bf23c8580b3f6126f5d9af0dd3ddc21
parentff667e83324a9cbe551d3d096e91d59e6b71ae59 (diff)
parent353c52ee0c26d36512494923c08919a86d862185 (diff)
downloadpysaml2-3b5b7c70241315d2794ace3d4e13116495a7b4e3.tar.gz
Merge pull request #846 from johanlundberg/lundberg_swamid_esi_2
Fix entity category MyAcademicID-ESI for SWAMID
-rw-r--r--src/saml2/entity_category/swamid.py5
-rw-r--r--tests/entity_esi_and_coco_sp.xml1
-rw-r--r--tests/test_37_entity_categories.py27
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
<ns0:AttributeConsumingService index="0">
<ns0:ServiceName xml:lang="en">esi-coco-SP</ns0:ServiceName>
<ns0:ServiceDescription xml:lang="en">ESI and COCO SP</ns0:ServiceDescription>
+ <ns0:RequestedAttribute FriendlyName="schacHomeOrganization" Name="urn:oid:1.3.6.1.4.1.25178.1.2.9" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" />
<ns0:RequestedAttribute FriendlyName="eduPersonScopedAffiliation" Name="urn:oid:1.3.6.1.4.1.5923.1.1.1.9" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" />
</ns0:AttributeConsumingService>
</ns0:SPSSODescriptor>
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"])