diff --git a/requirements.txt b/requirements.txt index b0df18b29d..d2f13a5917 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ oslo.config>=5.2.0 # Apache-2.0 oslo.log>=3.36.0 # Apache-2.0 stestr>=1.0.0 # Apache-2.0 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 -oslo.utils>=4.7.0 # Apache-2.0 +oslo.utils>=7.0.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD PyYAML>=3.12 # MIT python-subunit>=1.0.0 # Apache-2.0/BSD diff --git a/tempest/lib/auth.py b/tempest/lib/auth.py index 8bdf98e5a6..12fffdb002 100644 --- a/tempest/lib/auth.py +++ b/tempest/lib/auth.py @@ -21,6 +21,7 @@ import re from urllib import parse as urlparse from oslo_log import log as logging +from oslo_utils import timeutils from tempest.lib import exceptions from tempest.lib.services.identity.v2 import token_client as json_v2id @@ -419,8 +420,7 @@ class KeystoneV2AuthProvider(KeystoneAuthProvider): def is_expired(self, auth_data): _, access = auth_data expiry = self._parse_expiry_time(access['token']['expires']) - return (expiry - self.token_expiry_threshold <= - datetime.datetime.utcnow()) + return (expiry - self.token_expiry_threshold <= timeutils.utcnow()) class KeystoneV3AuthProvider(KeystoneAuthProvider): @@ -595,8 +595,7 @@ class KeystoneV3AuthProvider(KeystoneAuthProvider): def is_expired(self, auth_data): _, access = auth_data expiry = self._parse_expiry_time(access['expires_at']) - return (expiry - self.token_expiry_threshold <= - datetime.datetime.utcnow()) + return (expiry - self.token_expiry_threshold <= timeutils.utcnow()) def is_identity_version_supported(identity_version): diff --git a/tempest/tests/lib/test_auth.py b/tempest/tests/lib/test_auth.py index 3edb122f02..4e5ec48aab 100644 --- a/tempest/tests/lib/test_auth.py +++ b/tempest/tests/lib/test_auth.py @@ -17,6 +17,7 @@ import copy import datetime import fixtures +from oslo_utils import timeutils import testtools from tempest.lib import auth @@ -509,15 +510,15 @@ class TestKeystoneV2AuthProvider(BaseAuthTestsSetUp): self._test_base_url_helper(expected, filters, ('token', auth_data)) def test_token_not_expired(self): - expiry_data = datetime.datetime.utcnow() + datetime.timedelta(days=1) + expiry_data = timeutils.utcnow() + datetime.timedelta(days=1) self._verify_expiry(expiry_data=expiry_data, should_be_expired=False) def test_token_expired(self): - expiry_data = datetime.datetime.utcnow() - datetime.timedelta(hours=1) + expiry_data = timeutils.utcnow() - datetime.timedelta(hours=1) self._verify_expiry(expiry_data=expiry_data, should_be_expired=True) def test_token_not_expired_to_be_renewed(self): - expiry_data = (datetime.datetime.utcnow() + + expiry_data = (timeutils.utcnow() + self.auth_provider.token_expiry_threshold / 2) self._verify_expiry(expiry_data=expiry_data, should_be_expired=True)