diff options
| author | MotoKen <motokentsai@gmail.com> | 2013-03-20 13:46:42 +0800 |
|---|---|---|
| committer | MotoKen <motokentsai@gmail.com> | 2013-03-29 10:53:44 +0800 |
| commit | 69e940c661731c8ac3cc0cf4e874929c86dcdeb2 (patch) | |
| tree | 1984c5de665fe5bc18c8fb45ce47d2511bab9864 /nova/tests | |
| parent | befef9ab1d497c42de60afa70f07b67b28350c3d (diff) | |
Accepts aws-sdk-java timestamp format
The aws-sdk-java timestamp format is "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
which contains millisecond representation. However, the current
implementation does not accept this kind of format.
References:
https://github.com/aws/aws-sdk-java/blob/master/src/main/java/com/amazonaws/auth/QueryStringSigner.java#L173
Adds ability to parse this format in ec2utils.is_ec2_timestamp_expired.
Fixes bug 1156445.
Change-Id: I389ff8b9c6c91b699538b889add264d66dbb8131
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/ec2/test_ec2_validate.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/nova/tests/api/ec2/test_ec2_validate.py b/nova/tests/api/ec2/test_ec2_validate.py index 24d226335..9b67d67a1 100644 --- a/nova/tests/api/ec2/test_ec2_validate.py +++ b/nova/tests/api/ec2/test_ec2_validate.py @@ -194,6 +194,25 @@ class EC2TimestampValidationTestCase(test.TestCase): expired = ec2utils.is_ec2_timestamp_expired(params) self.assertFalse(expired) + def test_validate_ec2_timestamp_ms_time_regex(self): + result = ec2utils._ms_time_regex.match('2011-04-22T11:29:49.123Z') + self.assertIsNotNone(result) + result = ec2utils._ms_time_regex.match('2011-04-22T11:29:49.123456Z') + self.assertIsNotNone(result) + result = ec2utils._ms_time_regex.match('2011-04-22T11:29:49.1234567Z') + self.assertIsNone(result) + result = ec2utils._ms_time_regex.match('2011-04-22T11:29:49.123') + self.assertIsNone(result) + result = ec2utils._ms_time_regex.match('2011-04-22T11:29:49Z') + self.assertIsNone(result) + + def test_validate_ec2_timestamp_aws_sdk_format(self): + params = {'Timestamp': '2011-04-22T11:29:49.123Z'} + expired = ec2utils.is_ec2_timestamp_expired(params) + self.assertFalse(expired) + expired = ec2utils.is_ec2_timestamp_expired(params, expires=300) + self.assertTrue(expired) + def test_validate_ec2_timestamp_invalid_format(self): params = {'Timestamp': '2011-04-22T11:29:49.000P'} expired = ec2utils.is_ec2_timestamp_expired(params) |
