From 3b51afee567f5f439795e2ca987b88d363b2a39b Mon Sep 17 00:00:00 2001 From: "Jonathan G. Underwood" Date: Sat, 20 Mar 2021 15:34:43 +0000 Subject: [PATCH] [openwrt] Add firewall includes tests --- tests/openwrt/test_firewall.py | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/openwrt/test_firewall.py b/tests/openwrt/test_firewall.py index 6c3d884e1..33b74d244 100644 --- a/tests/openwrt/test_firewall.py +++ b/tests/openwrt/test_firewall.py @@ -898,3 +898,43 @@ def test_render_redirect_4(self): def test_parse_redirect_4(self): o = OpenWrt(native=self._redirect_4_uci) self.assertEqual(o.config, self._redirect_4_netjson) + + _include_1_uci = textwrap.dedent( + """\ + package firewall + + config defaults 'defaults' + + config include 'Include Test' + option name 'Include Test' + option type 'script' + option family 'any' + option path '/a/b/c.ipt' + option reload '1' + option enabled '0' + """ + ) + + _include_1_netjson = { + "firewall": { + "includes": [ + { + "name": "Include Test", + "type": "script", + "family": "any", + "path": "/a/b/c.ipt", + "reload": True, + "enabled": False, + } + ] + } + } + + def test_render_include_1(self): + o = OpenWrt(self._include_1_netjson) + expected = self._tabs(self._include_1_uci) + self.assertEqual(o.render(), expected) + + def test_parse_include_1(self): + o = OpenWrt(native=self._include_1_uci) + self.assertEqual(o.config, self._include_1_netjson)