Skip to content

Commit 2e8f244

Browse files
Add another firewall rule test
1 parent f727193 commit 2e8f244

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/openwrt/test_firewall.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,41 @@ def test_render_rule_3(self):
138138
def test_parse_rule_3(self):
139139
o = OpenWrt(native=self._rule_3_uci)
140140
self.assertEqual(o.config, self._rule_3_netjson)
141+
142+
_rule_4_netjson = {
143+
"firewall": {
144+
"rules": [
145+
{
146+
"name": "Allow-Isolated-DHCP",
147+
"src": "isolated",
148+
"proto": ["udp"],
149+
"dest_port": "67-68",
150+
"target": "ACCEPT",
151+
}
152+
]
153+
}
154+
}
155+
156+
_rule_4_uci = textwrap.dedent(
157+
"""\
158+
package firewall
159+
160+
config defaults 'defaults'
161+
162+
config rule 'rule_Allow_Isolated_DHCP'
163+
option name 'Allow-Isolated-DHCP'
164+
option src 'isolated'
165+
option proto 'udp'
166+
option dest_port '67-68'
167+
option target 'ACCEPT'
168+
"""
169+
)
170+
171+
def test_render_rule_4(self):
172+
o = OpenWrt(self._rule_4_netjson)
173+
expected = self._tabs(self._rule_4_uci)
174+
self.assertEqual(o.render(), expected)
175+
176+
def test_parse_rule_4(self):
177+
o = OpenWrt(native=self._rule_4_uci)
178+
self.assertEqual(o.config, self._rule_4_netjson)

0 commit comments

Comments
 (0)