Skip to content

Commit

Permalink
Merge branch 's3-endpoint-fix2' into develop
Browse files Browse the repository at this point in the history
Closes #1172.

* s3-endpoint-fix2:
  Add #1172 to the changelog
  Honor --endpoint-url in s3/s3api commands
  • Loading branch information
jamesls committed Feb 23, 2015
2 parents 12c8669 + 043d5a9 commit 9144714
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Next Release (TBD)
command is always a recursive operation meaning the inclusion or
exclusion of ``--recursive`` had no effect on the ``sync`` command.
(`issue 1171 <https://github.com/aws/aws-cli/pull/1168>`__)
* bugfix:``aws s3``: Fix issue where ``--endpoint-url`` was being ignored
(`issue 1142 <https://github.com/aws/aws-cli/pull/1172>`__)


1.7.11
Expand Down
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 connections 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 9144714

Please sign in to comment.