Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back support for sigv4 overrides #382

Merged
merged 1 commit into from
Nov 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion botocore/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ def signature_overrides(service_data, service_name, session, **kwargs):
logger.debug("Switching signature version for service %s "
"to version %s based on config file override.",
service_name, signature_version_override)
service_data['signature_version'] = signature_version_override
service_metadata = service_data['metadata']
service_metadata['signatureVersion'] = signature_version_override


def add_expect_header(model, params, **kwargs):
Expand Down
21 changes: 21 additions & 0 deletions tests/integration/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,5 +560,26 @@ def test_can_get_bucket_location(self):
self.assertEqual(response[1]['LocationConstraint'], 'eu-central-1')


class TestCanSwitchToSigV4(unittest.TestCase):
def setUp(self):
self.session = botocore.session.get_session()

def test_verify_can_switch_sigv4(self):
self.session.set_config_variable('s3', {'signature_version': 's3v4'})
# We need to verify this option for service/operation objects so we're
# not using client objects now (though we should add a test for client
# objects eventually).
service = self.session.get_service('s3')
endpoint = service.get_endpoint('us-east-1')
# The set_config_variable should ensure that we use sigv4 for s3.
self.assertIsInstance(endpoint.auth, botocore.auth.S3SigV4Auth)

# And just to be sure, we'll go ahead and make a basic S3
# call and verify it works with sigv4.
operation = service.get_operation('ListBuckets')
http, response = operation.call(endpoint)
self.assertEqual(http.status_code, 200)


if __name__ == '__main__':
unittest.main()
12 changes: 8 additions & 4 deletions tests/unit/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,23 @@ def test_switch_to_sigv4(self):
mock_session.get_scoped_config.return_value = {
's3': {'signature_version': 's3v4'}
}
kwargs = {'service_data': {'signature_version': 's3'},
kwargs = {'service_data': {'metadata': {'signatureVersion': 's3'}},
'service_name': 's3', 'session': mock_session}
self.session.emit(event, **kwargs)
self.assertEqual(kwargs['service_data']['signature_version'], 's3v4')
self.assertEqual(
kwargs['service_data']['metadata']['signatureVersion'],
's3v4')

def test_noswitch_to_sigv4(self):
event = self.session.create_event('service-data-loaded', 's3')
mock_session = mock.Mock()
mock_session.get_scoped_config.return_value = {}
kwargs = {'service_data': {'signature_version': 's3'},
kwargs = {'service_data': {'metadata': {'signatureVersion': 's3'}},
'service_name': 's3', 'session': mock_session}
self.session.emit(event, **kwargs)
self.assertEqual(kwargs['service_data']['signature_version'], 's3')
self.assertEqual(
kwargs['service_data']['metadata']['signatureVersion'],
's3')

def test_quote_source_header(self):
for op in ('UploadPartCopy', 'CopyObject'):
Expand Down