forked from ansible-collections/community.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
s3: raise an error if the bucket name is not correct (ansible-collect…
…ions#341) s3: raise an error if the bucket name is not correct Reviewed-by: https://github.com/apps/ansible-zuul
- Loading branch information
Showing
5 changed files
with
76 additions
and
1 deletion.
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,40 @@ | ||
# | ||
# (c) 2021 Red Hat Inc. | ||
# | ||
# This file is part of Ansible | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
from ansible_collections.amazon.aws.tests.unit.compat.mock import MagicMock | ||
import ansible_collections.amazon.aws.plugins.module_utils.s3 as s3 | ||
|
||
|
||
def test_validate_bucket_name(): | ||
module = MagicMock() | ||
|
||
assert s3.validate_bucket_name(module, "docexamplebucket1") is True | ||
assert not module.fail_json.called | ||
assert s3.validate_bucket_name(module, "log-delivery-march-2020") is True | ||
assert not module.fail_json.called | ||
assert s3.validate_bucket_name(module, "my-hosted-content") is True | ||
assert not module.fail_json.called | ||
|
||
assert s3.validate_bucket_name(module, "docexamplewebsite.com") is True | ||
assert not module.fail_json.called | ||
assert s3.validate_bucket_name(module, "www.docexamplewebsite.com") is True | ||
assert not module.fail_json.called | ||
assert s3.validate_bucket_name(module, "my.example.s3.bucket") is True | ||
assert not module.fail_json.called | ||
|
||
module.fail_json.reset_mock() | ||
s3.validate_bucket_name(module, "doc_example_bucket") | ||
assert module.fail_json.called | ||
|
||
module.fail_json.reset_mock() | ||
s3.validate_bucket_name(module, "DocExampleBucket") | ||
assert module.fail_json.called | ||
module.fail_json.reset_mock() | ||
s3.validate_bucket_name(module, "doc-example-bucket-") | ||
assert module.fail_json.called |