Make keystone tests work on leap years
A bunch of tests have to do with fast forwarding time to figure out what happens with expirations. That is done with a naive .replace on year. Which is fine, except on Feb 29th, because the python code does care if something is a valid datetime. Previously 2030 and 2031 were used as magic years. Neither is a leap year. Fast forwarding to that year on Feb 29th is a fatal python error. Narrowly fix this by using 2028 and 2032 instead. A better solution should probably be implemented long-term, but until this is landed keystone is blocked. Change-Id: If13e53bd5d4ace2a53a245d74166e4f3b1c34d4a Closes-Bug: #1551189
This commit is contained in:
parent
faf713e18a
commit
7c6556ce18
keystone/tests/unit
@ -5472,7 +5472,7 @@ class TrustTests(object):
|
||||
def create_sample_trust(self, new_id, remaining_uses=None):
|
||||
self.trustor = self.user_foo
|
||||
self.trustee = self.user_two
|
||||
expires_at = datetime.datetime.utcnow().replace(year=2031)
|
||||
expires_at = datetime.datetime.utcnow().replace(year=2032)
|
||||
trust_data = (self.trust_api.create_trust
|
||||
(new_id,
|
||||
{'trustor_user_id': self.trustor['id'],
|
||||
@ -5607,7 +5607,7 @@ class TrustTests(object):
|
||||
'trustee_user_id': self.user_two['id'],
|
||||
'project_id': self.tenant_bar['id'],
|
||||
'expires_at': timeutils.parse_isotime(
|
||||
'2031-02-18T18:10:00Z'),
|
||||
'2032-02-18T18:10:00Z'),
|
||||
'impersonation': True,
|
||||
'remaining_uses': None}
|
||||
roles = [{"id": "member"},
|
||||
|
@ -3316,7 +3316,7 @@ class TestTrustRedelegation(test_v3.RestfulTestCase):
|
||||
# Create first trust with extended set of roles
|
||||
ref = self.redelegated_trust_ref
|
||||
ref['expires_at'] = datetime.datetime.utcnow().replace(
|
||||
year=2031).strftime(unit.TIME_FORMAT)
|
||||
year=2032).strftime(unit.TIME_FORMAT)
|
||||
ref['roles'].append({'id': role['id']})
|
||||
r = self.post('/OS-TRUST/trusts',
|
||||
body={'trust': ref})
|
||||
@ -3330,7 +3330,7 @@ class TestTrustRedelegation(test_v3.RestfulTestCase):
|
||||
|
||||
# Chain second trust with roles subset
|
||||
self.chained_trust_ref['expires_at'] = (
|
||||
datetime.datetime.utcnow().replace(year=2030).strftime(
|
||||
datetime.datetime.utcnow().replace(year=2028).strftime(
|
||||
unit.TIME_FORMAT))
|
||||
r = self.post('/OS-TRUST/trusts',
|
||||
body={'trust': self.chained_trust_ref},
|
||||
@ -3353,7 +3353,7 @@ class TestTrustRedelegation(test_v3.RestfulTestCase):
|
||||
role_names=[self.role['name']],
|
||||
allow_redelegation=True)
|
||||
ref['expires_at'] = datetime.datetime.utcnow().replace(
|
||||
year=2031).strftime(unit.TIME_FORMAT)
|
||||
year=2032).strftime(unit.TIME_FORMAT)
|
||||
r = self.post('/OS-TRUST/trusts',
|
||||
body={'trust': ref})
|
||||
trust = self.assertValidTrustResponse(r)
|
||||
@ -3368,7 +3368,7 @@ class TestTrustRedelegation(test_v3.RestfulTestCase):
|
||||
role_names=[self.role['name']],
|
||||
allow_redelegation=True)
|
||||
ref['expires_at'] = datetime.datetime.utcnow().replace(
|
||||
year=2030).strftime(unit.TIME_FORMAT)
|
||||
year=2028).strftime(unit.TIME_FORMAT)
|
||||
r = self.post('/OS-TRUST/trusts',
|
||||
body={'trust': ref},
|
||||
token=trust_token)
|
||||
@ -3402,7 +3402,7 @@ class TestTrustRedelegation(test_v3.RestfulTestCase):
|
||||
|
||||
def test_redelegation_terminator(self):
|
||||
self.redelegated_trust_ref['expires_at'] = (
|
||||
datetime.datetime.utcnow().replace(year=2031).strftime(
|
||||
datetime.datetime.utcnow().replace(year=2032).strftime(
|
||||
unit.TIME_FORMAT))
|
||||
r = self.post('/OS-TRUST/trusts',
|
||||
body={'trust': self.redelegated_trust_ref})
|
||||
@ -3411,7 +3411,7 @@ class TestTrustRedelegation(test_v3.RestfulTestCase):
|
||||
|
||||
# Build second trust - the terminator
|
||||
self.chained_trust_ref['expires_at'] = (
|
||||
datetime.datetime.utcnow().replace(year=2030).strftime(
|
||||
datetime.datetime.utcnow().replace(year=2028).strftime(
|
||||
unit.TIME_FORMAT))
|
||||
ref = dict(self.chained_trust_ref,
|
||||
redelegation_count=1,
|
||||
|
@ -103,7 +103,7 @@ class TestTrustOperations(test_v3.RestfulTestCase):
|
||||
role_ids=[self.role_id])
|
||||
for i in range(3):
|
||||
ref['expires_at'] = datetime.datetime.utcnow().replace(
|
||||
year=2031).strftime(unit.TIME_FORMAT)
|
||||
year=2032).strftime(unit.TIME_FORMAT)
|
||||
r = self.post('/OS-TRUST/trusts', body={'trust': ref})
|
||||
self.assertValidTrustResponse(r, ref)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user