Skip to content

Instantly share code, notes, and snippets.

@notmyname
Created March 12, 2014 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notmyname/5333c625ed976ebf6d58 to your computer and use it in GitHub Desktop.
Save notmyname/5333c625ed976ebf6d58 to your computer and use it in GitHub Desktop.
diff --git a/tempest/api/object_storage/test_object_temp_url_negative.py b/tempest/api/object_storage/test_object_temp_url_negative.py
index cf24f66..691553c 100644
--- a/tempest/api/object_storage/test_object_temp_url_negative.py
+++ b/tempest/api/object_storage/test_object_temp_url_negative.py
@@ -70,9 +70,6 @@ class ObjectTempUrlNegativeTest(base.BaseObjectTest):
self.object_client.create_object(self.container_name,
self.object_name, self.data)
- def _get_expiry_date(self, expiration_time=1000):
- return int(time.time() + expiration_time)
-
def _get_temp_url(self, container, object_name, method, expires,
key):
"""Create the temporary URL."""
@@ -94,14 +91,19 @@ class ObjectTempUrlNegativeTest(base.BaseObjectTest):
@test.requires_ext(extension='tempurl', service='object')
def test_get_object_after_expiration_time(self):
- expires = self._get_expiry_date(1)
+ test_timeout = time.time() + 20
+ expires = int(time.time() + 1.0)
# get a temp URL for the created object
url = self._get_temp_url(self.container_name,
self.object_name, "GET",
expires, self.key)
- # temp URL is valid for 1 seconds, let's wait 2
- time.sleep(2)
-
- self.assertRaises(exceptions.Unauthorized,
- self.object_client.get, url)
+ passed = False
+ while time.time() < test_timeout:
+ try:
+ self.object_client.get(url)
+ except exceptions.Unauthorized:
+ passed = True # expected value
+ break
+ if not passed:
+ self.assertTrue(False, 'Failed to expire the object in 20 seconds')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment