Skip to content

Commit

Permalink
Merge pull request #292 from Jaco-Pretorius/master
Browse files Browse the repository at this point in the history
Improve the error message when validating the audience
  • Loading branch information
pitbulk committed Dec 3, 2015
2 parents 5dcb7bb + 85c8322 commit eff4a22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def validate_audience
return true if audiences.empty? || settings.issuer.nil? || settings.issuer.empty?

unless audiences.include? settings.issuer
error_msg = "#{settings.issuer} is not a valid audience for this Response"
error_msg = "#{settings.issuer} is not a valid audience for this Response - Valid audiences: #{audiences.join(',')}"
return append_error(error_msg)
end

Expand Down
8 changes: 4 additions & 4 deletions test/response_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class RubySamlTest < Minitest::Test
settings.issuer = 'invalid'
response_valid_signed.settings = settings
response_valid_signed.soft = false
error_msg = "#{response_valid_signed.settings.issuer} is not a valid audience for this Response"
error_msg = "#{response_valid_signed.settings.issuer} is not a valid audience for this Response - Valid audiences: https://someone.example.com/audience"
assert_raises(OneLogin::RubySaml::ValidationError, error_msg) do
response_valid_signed.is_valid?
end
Expand Down Expand Up @@ -368,7 +368,7 @@ class RubySamlTest < Minitest::Test
settings.issuer = 'invalid'
response_valid_signed.settings = settings
response_valid_signed.is_valid?
assert_includes response_valid_signed.errors, "#{response_valid_signed.settings.issuer} is not a valid audience for this Response"
assert_includes response_valid_signed.errors, "#{response_valid_signed.settings.issuer} is not a valid audience for this Response - Valid audiences: https://someone.example.com/audience"
end

it "return false when no ID present in the SAML Response" do
Expand Down Expand Up @@ -411,7 +411,7 @@ class RubySamlTest < Minitest::Test
response.settings = settings
response.settings.issuer = 'invalid_audience'
assert !response.send(:validate_audience)
assert_includes response.errors, "#{response.settings.issuer} is not a valid audience for this Response"
assert_includes response.errors, "#{response.settings.issuer} is not a valid audience for this Response - Valid audiences: {audience}"
end
end

Expand Down Expand Up @@ -551,7 +551,7 @@ class RubySamlTest < Minitest::Test
response_invalid_audience.settings = settings
response_invalid_audience.settings.issuer = "https://invalid.example.com/audience"
assert !response_invalid_audience.send(:validate_audience)
assert_includes response_invalid_audience.errors, "#{response_invalid_audience.settings.issuer} is not a valid audience for this Response"
assert_includes response_invalid_audience.errors, "#{response_invalid_audience.settings.issuer} is not a valid audience for this Response - Valid audiences: http://invalid.audience.com"
end
end

Expand Down

0 comments on commit eff4a22

Please sign in to comment.