Skip to content

Commit edf4f45

Browse files
committed
more fixes
1 parent 12c62d0 commit edf4f45

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

lib/onelogin/ruby-saml/slo_logoutrequest.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,15 @@ def validate_version
186186
true
187187
end
188188

189-
# Validates the time. (If the logout request was initialized with the :allowed_clock_drift option, the timing validations are relaxed by the allowed_clock_drift value)
189+
# Validates the time. (If the logout request was initialized with the :allowed_clock_drift option,
190+
# the timing validations are relaxed by the allowed_clock_drift value)
190191
# If fails, the error is added to the errors array
191192
# @return [Boolean] True if satisfies the conditions, otherwise False if soft=True
192193
# @raise [ValidationError] if soft == false and validation fails
193194
#
194195
def validate_not_on_or_after
195196
now = Time.now.utc
197+
196198
if not_on_or_after && now >= (not_on_or_after + allowed_clock_drift)
197199
return append_error("Current time is on or after NotOnOrAfter (#{now} >= #{not_on_or_after}#{" + #{allowed_clock_drift.ceil}s" if allowed_clock_drift > 0})")
198200
end

test/slo_logoutrequest_test.rb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,35 @@ class RubySamlTest < Minitest::Test
214214
puts val.inspect
215215
puts val.nsec.inspect
216216

217-
logout_request.options[:allowed_clock_drift] = java ? 0.485 : 0.484
217+
puts 'r'
218+
puts (Time.now >= val).inspect
219+
puts (Time.now - val).inspect
220+
221+
logout_request.options[:allowed_clock_drift] = 0.484
218222
assert logout_request.send(:validate_not_on_or_after)
219223

224+
puts 'HERE2'
225+
puts Time.now.inspect
226+
puts Time.now.nsec.inspect
227+
228+
puts 'x'
229+
puts logout_request.send(:not_on_or_after).inspect
230+
puts logout_request.send(:not_on_or_after).nsec.inspect
231+
232+
puts 'y'
233+
puts logout_request.send(:allowed_clock_drift).inspect
234+
235+
puts 'z'
236+
val = logout_request.send(:not_on_or_after) + logout_request.send(:allowed_clock_drift)
237+
puts val.inspect
238+
puts val.nsec.inspect
239+
240+
puts 'r'
241+
puts (Time.now >= val).inspect
242+
puts (Time.now - val).inspect
243+
244+
245+
220246
logout_request.options[:allowed_clock_drift] = '0.483'
221247
assert !logout_request.send(:validate_not_on_or_after)
222248

0 commit comments

Comments
 (0)