diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2024-09-06 22:57:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-06 22:57:05 +0200 |
commit | 11e56d9c27cdee08e0fd94efe530a9f09e4aaa43 (patch) | |
tree | cd2f4d42fd6ad5def098e53a6f7e3780a59f589f | |
parent | Stop suggesting `easy_install` in hacking (#83909) (diff) | |
download | ansible-11e56d9c27cdee08e0fd94efe530a9f09e4aaa43.tar.xz ansible-11e56d9c27cdee08e0fd94efe530a9f09e4aaa43.zip |
iptables, use existing validation (#83907)
also remove redundant and wrong test
-rw-r--r-- | lib/ansible/modules/iptables.py | 5 | ||||
-rw-r--r-- | test/units/modules/test_iptables.py | 14 |
2 files changed, 1 insertions, 18 deletions
diff --git a/lib/ansible/modules/iptables.py b/lib/ansible/modules/iptables.py index 9976d805c8..fad9b405ae 100644 --- a/lib/ansible/modules/iptables.py +++ b/lib/ansible/modules/iptables.py @@ -848,6 +848,7 @@ def main(): required_if=[ ['jump', 'TEE', ['gateway']], ['jump', 'tee', ['gateway']], + ['flush', False, ['chain']], ] ) args = dict( @@ -865,10 +866,6 @@ def main(): ip_version = module.params['ip_version'] iptables_path = module.get_bin_path(BINS[ip_version], True) - # Check if chain option is required - if args['flush'] is False and args['chain'] is None: - module.fail_json(msg="Either chain or flush parameter must be specified.") - if module.params.get('log_prefix', None) or module.params.get('log_level', None): if module.params['jump'] is None: module.params['jump'] = 'LOG' diff --git a/test/units/modules/test_iptables.py b/test/units/modules/test_iptables.py index 67e3909839..2b93b4b62d 100644 --- a/test/units/modules/test_iptables.py +++ b/test/units/modules/test_iptables.py @@ -22,20 +22,6 @@ def _mock_basic_commands(mocker): mocker.patch("ansible.modules.iptables.get_iptables_version", return_value=IPTABLES_VERSION) -def test_without_required_parameters(mocker): - """Test module without any parameters.""" - mocker.patch( - "ansible.module_utils.basic.AnsibleModule.fail_json", - side_effect=fail_json, - ) - set_module_args({}) - with pytest.raises(AnsibleFailJson) as exc: - iptables.main() - - assert exc.value.args[0]["failed"] - assert "Failed to find required executable" in exc.value.args[0]["msg"] - - @pytest.mark.usefixtures('_mock_basic_commands') def test_flush_table_without_chain(mocker): """Test flush without chain, flush the table.""" |