From 67cda0147ab54136ef0604427c5a01a7f4b21986 Mon Sep 17 00:00:00 2001 From: maxime <37832743+mlk-89@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:37:36 +0100 Subject: Add feature for bonding/vlan interface in the firewall_interfaces (#246) * - Add feature for bonding interface in the firewall_interfaces - Add feature for vlan interface in the firewall_interfaces * fix a bug when invoking replaced in the module firewall_rules. * - Add feature for bonding interface in the firewall_interfaces - Add feature for vlan interface in the firewall_interfaces * test: add tests * fix: support for interface types * docs: fixed for 1.4 deprecation --------- Co-authored-by: Maxime.L Co-authored-by: Gaige B. Paulsen Co-authored-by: Gaige B Paulsen --- .../network/vyos/test_vyos_firewall_interfaces.py | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'tests/unit') diff --git a/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py b/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py index 3034d589..f921c508 100644 --- a/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py +++ b/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py @@ -388,3 +388,68 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): ), ) self.execute_module(changed=False, commands=[]) + + def test_vyos_firewall_rule_set_02_replaced(self): + set_module_args( + dict( + config=[ + dict( + name="eth0.100", + access_rules=[ + dict( + afi="ipv4", + rules=[dict(name="INBOUND", direction="in")], + ), + dict( + afi="ipv6", + rules=[dict(name="V6-LOCAL", direction="local")], + ), + ], + ), + dict( + name="bond2", + access_rules=[ + dict( + afi="ipv4", + rules=[dict(name="LOCAL", direction="local")], + ), + dict( + afi="ipv6", + rules=[dict(name="V6-LOCAL", direction="local")], + ), + ], + ), + dict( + name="wg4", + access_rules=[ + dict( + afi="ipv4", + rules=[dict(name="LOCAL", direction="local")], + ), + dict( + afi="ipv6", + rules=[dict(name="V6-LOCAL", direction="local")], + ), + ], + ), + ], + state="replaced", + ), + ) + commands = [ + 'delete interfaces ethernet eth0 firewall in name', + 'delete interfaces ethernet eth0 firewall local name', + 'delete interfaces ethernet eth0 firewall out name', + 'delete interfaces ethernet eth0 firewall local ipv6-name', + 'delete interfaces ethernet eth2 firewall in name', + 'delete interfaces ethernet eth2 firewall local name', + 'delete interfaces ethernet eth2 firewall out name', + 'delete interfaces ethernet eth2 firewall local ipv6-name', + "set interfaces ethernet eth0 vif 100 firewall in name 'INBOUND'", + "set interfaces ethernet eth0 vif 100 firewall local ipv6-name 'V6-LOCAL'", + "set interfaces bonding bond2 firewall local name 'LOCAL'", + "set interfaces bonding bond2 firewall local ipv6-name 'V6-LOCAL'", + "set interfaces wireguard wg4 firewall local name 'LOCAL'", + "set interfaces wireguard wg4 firewall local ipv6-name 'V6-LOCAL'" + ] + self.execute_module(changed=True, commands=commands) -- cgit v1.2.3