Skip to content

Commit

Permalink
Honor --endpoint-url in s3/s3api commands
Browse files Browse the repository at this point in the history
Fixes aws#1142.

The issue was that the before-auth event was removed in the
internal botocore auth refactor (between 1.7.4-1.7.5), but
this handler was not updated.  I've added an integration
test that should catch this issue in the future.
  • Loading branch information
jamesls committed Feb 23, 2015
1 parent ee499af commit a1a6c0f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
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

0 comments on commit a1a6c0f

Please sign in to comment.