Skip to content

Commit

Permalink
Add another firewall rule test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanunderwood committed Jul 28, 2020
1 parent 3ea6014 commit a8117e6
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/openwrt/test_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit a8117e6

Please sign in to comment.