txaws-dev team mailing list archive
-
txaws-dev team
-
Mailing list archive
-
Message #00010
[Merge] lp:~bjornt/txaws/allow-expires-bug-633580 into lp:txaws
Björn Tillenius has proposed merging lp:~bjornt/txaws/allow-expires-bug-633580 into lp:txaws.
Requested reviews:
txAWS Developers (txaws-dev)
Related bugs:
#633580 Can't use Expires parameter
https://bugs.launchpad.net/bugs/633580
Allow Expires to be passed as a parameter in EC2 request. If Expires is
passed, a Timestamp parameter shouldn't be automatically added.
--
https://code.launchpad.net/~bjornt/txaws/allow-expires-bug-633580/+merge/34929
Your team txAWS Developers is requested to review the proposed merge of lp:~bjornt/txaws/allow-expires-bug-633580 into lp:txaws.
=== modified file 'txaws/ec2/client.py'
--- txaws/ec2/client.py 2010-07-20 10:15:48 +0000
+++ txaws/ec2/client.py 2010-09-08 22:06:45 +0000
@@ -767,8 +767,11 @@
"SignatureVersion": "2",
"Action": self.action,
"AWSAccessKeyId": self.creds.access_key,
- "Timestamp": iso8601time(time_tuple),
}
+ if other_params is None or "Expires" not in other_params:
+ # Only add a Timestamp parameter, if Expires isn't used,
+ # since both can't be used in the same request.
+ self.params["Timestamp"] = iso8601time(time_tuple)
if other_params:
self.params.update(other_params)
=== modified file 'txaws/ec2/tests/test_client.py'
--- txaws/ec2/tests/test_client.py 2010-07-20 10:15:48 +0000
+++ txaws/ec2/tests/test_client.py 2010-09-08 22:06:45 +0000
@@ -1471,6 +1471,24 @@
"Timestamp": "2007-11-12T13:14:15Z",
"Version": "2008-12-01"})
+ def test_no_timestamp_if_expires_in_other_params(self):
+ """
+ If Expires is present in other_params, Timestamp won't be added,
+ since a request should contain either Expires or Timestamp, but
+ not both.
+ """
+ query = client.Query(
+ action="DescribeInstances", creds=self.creds,
+ endpoint=self.endpoint,
+ other_params={"Expires": "2007-11-12T13:14:15Z"})
+ self.assertEqual(
+ query.params,
+ {"AWSAccessKeyId": "foo",
+ "Action": "DescribeInstances",
+ "SignatureVersion": "2",
+ "Expires": "2007-11-12T13:14:15Z",
+ "Version": "2008-12-01"})
+
def test_sorted_params(self):
query = client.Query(
action="DescribeInstances", creds=self.creds,