Skip to content

Commit 3c8a754

Browse files
authored
Merge pull request SAML-Toolkits#471 from stavros-wb/cast_allowed_clock_drift
Allow for `allowed_clock_drift` to be set as a string
2 parents 937a826 + 73e43a9 commit 3c8a754

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

lib/onelogin/ruby-saml/response.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ def audiences
338338
# returns the allowed clock drift on timing validation
339339
# @return [Integer]
340340
def allowed_clock_drift
341-
return options[:allowed_clock_drift] || 0
341+
return options[:allowed_clock_drift].to_f
342342
end
343343

344344
private

test/response_test.rb

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,15 +633,15 @@ def generate_audience_error(expected, actual)
633633
:skip_conditions => true,
634634
:skip_subject_confirmation => true })
635635
}
636-
636+
637637
it "be able to parse the response wihout errors" do
638638
response_with_formatted_x509certificate.settings = settings
639-
response_with_formatted_x509certificate.settings.idp_cert = ruby_saml_cert_text
639+
response_with_formatted_x509certificate.settings.idp_cert = ruby_saml_cert_text
640640
assert response_with_formatted_x509certificate.is_valid?
641641
assert_empty response_with_formatted_x509certificate.errors
642642
end
643643
end
644-
644+
645645
describe "#validate_in_response_to" do
646646
it "return true when the inResponseTo value matches the Request ID" do
647647
response = OneLogin::RubySaml::Response.new(response_document_valid_signed, :settings => settings, :matches_request_id => "_fc4a34b0-7efb-012e-caae-782bcb13bb38")
@@ -1072,6 +1072,24 @@ def generate_audience_error(expected, actual)
10721072
)
10731073
assert special_response_with_saml2_namespace.send(:validate_conditions)
10741074
end
1075+
1076+
Timecop.freeze(Time.parse("2011-06-14T18:21:01Z")) do
1077+
settings.soft = true
1078+
special_response_with_saml2_namespace = OneLogin::RubySaml::Response.new(
1079+
response_document_with_saml2_namespace,
1080+
:allowed_clock_drift => '0.515',
1081+
:settings => settings
1082+
)
1083+
assert !special_response_with_saml2_namespace.send(:validate_conditions)
1084+
end
1085+
1086+
Timecop.freeze(Time.parse("2011-06-14T18:21:01Z")) do
1087+
special_response_with_saml2_namespace = OneLogin::RubySaml::Response.new(
1088+
response_document_with_saml2_namespace,
1089+
:allowed_clock_drift => '0.516'
1090+
)
1091+
assert special_response_with_saml2_namespace.send(:validate_conditions)
1092+
end
10751093
end
10761094
end
10771095

0 commit comments

Comments
 (0)