]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat engine : WaitConditionHandle use creation time for timestamp
authorSteven Hardy <shardy@redhat.com>
Tue, 29 Jan 2013 18:20:04 +0000 (18:20 +0000)
committerSteven Hardy <shardy@redhat.com>
Thu, 31 Jan 2013 10:28:47 +0000 (10:28 +0000)
Use the resource creation time for the pre-signed URL timestamp,
otherwise you get a different timestamp/signature every time you
refer to the resource, which makes things like comparing templates
for update more difficult.

Change-Id: Ieb4a6269cfcaf1214c08442db03772fdd7570d59
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/engine/resources/wait_condition.py
heat/tests/test_waitcondition.py

index a88b08c0fbd0d9693d45b976e83525ba9340e29f..373ea1e917c2e81ba75240ccc7fa6139844269a8 100644 (file)
@@ -72,8 +72,9 @@ class WaitConditionHandle(resource.Resource):
                    'params': {'SignatureMethod': 'HmacSHA256',
                               'SignatureVersion': '2',
                               'AWSAccessKeyId': credentials.access,
-                              'Timestamp': time.strftime("%Y-%m-%dT%H:%M:%SZ",
-                                                         time.gmtime())}}
+                              'Timestamp':
+                              self.created_time.strftime("%Y-%m-%dT%H:%M:%SZ")
+                              }}
         # Sign the request
         signer = Ec2Signer(credentials.secret)
         request['params']['Signature'] = signer.generate(request)
index 36fdc080167f90e77994c62281f1c1f79fab5752..1a4ea000e5bbe6b1b15a92a77f374f8a6ebba8d3 100644 (file)
@@ -16,6 +16,7 @@
 import mox
 import uuid
 import time
+import datetime
 
 import eventlet
 import unittest
@@ -299,13 +300,10 @@ class WaitConditionHandleTest(unittest.TestCase):
         return stack
 
     def test_handle(self):
-        # Stub time to a fixed value so we can get an expected signature
-        t = time.gmtime(1354196977)
-        self.m.StubOutWithMock(time, 'gmtime')
-        time.gmtime().MultipleTimes().AndReturn(t)
-        self.m.ReplayAll()
+        created_time = datetime.datetime(2012, 11, 29, 13, 49, 37)
 
         resource = self.stack.resources['WaitHandle']
+        resource.created_time = created_time
         self.assertEqual(resource.state, 'CREATE_COMPLETE')
 
         expected_url = "".join([