From 95aa5ccc7bfaeafc0373e8472c8459030ac18920 Mon Sep 17 00:00:00 2001
From: Avimitin <dev@avimit.in>
Date: Tue, 21 Mar 2023 12:36:48 +0800
Subject: [PATCH] Force timezone info to fix possible test failure

This commit will affects the test
`test_credentials.py::SSOSessionTest::test_token_chosen_from_provider`.
This test will throw a `RuntimeError: Credentials were refreshed, but
the refreshed credentials are still expired` because the timestamp call
uses system local time, which is different from UTC time. And this will
cause an unexpected failure if the test is not run in a system configured
with `TZ=UTC`.

Signed-off-by: Avimitin <dev@avimit.in>
---
 tests/functional/botocore/test_credentials.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/functional/botocore/test_credentials.py b/tests/functional/botocore/test_credentials.py
index 843be90e484..9da9bf2b443 100644
--- a/tests/functional/botocore/test_credentials.py
+++ b/tests/functional/botocore/test_credentials.py
@@ -19,7 +19,7 @@
 import mock
 import tempfile
 import shutil
-from datetime import datetime, timedelta
+from datetime import datetime, timedelta, timezone
 import sys
 
 import pytest
@@ -47,8 +47,8 @@
 from botocore.tokens import SSOTokenProvider
 from botocore.utils import datetime2timestamp
 
-TIME_IN_ONE_HOUR = datetime.utcnow() + timedelta(hours=1)
-TIME_IN_SIX_MONTHS = datetime.utcnow() + timedelta(hours=4320)
+TIME_IN_ONE_HOUR = datetime.now(tz=timezone.utc) + timedelta(hours=1)
+TIME_IN_SIX_MONTHS = datetime.now(tz=timezone.utc) + timedelta(hours=4320)
 
 
 class TestCredentialRefreshRaces(unittest.TestCase):
