File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ def sessionindex
4949 end
5050 end
5151
52- # A hash of alle the attributes with the response. Assuming there is only one value for each key
52+ # A hash of all the attributes with the response.
53+ # Multiple values will be returned in the AttributeValue#values array
5354 def attributes
5455 @attr_statements ||= begin
5556 result = { }
@@ -63,6 +64,11 @@ def attributes
6364
6465 # Set up a string-like wrapper for the values array
6566 attr_value = AttributeValue . new ( values . first , values )
67+ # Merge values if the Attribute has already been seen
68+ if result [ name ]
69+ attr_value . values += result [ name ] . values
70+ end
71+
6672 result [ name ] = attr_value
6773 end
6874
Original file line number Diff line number Diff line change @@ -239,6 +239,16 @@ class RubySamlTest < Test::Unit::TestCase
239239 response = OneLogin ::RubySaml ::Response . new ( fixture ( :response_with_multiple_attribute_values ) )
240240 assert_equal [ 'value1' , 'value2' ] , response . attributes [ :another_value ] . values
241241 end
242+
243+ should "return last of multiple values when multiple Attribute tags in XML" do
244+ response = OneLogin ::RubySaml ::Response . new ( fixture ( :response_with_multiple_attribute_values ) )
245+ assert_equal 'role2' , response . attributes [ :role ]
246+ end
247+
248+ should "return all of multiple values in reverse order when multiple Attribute tags in XML" do
249+ response = OneLogin ::RubySaml ::Response . new ( fixture ( :response_with_multiple_attribute_values ) )
250+ assert_equal [ 'role2' , 'role1' ] , response . attributes [ :role ] . values
251+ end
242252 end
243253 end
244254
Original file line number Diff line number Diff line change 4646 <saml : AttributeValue xmlns : xs =" http://www.w3.org/2001/XMLSchema" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : type =" xs:string" >value1</saml : AttributeValue >
4747 <saml : AttributeValue xmlns : xs =" http://www.w3.org/2001/XMLSchema" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : type =" xs:string" >value2</saml : AttributeValue >
4848 </saml : Attribute >
49+ <saml : Attribute Name =" role" >
50+ <saml : AttributeValue xmlns : xs =" http://www.w3.org/2001/XMLSchema" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : type =" xs:string" >role1</saml : AttributeValue >
51+ </saml : Attribute >
52+ <saml : Attribute Name =" role" >
53+ <saml : AttributeValue xmlns : xs =" http://www.w3.org/2001/XMLSchema" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : type =" xs:string" >role2</saml : AttributeValue >
54+ </saml : Attribute >
4955 </saml : AttributeStatement >
5056 </saml : Assertion >
5157</samlp : Response >
You can’t perform that action at this time.
0 commit comments