-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* release-1.3.22: Bumping version to 1.3.22 Update CHANGELOG with the latest features Update completer test with new services Update changelog with #825 Add changelog entry for #834 Fix changelog entry for merge of #831 Added test_cancel_after_upload_id to test_tasks Update changelog with fix for #549 Disable fix_s3_host when --endpoint-url is given Fixes issue #834 Update changelog with bugfix Add validation to ensure we don't mv a file onto itself Let aws.cmd find python.exe on paths with spaces.
- Loading branch information
Showing
14 changed files
with
240 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
"""Disable endpoint url customizations for s3. | ||
There's a customization in botocore such that for S3 operations | ||
we try to fix the S3 endpoint url based on whether a bucket is | ||
dns compatible. We also try to map the endpoint url to the | ||
standard S3 region (s3.amazonaws.com). This normally happens | ||
even if a user provides an --endpoint-url (if the bucket is | ||
DNS compatible). | ||
This customization ensures that if a user specifies | ||
an --endpoint-url, then we turn off the botocore customization | ||
that messes with endpoint url. | ||
""" | ||
from functools import partial | ||
|
||
from botocore.handlers import fix_s3_host | ||
|
||
|
||
def register_s3_endpoint(cli): | ||
handler = partial(on_top_level_args_parsed, event_handler=cli) | ||
cli.register('top-level-args-parsed', handler) | ||
|
||
|
||
def on_top_level_args_parsed(parsed_args, event_handler, **kwargs): | ||
# The fix_s3_host has logic to set the endpoint to the | ||
# standard region endpoint for s3 (s3.amazonaws.com) under | ||
# certain conditions. We're making sure that if | ||
# the user provides an --endpoint-url, that entire handler | ||
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python | ||
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
from awscli.testutils import BaseAWSCommandParamsTest, FileCreator | ||
import re | ||
|
||
import mock | ||
import six | ||
|
||
|
||
class TestMvCommand(BaseAWSCommandParamsTest): | ||
|
||
prefix = 's3 mv ' | ||
|
||
def setUp(self): | ||
super(TestMvCommand, self).setUp() | ||
self.files = FileCreator() | ||
|
||
def tearDown(self): | ||
super(TestMvCommand, self).tearDown() | ||
self.files.remove_all() | ||
|
||
def test_cant_mv_object_onto_itself(self): | ||
cmdline = '%s s3://bucket/key s3://bucket/key' % self.prefix | ||
stderr = self.run_cmd(cmdline, expected_rc=255)[1] | ||
self.assertIn('Cannot mv a file onto itself', stderr) | ||
|
||
def test_cant_mv_object_with_implied_name(self): | ||
# The "key" key name is implied in the dst argument. | ||
cmdline = '%s s3://bucket/key s3://bucket/' % self.prefix | ||
stderr = self.run_cmd(cmdline, expected_rc=255)[1] | ||
self.assertIn('Cannot mv a file onto itself', stderr) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
from awscli.testutils import unittest | ||
from awscli.customizations.s3endpoint import on_top_level_args_parsed | ||
|
||
from botocore.handlers import fix_s3_host | ||
|
||
import mock | ||
|
||
|
||
class TestS3EndpointURL(unittest.TestCase): | ||
def test_endpoint_url_unregisters_fix_s3_host(self): | ||
args = mock.Mock() | ||
args.endpoint_url = 'http://custom/' | ||
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) | ||
|
||
def test_unregister_not_called_for_no_endpoint(self): | ||
args = mock.Mock() | ||
args.endpoint_url = None | ||
event_handler = mock.Mock() | ||
on_top_level_args_parsed(args, event_handler) | ||
self.assertFalse(event_handler.unregister.called) | ||
|
||
def test_endpoint_url_set_but_not_for_s3(self): | ||
args = mock.Mock() | ||
args.endpoint_url = 'http://custom/' | ||
args.command = 'NOTS3' | ||
event_handler = mock.Mock() | ||
on_top_level_args_parsed(args, event_handler) | ||
self.assertFalse(event_handler.unregister.called) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters