summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard M. Wiedemann <bwiedemann@suse.de>2019-05-08 14:00:26 +0200
committerguang-yee <gyee@suse.com>2020-01-08 19:18:00 +0000
commit8b5202e730b5294b3420b7b64a62100f5309cc3e (patch)
tree95b1c4fd1e4a13064baccc601b8125bc8d827c50
parentbc03de9ca412805490a39dfbd00b4f938e64895b (diff)
downloadkeystonemiddleware-8b5202e730b5294b3420b7b64a62100f5309cc3e.tar.gz
Make tests pass in 2022
Background: As part of my work on reproducible builds for openSUSE, I check that software still gives identical build results in the future. The usual offset is +15 years, because that is how long I expect some software will be used in some places. This showed up failing tests in our package build. See https://reproducible-builds.org/ for why this matters. This makes it expire 1 year in the future to model realistic tokens. NOTE: in addition to the orginal backport, this patch adds the following changes. The changes has to be combined into a single patch in order to avoid circular dependencies. 1. fixed the hadcoded token expiration date in keystonemiddleware/tests/unit/client_fixtures.py. This is using the same technique in the original backport. 2. fixed bandit complains in keystonemiddleware/auth_token/_request.py. The request environment variable names are not tokens. We'll need to mark them as false positives so bandit can stop chirping. Change-Id: I73bde68be53afff4e8dff12d756b8381f34b2adb (cherry picked from commit 4a4c96ce9b28ed54f93a21ca405c5b34ef3c3429)
-rw-r--r--keystonemiddleware/auth_token/_request.py4
-rw-r--r--keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py3
-rw-r--r--keystonemiddleware/tests/unit/client_fixtures.py4
3 files changed, 7 insertions, 4 deletions
diff --git a/keystonemiddleware/auth_token/_request.py b/keystonemiddleware/auth_token/_request.py
index 26037a2..3edd3f4 100644
--- a/keystonemiddleware/auth_token/_request.py
+++ b/keystonemiddleware/auth_token/_request.py
@@ -97,8 +97,8 @@ class _AuthTokenRequest(webob.Request):
_ADMIN_PROJECT_HEADER = 'X-Is-Admin-Project'
_SERVICE_CATALOG_HEADER = 'X-Service-Catalog'
- _TOKEN_AUTH = 'keystone.token_auth'
- _TOKEN_INFO = 'keystone.token_info'
+ _TOKEN_AUTH = 'keystone.token_auth' # nosec
+ _TOKEN_INFO = 'keystone.token_info' # nosec
_CONFIRMED = 'Confirmed'
_INVALID = 'Invalid'
diff --git a/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py b/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py
index 5c59d14..9150aef 100644
--- a/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py
+++ b/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py
@@ -92,7 +92,8 @@ BASE_URI = '%s/testadmin' % BASE_HOST
FAKE_ADMIN_TOKEN_ID = 'admin_token2'
FAKE_ADMIN_TOKEN = jsonutils.dumps(
{'access': {'token': {'id': FAKE_ADMIN_TOKEN_ID,
- 'expires': '2022-10-03T16:58:01Z'}}})
+ 'expires': '%i-10-03T16:58:01Z' %
+ (1 + time.gmtime().tm_year)}}})
VERSION_LIST_v3 = fixture.DiscoveryList(href=BASE_URI)
VERSION_LIST_v2 = fixture.DiscoveryList(v3=False, href=BASE_URI)
diff --git a/keystonemiddleware/tests/unit/client_fixtures.py b/keystonemiddleware/tests/unit/client_fixtures.py
index fe199fc..e2cd9fd 100644
--- a/keystonemiddleware/tests/unit/client_fixtures.py
+++ b/keystonemiddleware/tests/unit/client_fixtures.py
@@ -13,6 +13,7 @@
# under the License.
import os
+import time
import uuid
import fixtures
@@ -261,7 +262,8 @@ class Examples(fixtures.Fixture):
'access': {
'token': {
'id': self.VALID_DIABLO_TOKEN,
- 'expires': '2020-01-01T00:00:10.000123Z',
+ 'expires': '%i-01-01T00:00:10.000123Z' %
+ (1 + time.gmtime().tm_year),
'tenantId': PROJECT_ID,
},
'user': {