diff options
Diffstat (limited to 'tests/test_20_assertion.py')
-rw-r--r-- | tests/test_20_assertion.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/test_20_assertion.py b/tests/test_20_assertion.py index 4b3c0ea9..8043c911 100644 --- a/tests/test_20_assertion.py +++ b/tests/test_20_assertion.py @@ -1,4 +1,6 @@ # coding=utf-8 +import pytest + from saml2.authn_context import pword from saml2.mdie import to_dict from saml2 import md, assertion @@ -81,9 +83,10 @@ def test_filter_on_attributes_1(): def test_filter_on_attributes_without_friendly_name(): ava = {"eduPersonTargetedID": "test@example.com", "eduPersonAffiliation": "test", "extra": "foo"} - eptid = to_dict(Attribute(name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10", name_format=NAME_FORMAT_URI), ONTS) + eptid = to_dict( + Attribute(name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10", name_format=NAME_FORMAT_URI), ONTS) ep_affiliation = to_dict( - Attribute(name="urn:oid:1.3.6.1.4.1.5923.1.1.1.1", name_format=NAME_FORMAT_URI), ONTS) + Attribute(name="urn:oid:1.3.6.1.4.1.5923.1.1.1.1", name_format=NAME_FORMAT_URI), ONTS) restricted_ava = filter_on_attributes(ava, required=[eptid], optional=[ep_affiliation], acs=ac_factory()) @@ -91,6 +94,23 @@ def test_filter_on_attributes_without_friendly_name(): "eduPersonAffiliation": "test"} +def test_filter_on_attributes_with_missing_required_attribute(): + ava = {"extra": "foo"} + eptid = to_dict(Attribute( + friendly_name="eduPersonTargetedID", name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10", + name_format=NAME_FORMAT_URI), ONTS) + with pytest.raises(MissingValue): + filter_on_attributes(ava, required=[eptid]) + + +def test_filter_on_attributes_with_missing_optional_attribute(): + ava = {"extra": "foo"} + eptid = to_dict(Attribute( + friendly_name="eduPersonTargetedID", name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10", + name_format=NAME_FORMAT_URI), ONTS) + assert filter_on_attributes(ava, optional=[eptid]) == {} + + # ---------------------------------------------------------------------- def test_lifetime_1(): |