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

Honor --endpoint-url in s3/s3api commands #1172

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion awscli/customizations/s3endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def on_top_level_args_parsed(parsed_args, event_handler, **kwargs):
# is disabled.
if parsed_args.command in ['s3', 's3api'] and \
parsed_args.endpoint_url is not None:
event_handler.unregister('before-auth.s3', fix_s3_host)
event_handler.unregister('before-sign.s3', fix_s3_host)
20 changes: 20 additions & 0 deletions tests/integration/customizations/s3/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,5 +1636,25 @@ def test_no_sign_request(self):
self.assert_no_errors(p)


class TestHonorsEndpointUrl(BaseS3CLICommand):
def test_verify_endpoint_url_is_used(self):
# We're going to verify this indirectly by looking at the
# debug logs. The endpoint url we specify should be in the
# debug logs, and the endpoint url that botocore would have
# used if we didn't provide the endpoint-url should not
# be in the debug logs. The other alternative is to actually
# watch what connetions are made in the process, which is not
# easy.
p = aws('s3 ls s3://dnscompat/ '
'--endpoint-url http://localhost:51515 '
'--debug')
debug_logs = p.stderr
original_hostname = 'dnscompat.s3.amazonaws.com'
expected = 'localhost'
self.assertNotIn(original_hostname, debug_logs,
'--endpoint-url is being ignored in s3 commands.')
self.assertIn(expected, debug_logs)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion tests/unit/customizations/test_s3endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_endpoint_url_unregisters_fix_s3_host(self):
args.command = 's3'
event_handler = mock.Mock()
on_top_level_args_parsed(args, event_handler)
event_handler.unregister.assert_called_with('before-auth.s3', fix_s3_host)
event_handler.unregister.assert_called_with('before-sign.s3', fix_s3_host)

def test_unregister_not_called_for_no_endpoint(self):
args = mock.Mock()
Expand Down