diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-12-13 22:41:02 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-12-13 22:41:02 +0000 |
| commit | d1e7f796bf43b840983266f8510a7e6ed4dce415 (patch) | |
| tree | 8570afe91ebb51f3ec8aabc4bb8c116688fdaecb /nova | |
| parent | b7b578ff8c81e736ae3e6a1a3241e35ae7d7a941 (diff) | |
| parent | 2ce5fee0d6cc3244db11670379fd7938119919ed (diff) | |
Merge "Remove sleep in test_consoleauth."
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/tests/consoleauth/test_consoleauth.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/nova/tests/consoleauth/test_consoleauth.py b/nova/tests/consoleauth/test_consoleauth.py index 9c6368b4c..1490028ca 100644 --- a/nova/tests/consoleauth/test_consoleauth.py +++ b/nova/tests/consoleauth/test_consoleauth.py @@ -20,16 +20,27 @@ Tests for Consoleauth Code. """ +import fixtures import time from nova.consoleauth import manager from nova import context from nova.openstack.common import log as logging +from nova.openstack.common import timeutils from nova import test LOG = logging.getLogger(__name__) +class TimeOverride(fixtures.Fixture): + """Fixture to start and remove time override.""" + + def setUp(self): + super(TimeOverride, self).setUp() + timeutils.set_time_override() + self.addCleanup(timeutils.clear_time_override) + + class ConsoleauthTestCase(test.TestCase): """Test Case for consoleauth.""" @@ -40,10 +51,11 @@ class ConsoleauthTestCase(test.TestCase): def test_tokens_expire(self): """Test that tokens expire correctly.""" + self.useFixture(TimeOverride()) token = 'mytok' self.flags(console_token_ttl=1) self.manager.authorize_console(self.context, token, 'novnc', '127.0.0.1', 'host', '') self.assertTrue(self.manager.check_token(self.context, token)) - time.sleep(1.1) + timeutils.advance_time_seconds(1) self.assertFalse(self.manager.check_token(self.context, token)) |
