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 88
99from saml2 .s_utils import factory
1010from saml2 .s_utils import do_ava
11- from saml2 import saml
11+ from saml2 import saml , ExtensionElement , NAMESPACE
1212from saml2 import extension_elements_to_elements
1313from saml2 import SAMLError
1414from saml2 .saml import NAME_FORMAT_UNSPECIFIED , NAMEID_FORMAT_PERSISTENT , NameID
@@ -495,7 +495,12 @@ def to_(self, attrvals):
495495 if name :
496496 if name == "urn:oid:1.3.6.1.4.1.5923.1.1.1.10" :
497497 # 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 )
499504 else :
500505 attr_value = do_ava (value )
501506 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):
211211 assert attr_conv ._fro is None and attr_conv ._to is None
212212
213213 def test_from_local_nest_eduPersonTargetedID_in_NameID (self ):
214- ava = {"edupersontargetedid" : "test value" }
214+ ava = {"edupersontargetedid" : [ "test value1" , "test value2" ] }
215215 attributes = from_local (self .acs , ava , URI_NF )
216216 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"
219220
220221
221222def test_noop_attribute_conversion ():
You can’t perform that action at this time.
0 commit comments