Skip to content

Commit

Permalink
Do not raise when no attributes are given
Browse files Browse the repository at this point in the history
  • Loading branch information
morten committed Jun 10, 2011
1 parent 8a3520b commit ccae363
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/onelogin/saml/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def attributes
result = {}

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|
name = attr_element.attributes["Name"]
value = attr_element.elements.first.text
Expand Down
7 changes: 6 additions & 1 deletion test/ruby-saml_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class RubySamlTest < Test::Unit::TestCase
response = Onelogin::Saml::Response.new(response_document_3)
assert !response.name_id.nil?
end

should "check time conditions" do
response = Onelogin::Saml::Response.new(response_document)
assert !response.check_conditions
Expand Down Expand Up @@ -111,6 +111,11 @@ class RubySamlTest < Test::Unit::TestCase
response = Onelogin::Saml::Response.new(response_document_3)
assert_equal "[email protected]", response.attributes["http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"]
end

should "not raise on responses without attributes" do
response = Onelogin::Saml::Response.new(response_document_4)
assert_equal Hash.new, response.attributes
end
end

context "#session_expires_at" do
Expand Down

0 comments on commit ccae363

Please sign in to comment.