File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -515,7 +515,7 @@ def validate_session_expiration(soft = true)
515515 return true if session_expires_at . nil?
516516
517517 now = Time . now . utc
518- unless session_expires_at > ( now + allowed_clock_drift )
518+ unless ( session_expires_at + allowed_clock_drift ) > now
519519 error_msg = "The attributes have expired, based on the SessionNotOnOrAfter of the AttributeStatement of this Response"
520520 return append_error ( error_msg )
521521 end
Original file line number Diff line number Diff line change @@ -630,6 +630,18 @@ class RubySamlTest < Minitest::Test
630630 assert !response . send ( :validate_session_expiration )
631631 assert_includes response . errors , "The attributes have expired, based on the SessionNotOnOrAfter of the AttributeStatement of this Response"
632632 end
633+
634+ it "returns true when the session has expired, but is still within the allowed_clock_drift" do
635+ drift = ( Time . now - Time . parse ( "2010-11-19T21:57:37Z" ) ) * 60 # minutes ago that this assertion expired
636+ drift += 10 # add a buffer of 10 minutes to make sure the test passes
637+ opts = { }
638+ opts [ :allowed_clock_drift ] = drift
639+
640+ response_with_drift = OneLogin ::RubySaml ::Response . new ( response_document_without_recipient , opts )
641+ response_with_drift . settings = settings
642+ assert response_with_drift . send ( :validate_session_expiration )
643+ assert_empty response_with_drift . errors
644+ end
633645 end
634646
635647 describe "#validate_signature" do
You can’t perform that action at this time.
0 commit comments