adding changelog. updating tests to reflect changes.

This commit is contained in:
Gareth J. Greenaway 2022-09-22 11:01:23 -07:00
parent 5c77b2beaa
commit 5961eb9435
2 changed files with 9 additions and 6 deletions

1
changelog/60467.fixed Normal file
View file

@ -0,0 +1 @@
Use return code in iptables --check to verify rule exists.

View file

@ -473,9 +473,10 @@ def test_check():
with patch.object(iptables, "_has_option", mock_has):
with patch.dict(iptables.__salt__, {"cmd.run_stderr": mock_cmd}):
assert iptables.check(
table="filter", chain="INPUT", rule=mock_rule, family="ipv4"
)
with patch.dict(iptables.__context__, {"retcode": 1}):
assert not iptables.check(
table="filter", chain="INPUT", rule=mock_rule, family="ipv4"
)
mock_cmd = MagicMock(return_value="-A 0x4d2")
mock_uuid = MagicMock(return_value=1234)
@ -483,9 +484,10 @@ def test_check():
with patch.object(iptables, "_has_option", mock_has):
with patch.object(uuid, "getnode", mock_uuid):
with patch.dict(iptables.__salt__, {"cmd.run_stderr": mock_cmd}):
assert iptables.check(
table="filter", chain="0x4d2", rule=mock_rule, family="ipv4"
)
with patch.dict(iptables.__context__, {"retcode": 0}):
assert iptables.check(
table="filter", chain="0x4d2", rule=mock_rule, family="ipv4"
)
# 'check_chain' function tests: 1