Skip to content
Browse files

renamed response6 to response7, implemented parsing multiple attributes

  • Loading branch information...
1 parent d72162d commit 9aa4a6cd1115ceb2797bc1eada8973c46407f64a @hryk committed Mar 17, 2012
View
9 lib/onelogin/saml/response.rb
@@ -38,10 +38,13 @@ def attributes
stmt_element = REXML::XPath.first(document, "/p:Response/a:Assertion/a:AttributeStatement", { "p" => PROTOCOL, "a" => ASSERTION })
return {} if stmt_element.nil?
- stmt_element.elements.each do |attr_element|
+ stmt_element.each_element do |attr_element|
name = attr_element.attributes["Name"]
- value = attr_element.elements.first.text
-
+ value = if attr_element.elements.size > 1
+ attr_element.elements.collect {|e| e.text }
+ else
+ attr_element.elements.first.text
+ end
result[name] = value
end
View
4 test/response_test.rb
@@ -214,13 +214,13 @@ class RubySamlTest < Test::Unit::TestCase
end
should "return an Array of AttributeValues" do
- response = Onelogin::Saml::Response.new(response_document_4)
+ response = Onelogin::Saml::Response.new(response_document_7)
member_of_attributes = [
'cn=group1,ou=Groups,dc=example,dc=com',
'cn=group2,ou=Groups,dc=example,dc=com',
'cn=group3,ou=Groups,dc=example,dc=com'
]
- assert response.attributes.kind_of?(Array), 'member_of attribute is an instance of Array.'
+ assert response.attributes[:member_of].kind_of?(Array), 'member_of attribute is an instance of Array.'
assert_equal member_of_attributes, response.attributes[:member_of], 'correctly parsed member_of attribute.'
end
end
View
0 test/responses/response6.xml.base64 → test/responses/response7.xml.base64
File renamed without changes.
View
10 test/test_helper.rb
@@ -38,11 +38,6 @@ def response_document_5
@response_document5 ||= File.read(File.join(File.dirname(__FILE__), 'responses', 'response5.xml.base64'))
end
- # Multiple AttributeValues in a Attribute
- def response_document_6
- @response_document6 ||= File.read(File.join(File.dirname(__FILE__), 'responses', 'response6.xml.base64'))
- end
-
def ampersands_response
@ampersands_resposne ||= File.read(File.join(File.dirname(__FILE__), 'responses', 'response_with_ampersands.xml.base64'))
end
@@ -62,6 +57,11 @@ def response_document_6
Base64.encode64(doc)
end
+ # Multiple AttributeValues in a Attribute
+ def response_document_7
+ @response_document7 ||= File.read(File.join(File.dirname(__FILE__), 'responses', 'response7.xml.base64'))
+ end
+
def signature_fingerprint_1
@signature_fingerprint1 ||= "C5:19:85:D9:47:F1:BE:57:08:20:25:05:08:46:EB:27:F6:CA:B7:83"
end

0 comments on commit 9aa4a6c

Please sign in to comment.
Something went wrong with that request. Please try again.