From 2e8f24447f645b5b79a4f2811c2b2231ef9b03c2 Mon Sep 17 00:00:00 2001 From: "Jonathan G. Underwood" Date: Tue, 28 Jul 2020 17:35:51 +0100 Subject: [PATCH] Add another firewall rule test --- tests/openwrt/test_firewall.py | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/openwrt/test_firewall.py b/tests/openwrt/test_firewall.py index b0619edd2..6a79ec32f 100644 --- a/tests/openwrt/test_firewall.py +++ b/tests/openwrt/test_firewall.py @@ -138,3 +138,41 @@ def test_render_rule_3(self): def test_parse_rule_3(self): o = OpenWrt(native=self._rule_3_uci) self.assertEqual(o.config, self._rule_3_netjson) + + _rule_4_netjson = { + "firewall": { + "rules": [ + { + "name": "Allow-Isolated-DHCP", + "src": "isolated", + "proto": ["udp"], + "dest_port": "67-68", + "target": "ACCEPT", + } + ] + } + } + + _rule_4_uci = textwrap.dedent( + """\ + package firewall + + config defaults 'defaults' + + config rule 'rule_Allow_Isolated_DHCP' + option name 'Allow-Isolated-DHCP' + option src 'isolated' + option proto 'udp' + option dest_port '67-68' + option target 'ACCEPT' + """ + ) + + def test_render_rule_4(self): + o = OpenWrt(self._rule_4_netjson) + expected = self._tabs(self._rule_4_uci) + self.assertEqual(o.render(), expected) + + def test_parse_rule_4(self): + o = OpenWrt(native=self._rule_4_uci) + self.assertEqual(o.config, self._rule_4_netjson)