File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 8
8
9
9
from saml2 .s_utils import factory
10
10
from saml2 .s_utils import do_ava
11
- from saml2 import saml
11
+ from saml2 import saml , ExtensionElement , NAMESPACE
12
12
from saml2 import extension_elements_to_elements
13
13
from saml2 import SAMLError
14
14
from saml2 .saml import NAME_FORMAT_UNSPECIFIED , NAMEID_FORMAT_PERSISTENT , NameID
@@ -495,7 +495,12 @@ def to_(self, attrvals):
495
495
if name :
496
496
if name == "urn:oid:1.3.6.1.4.1.5923.1.1.1.10" :
497
497
# special case for eduPersonTargetedID
498
- attr_value = do_ava (NameID (format = NAMEID_FORMAT_PERSISTENT , text = value ).to_string ())
498
+ attr_value = []
499
+ for v in value :
500
+ extension_element = ExtensionElement ("NameID" , NAMESPACE ,
501
+ attributes = {'Format' : NAMEID_FORMAT_PERSISTENT }, text = v )
502
+ attrval = saml .AttributeValue (extension_elements = [extension_element ])
503
+ attr_value .append (attrval )
499
504
else :
500
505
attr_value = do_ava (value )
501
506
attributes .append (factory (saml .Attribute ,
Original file line number Diff line number Diff line change @@ -211,11 +211,12 @@ def test_adjust_with_no_mapping_defined(self):
211
211
assert attr_conv ._fro is None and attr_conv ._to is None
212
212
213
213
def test_from_local_nest_eduPersonTargetedID_in_NameID (self ):
214
- ava = {"edupersontargetedid" : "test value" }
214
+ ava = {"edupersontargetedid" : [ "test value1" , "test value2" ] }
215
215
attributes = from_local (self .acs , ava , URI_NF )
216
216
assert len (attributes ) == 1
217
- assert len (attributes [0 ].attribute_value ) == 1
218
- assert attributes [0 ].attribute_value [0 ].text == NameID (format = NAMEID_FORMAT_PERSISTENT , text = "test value" ).to_string ().decode ("utf-8" )
217
+ assert len (attributes [0 ].attribute_value ) == 2
218
+ assert attributes [0 ].attribute_value [0 ].extension_elements [0 ].text == "test value1"
219
+ assert attributes [0 ].attribute_value [1 ].extension_elements [0 ].text == "test value2"
219
220
220
221
221
222
def test_noop_attribute_conversion ():
You can’t perform that action at this time.
0 commit comments