File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
ask-sdk-webservice-support
ask_sdk_webservice_support Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -432,6 +432,6 @@ def verify(
432432 """
433433 local_now = datetime .now (tz .tzutc ())
434434 request_timestamp = deserialized_request_env .request .timestamp
435- if (abs ((local_now - request_timestamp ).seconds ) >
435+ if (abs ((local_now - request_timestamp ).total_seconds () ) >
436436 (self ._tolerance_in_millis / 1000 )):
437437 raise VerificationException ("Timestamp verification failed" )
Original file line number Diff line number Diff line change @@ -396,6 +396,23 @@ def test_timestamp_verification_with_expired_timestamp(self):
396396
397397 self .assertIn ("Timestamp verification failed" , str (exc .exception ))
398398
399+ def test_timestamp_verification_with_valid_future_server_timestamp (self ):
400+ valid_tolerance = int (DEFAULT_TIMESTAMP_TOLERANCE_IN_MILLIS / 2 / 1000 )
401+ valid_future_datetime = datetime .now (tzutc ()) + timedelta (seconds = valid_tolerance )
402+ test_request_envelope = RequestEnvelope (
403+ request = IntentRequest (
404+ timestamp = valid_future_datetime ))
405+ self .timestamp_verifier = TimestampVerifier ()
406+ try :
407+ self .timestamp_verifier .verify (
408+ headers = {},
409+ serialized_request_env = "" ,
410+ deserialized_request_env = test_request_envelope )
411+ except :
412+ # Should never reach here
413+ raise self .fail (
414+ "Timestamp verification failed for a valid input request" )
415+
399416 def test_timestamp_verification_with_valid_timestamp (self ):
400417 test_request_envelope = RequestEnvelope (
401418 request = IntentRequest (
You can’t perform that action at this time.
0 commit comments