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>
'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)
import mox
import uuid
import time
+import datetime
import eventlet
import unittest
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([