format token expires time to prevent json loading datetime data
When output to shell, the token issue time is fine; however when selecting the json formatter (via the --format json) option, an exception is raised when formatting the dataetime data. Rather than pass in the datetime data, we should format the data with the ISO 8601 formatting. Closes-Bug: 1619937 Change-Id: Iffebb2d5413fabfd283dfa94fc560fc37270f9dd
This commit is contained in:
parent
3b75c9aae5
commit
24c8b94baf
@ -42,7 +42,9 @@ class IssueToken(command.ShowOne):
|
||||
if auth_ref.auth_token:
|
||||
data['id'] = auth_ref.auth_token
|
||||
if auth_ref.expires:
|
||||
data['expires'] = auth_ref.expires
|
||||
datetime_obj = auth_ref.expires
|
||||
expires_str = datetime_obj.strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||
data['expires'] = expires_str
|
||||
if auth_ref.project_id:
|
||||
data['project_id'] = auth_ref.project_id
|
||||
if auth_ref.user_id:
|
||||
|
@ -183,7 +183,9 @@ class IssueToken(command.ShowOne):
|
||||
if auth_ref.auth_token:
|
||||
data['id'] = auth_ref.auth_token
|
||||
if auth_ref.expires:
|
||||
data['expires'] = auth_ref.expires
|
||||
datetime_obj = auth_ref.expires
|
||||
expires_str = datetime_obj.strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||
data['expires'] = expires_str
|
||||
if auth_ref.project_id:
|
||||
data['project_id'] = auth_ref.project_id
|
||||
if auth_ref.user_id:
|
||||
|
@ -80,7 +80,7 @@ USER = {
|
||||
'enabled': True,
|
||||
}
|
||||
|
||||
token_expires = '2014-01-01T00:00:00Z'
|
||||
token_expires = '2016-09-05T18:04:52+0000'
|
||||
token_id = 'token-id-' + uuid.uuid4().hex
|
||||
|
||||
TOKEN = {
|
||||
|
@ -58,7 +58,7 @@ class TestTokenIssue(TestToken):
|
||||
collist = ('expires', 'id', 'project_id', 'user_id')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
auth_ref.expires,
|
||||
identity_fakes.token_expires,
|
||||
identity_fakes.token_id,
|
||||
'project-id',
|
||||
'user-id',
|
||||
@ -86,7 +86,7 @@ class TestTokenIssue(TestToken):
|
||||
)
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
auth_ref.expires,
|
||||
identity_fakes.token_expires,
|
||||
identity_fakes.token_id,
|
||||
'user-id',
|
||||
)
|
||||
|
@ -252,7 +252,7 @@ TRUST = {
|
||||
'trustor_user_id': user_id,
|
||||
}
|
||||
|
||||
token_expires = '2014-01-01T00:00:00Z'
|
||||
token_expires = '2016-09-05T18:04:52+0000'
|
||||
token_id = 'tttttttt-tttt-tttt-tttt-tttttttttttt'
|
||||
|
||||
UNSCOPED_TOKEN = {
|
||||
|
@ -55,7 +55,7 @@ class TestTokenIssue(TestToken):
|
||||
collist = ('expires', 'id', 'project_id', 'user_id')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
auth_ref.expires,
|
||||
identity_fakes.token_expires,
|
||||
identity_fakes.token_id,
|
||||
identity_fakes.project_id,
|
||||
identity_fakes.user_id,
|
||||
@ -82,7 +82,7 @@ class TestTokenIssue(TestToken):
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
identity_fakes.domain_id,
|
||||
auth_ref.expires,
|
||||
identity_fakes.token_expires,
|
||||
identity_fakes.token_id,
|
||||
identity_fakes.user_id,
|
||||
)
|
||||
@ -109,7 +109,7 @@ class TestTokenIssue(TestToken):
|
||||
)
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
auth_ref.expires,
|
||||
identity_fakes.token_expires,
|
||||
identity_fakes.token_id,
|
||||
identity_fakes.user_id,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user