Skip to content

Commit

Permalink
Fix Java weirdness
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields committed Aug 18, 2021
1 parent ea4b078 commit a35e8bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions test/response_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,9 @@ def generate_audience_error(expected, actual)
end

it "optionally allows for clock drift on NotOnOrAfter" do
# Java Floats behave differently than MRI
java = %w[jruby truffleruby].include?(ENV['RUBY_ENGINE'])

settings.soft = true

# The NotBefore condition in the document is 2011-06-1418:31:01.516Z
Expand All @@ -1154,7 +1157,7 @@ def generate_audience_error(expected, actual)

special_response_with_saml2_namespace = OneLogin::RubySaml::Response.new(
response_document_with_saml2_namespace,
:allowed_clock_drift => 0.484
:allowed_clock_drift => java ? 0.485 : 0.484
)
assert special_response_with_saml2_namespace.send(:validate_conditions)

Expand All @@ -1167,7 +1170,7 @@ def generate_audience_error(expected, actual)

special_response_with_saml2_namespace = OneLogin::RubySaml::Response.new(
response_document_with_saml2_namespace,
:allowed_clock_drift => '0.484'
:allowed_clock_drift => java ? '0.485' : '0.484'
)
assert special_response_with_saml2_namespace.send(:validate_conditions)
end
Expand Down
7 changes: 5 additions & 2 deletions test/slo_logoutrequest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ class RubySamlTest < Minitest::Test
end

it "optionally allows for clock drift" do
# Java Floats behave differently than MRI
java = %w[jruby truffleruby].include?(ENV['RUBY_ENGINE'])

logout_request.soft = true
logout_request.document.root.attributes['NotOnOrAfter'] = '2011-06-14T18:31:01.516Z'

Expand All @@ -193,13 +196,13 @@ class RubySamlTest < Minitest::Test
logout_request.options[:allowed_clock_drift] = 0.483
assert !logout_request.send(:validate_not_on_or_after)

logout_request.options[:allowed_clock_drift] = 0.484
logout_request.options[:allowed_clock_drift] = java ? 0.485 : 0.484
assert logout_request.send(:validate_not_on_or_after)

logout_request.options[:allowed_clock_drift] = '0.483'
assert !logout_request.send(:validate_not_on_or_after)

logout_request.options[:allowed_clock_drift] = '0.484'
logout_request.options[:allowed_clock_drift] = java ? '0.485' : '0.484'
assert logout_request.send(:validate_not_on_or_after)
end
end
Expand Down

0 comments on commit a35e8bc

Please sign in to comment.