diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-07-15 18:03:51 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-07-15 18:03:51 +0000 |
| commit | 2329e0a8e5b1c1620aa9f84fd25188215ede896c (patch) | |
| tree | accced907b652f7f888881f7f195511fde37a9f6 /tests | |
| parent | f2ad113d1c65e94a3a9f4b1f53c9ab4b0dd01727 (diff) | |
| parent | 4f53f935a40ad0c90c02a02a56c18825a3d14bdb (diff) | |
| download | python-keystoneclient-2329e0a8e5b1c1620aa9f84fd25188215ede896c.tar.gz | |
Merge "Ec2Signer : Modify v4 signer to match latest boto"
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_ec2utils.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_ec2utils.py b/tests/test_ec2utils.py index 7e444ee..d343a36 100644 --- a/tests/test_ec2utils.py +++ b/tests/test_ec2utils.py @@ -143,3 +143,39 @@ class Ec2SignerTest(testtools.TestCase): expected = ('ced6826de92d2bdeed8f846f0bf508e8' '559e98e4b0199114b84c54174deb456c') self.assertEqual(signature, expected) + + def test_generate_v4_port(self): + """ + Test v4 generator with host:port format + """ + # Create a new signer object with the AWS example key + secret = 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY' + signer = Ec2Signer(secret) + + body_hash = ('b6359072c78d70ebee1e81adcbab4f0' + '1bf2c23245fa365ef83fe8f1f955085e2') + auth_str = ('AWS4-HMAC-SHA256 ' + 'Credential=AKIAIOSFODNN7EXAMPLE/20110909/' + 'us-east-1/iam/aws4_request,' + 'SignedHeaders=content-type;host;x-amz-date,') + headers = {'Content-type': + 'application/x-www-form-urlencoded; charset=utf-8', + 'X-Amz-Date': '20110909T233600Z', + 'Host': 'foo:8000', + 'Authorization': auth_str} + # Note the example in the AWS docs is inconsistent, previous + # examples specify no query string, but the final POST example + # does, apparently incorrectly since an empty parameter list + # aligns all steps and the final signature with the examples + params = {} + credentials = {'host': 'foo:8000', + 'verb': 'POST', + 'path': '/', + 'params': params, + 'headers': headers, + 'body_hash': body_hash} + signature = signer.generate(credentials) + + expected = ('26dd92ea79aaa49f533d13b1055acdc' + 'd7d7321460d64621f96cc79c4f4d4ab2b') + self.assertEqual(signature, expected) |
