Skip to content

Commit

Permalink
[openwrt] Add firewall includes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanunderwood committed Mar 20, 2021
1 parent b2536dd commit 3b51afe
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/openwrt/test_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 3b51afe

Please sign in to comment.