From 2ed43259e524a64c2a799864b429233a6edff41b Mon Sep 17 00:00:00 2001 From: James Saryerwinnie Date: Thu, 5 Jun 2014 10:40:11 -0700 Subject: [PATCH] Fix auth bug with S3 in cn-north-1 region --- botocore/auth.py | 2 +- tests/unit/auth/test_signers.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/botocore/auth.py b/botocore/auth.py index 194535f2aa..8b6224b93b 100644 --- a/botocore/auth.py +++ b/botocore/auth.py @@ -330,7 +330,7 @@ def _modify_request_before_signing(self, request): class S3SigV4Auth(SigV4Auth): def _modify_request_before_signing(self, request): - super(S3SigV4Auth, self)._add_headers_before_signing(request) + super(S3SigV4Auth, self)._modify_request_before_signing(request) request.headers['X-Amz-Content-SHA256'] = self.payload(request) def _normalize_url_path(self, path): diff --git a/tests/unit/auth/test_signers.py b/tests/unit/auth/test_signers.py index 8e4b3edf5a..66ee636645 100644 --- a/tests/unit/auth/test_signers.py +++ b/tests/unit/auth/test_signers.py @@ -124,6 +124,19 @@ def test_signature_with_date_headers(self): 'Signature=M245fo86nVKI8rLpH4HgWs841sBTUKuwciiTpjMDgPs=')) +class TestS3SigV4Auth(unittest.TestCase): + def test_signature_is_not_normalized(self): + request = AWSRequest() + request.url = 'https://s3.amazonaws.com/bucket/foo/./bar/../bar' + request.method = 'GET' + credentials = botocore.credentials.Credentials('access_key', + 'secret_key') + auth = botocore.auth.S3SigV4Auth(credentials, 's3', 'us-east-1') + auth.add_auth(request) + self.assertTrue( + request.headers['Authorization'].startswith('AWS4-HMAC-SHA256')) + + class TestSigV4Presign(unittest.TestCase): maxDiff = None