summarylogtreecommitdiffstats
path: root/aws-cli-v2-tz-fix.patch
blob: a9db045ce2c2c696ecda8c0a919d2b1be80b8d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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):