Skip to content

Commit 3b5b7c7

Browse files
Merge pull request #846 from johanlundberg/lundberg_swamid_esi_2
Fix entity category MyAcademicID-ESI for SWAMID
2 parents ff667e8 + 353c52e commit 3b5b7c7

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

src/saml2/entity_category/swamid.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,7 @@
8484
(ESI, COCO): MYACADEMICID_ESI + GEANT_COCO,
8585
}
8686

87-
ONLY_REQUIRED = {COCO: True}
87+
ONLY_REQUIRED = {
88+
COCO: True,
89+
(ESI, COCO): True,
90+
}

tests/entity_esi_and_coco_sp.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ wHyaxzYldWmVC5omkgZeAdCGpJ316GQF8Zwg/yDOUzm4cvGeIESf1Q6ZxBwI6zGE
6969
<ns0:AttributeConsumingService index="0">
7070
<ns0:ServiceName xml:lang="en">esi-coco-SP</ns0:ServiceName>
7171
<ns0:ServiceDescription xml:lang="en">ESI and COCO SP</ns0:ServiceDescription>
72+
<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" />
7273
<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" />
7374
</ns0:AttributeConsumingService>
7475
</ns0:SPSSODescriptor>

tests/test_37_entity_categories.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def test_filter_ava_esi_coco():
298298
"entity_categories": ["swamid"]
299299
}
300300
}
301+
301302
policy = Policy(policy_conf, mds)
302303

303304
ava = {
@@ -312,17 +313,29 @@ def test_filter_ava_esi_coco():
312313
]
313314
}
314315

315-
ava = policy.filter(ava, entity_id)
316+
requested_attributes = [
317+
{
318+
'friendly_name': 'eduPersonScopedAffiliation',
319+
'name': '1.3.6.1.4.1.5923.1.1.1.9',
320+
'name_format': NAME_FORMAT_URI,
321+
'is_required': 'true'
322+
},
323+
{
324+
'friendly_name': 'schacHomeOrganization',
325+
'name': '1.3.6.1.4.1.25178.1.2.9',
326+
'name_format': NAME_FORMAT_URI,
327+
'is_required': 'true'
328+
}
329+
]
330+
331+
ava = policy.filter(ava, entity_id, required=requested_attributes)
316332

317333
assert _eq(list(ava.keys()), [
318-
'mail',
319-
'givenName',
320-
'sn',
321-
'c',
322-
'schacHomeOrganization',
323334
'eduPersonScopedAffiliation',
335+
'schacHomeOrganization',
324336
'schacPersonalUniqueCode'
325337
])
326-
assert _eq(ava["mail"], ["[email protected]"])
338+
assert _eq(ava["eduPersonScopedAffiliation"], ["[email protected]"])
339+
assert _eq(ava["schacHomeOrganization"], ["example.com"])
327340
assert _eq(ava["schacPersonalUniqueCode"],
328341
["urn:schac:personalUniqueCode:int:esi:ladok.se:externtstudentuid-00000000-1111-2222-3333-444444444444"])

0 commit comments

Comments
 (0)