summaryrefslogtreecommitdiff
path: root/tests/test_37_entity_categories.py
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2021-12-07 19:29:32 +0200
committerGitHub <noreply@github.com>2021-12-07 19:29:32 +0200
commit155910dabffa0f60a2075be862f2cf8c31fad685 (patch)
treed6d6985a54558ff12452820935d532dd4477c984 /tests/test_37_entity_categories.py
parentb32fe902b47803fb4a701ed7830d9e7b03fde3fc (diff)
parente311ae82cf4c90b441e13adc55cd3f5074161bf8 (diff)
downloadpysaml2-155910dabffa0f60a2075be862f2cf8c31fad685.tar.gz
Merge pull request #842 from johanlundberg/lundberg_swamid_esi
Implement entity category MyAcademicID-ESI for SWAMID
Diffstat (limited to 'tests/test_37_entity_categories.py')
-rw-r--r--tests/test_37_entity_categories.py48
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"])