-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add temporary ignore for PEP8 errors, will backport after release
- Loading branch information
Showing
3 changed files
with
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this | ||
plugins/inventory/aws_ec2.py pep8:E275 # Need to partially backport 1181 | ||
plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this | ||
plugins/modules/s3_object_info.py pep8:E275 # Need to partially backport 1181 |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
plugins/inventory/aws_ec2.py pep8:E275 # Need to partially backport 1181 | ||
plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this | ||
plugins/modules/s3_object_info.py pep8:E275 # Need to partially backport 1181 |
51 changes: 51 additions & 0 deletions
51
tests/unit/plugins/modules/ec2_security_group/test_validate_rule.py
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,51 @@ | ||
# (c) 2022 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 copy import deepcopy | ||
import pytest | ||
|
||
import ansible_collections.amazon.aws.plugins.modules.ec2_security_group as ec2_security_group_module | ||
|
||
|
||
VALID_RULES = [ | ||
dict(proto='all',), | ||
dict(proto='tcp', from_port='1', to_port='65535',), | ||
dict(proto='icmpv6', from_port='-1', to_port='-1',), | ||
dict(proto='icmp', from_port='-1', to_port='-1',), | ||
dict(proto='icmpv6', icmp_type='8', icmp_code='1'), | ||
dict(proto='icmpv6', icmp_code='1'), | ||
dict(proto='icmpv6', icmp_type='8'), | ||
dict(proto='icmp', icmp_type='8', icmp_code='1'), | ||
dict(proto='icmp', icmp_code='1'), | ||
dict(proto='icmp', icmp_type='8'), | ||
] | ||
|
||
INVALID_RULES = [ | ||
(dict(proto='tcp', icmp_code='1',), r"Specify proto: icmp or icmpv6",), | ||
(dict(proto='tcp', icmp_type='8',), r"Specify proto: icmp or icmpv6",), | ||
(dict(proto='tcp', icmp_type='8', icmp_code='1',), r"Specify proto: icmp or icmpv6",), | ||
(dict(proto='all', icmp_code='1',), r"Specify proto: icmp or icmpv6",), | ||
(dict(proto='all', icmp_type='8',), r"Specify proto: icmp or icmpv6",), | ||
(dict(proto='all', icmp_type='8', icmp_code='1',), r"Specify proto: icmp or icmpv6",), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("rule,error_msg", INVALID_RULES) | ||
def test_validate_rule_invalid(rule, error_msg): | ||
original_rule = deepcopy(rule) | ||
with pytest.raises(ec2_security_group_module.SecurityGroupError, match=error_msg): | ||
ec2_security_group_module.validate_rule(rule) | ||
assert original_rule == rule | ||
|
||
|
||
@pytest.mark.parametrize("rule", VALID_RULES) | ||
def test_validate_rule_valid(rule): | ||
original_rule = deepcopy(rule) | ||
ec2_security_group_module.validate_rule(rule) | ||
# validate_rule shouldn't change the rule | ||
assert original_rule == rule |