summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2012-01-25 10:48:08 -0600
committerDolph Mathews <dolph.mathews@gmail.com>2012-01-25 10:48:08 -0600
commit2e73dface4258c6d2d796d23ce95357e1093027c (patch)
tree2d8a926005ed2323ae5edaf733fd74e1074dde4e
parentd1a3c5fa96928b05c3ecdbd8fa5be4bd12fb33ff (diff)
downloadkeystone-2e73dface4258c6d2d796d23ce95357e1093027c.tar.gz
keystone-2e73dface4258c6d2d796d23ce95357e1093027c.tar.xz
keystone-2e73dface4258c6d2d796d23ce95357e1093027c.zip
Documented race condition (bug 921634)
Change-Id: I6db4035c0b2067f309407232959091245e80e290
-rw-r--r--keystone/test/unit/test_commands.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/keystone/test/unit/test_commands.py b/keystone/test/unit/test_commands.py
index 3b099c65..2c498116 100644
--- a/keystone/test/unit/test_commands.py
+++ b/keystone/test/unit/test_commands.py
@@ -818,6 +818,20 @@ class TestDeleteServiceCommand(CommandTestCase):
class TestCreateTokenCommand(CommandTestCase):
+ """Creates tokens and validates their attributes.
+
+ This class has a known potential race condition, due to the expected
+ token expiration being 24 hours after token creation. If the
+ 'create_token' command runs immediately before the minute rolls over,
+ and the test class produces a timestamp for the subsequent minute, the
+ test will fail.
+
+ """
+
+ @staticmethod
+ def _get_tomorrow_str():
+ return (datetime.datetime.utcnow() +
+ datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M')
def test_no_args(self):
with self.assertRaises(SystemExit):
@@ -827,8 +841,7 @@ class TestCreateTokenCommand(CommandTestCase):
user_id = self._create_user()
self.run_cmd(create_token, [
'--user-id', user_id])
- tomorrow = (datetime.datetime.utcnow() +
- datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M')
+ tomorrow = TestCreateTokenCommand._get_tomorrow_str()
token_id = self.ob.read_lines()[0]
self.assertEqual(len(token_id), 32)
@@ -844,8 +857,7 @@ class TestCreateTokenCommand(CommandTestCase):
self.run_cmd(create_token, [
'--user-id', user_id,
'--tenant-id', tenant_id])
- tomorrow = (datetime.datetime.utcnow() +
- datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M')
+ tomorrow = TestCreateTokenCommand._get_tomorrow_str()
token_id = self.ob.read_lines()[0]
self.assertEqual(len(token_id), 32)
@@ -876,8 +888,7 @@ class TestCreateTokenCommand(CommandTestCase):
self.run_cmd(create_token, [
'--id', token_id,
'--user-id', user_id])
- tomorrow = (datetime.datetime.utcnow() +
- datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M')
+ tomorrow = TestCreateTokenCommand._get_tomorrow_str()
self.assertEqual(token_id, self.ob.read_lines()[0])
self.ob.clear()