Correct format for token expiration time

Tokens with expiration time limited by application credentials had an
incorrect format.

Fix the format, control it with the test.

Closes-Bug: 2075723
Change-Id: I09fe34541615090766a5c4a010a3f39756debedc
This commit is contained in:
Boris Bobrov 2024-08-02 15:16:10 +02:00
parent f0352c5481
commit d01cde5a19
No known key found for this signature in database
GPG Key ID: CBA1365439F35844
2 changed files with 5 additions and 2 deletions

View File

@ -6411,6 +6411,7 @@ class ApplicationCredentialAuth(test_v3.RestfulTestCase):
resp = self.v3_create_token(
auth_data, expected_status=http.client.CREATED
)
self.assertValidTokenResponse(resp)
token = resp.headers.get('X-Subject-Token')
future = datetime.datetime.utcnow() + datetime.timedelta(minutes=2)
with freezegun.freeze_time(future):

View File

@ -316,11 +316,13 @@ class Manager(manager.Manager):
if (app_cred['expires_at'] is not None) and (
token_time > app_cred['expires_at']
):
token.expires_at = app_cred['expires_at'].isoformat()
token.expires_at = utils.isotime(
app_cred['expires_at'], subsecond=True
)
LOG.debug(
'Resetting token expiration to the application'
' credential expiration: %s',
app_cred['expires_at'].isoformat(),
token.expires_at,
)
token_id, issued_at = self.driver.generate_id_and_issued_at(token)