File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,61 @@ def test_rules_no_src_dest(self):
210
210
)
211
211
self .assertEqual (o .render (), expected )
212
212
213
+ def test_render_rule_wrong (self ):
214
+ rule = {
215
+ "ip_rules" : [
216
+ {
217
+ "in" : "eth0" ,
218
+ "out" : "eth1" ,
219
+ "src" : "wrong" ,
220
+ "dest" : "wrong" ,
221
+ "tos" : 2 ,
222
+ "action" : "blackhole"
223
+ }
224
+ ]
225
+ }
226
+ o = OpenWrt (rule )
227
+ try :
228
+ o .validate ()
229
+ except ValidationError as e :
230
+ # check error message
231
+ pass
232
+ else :
233
+ self .fail ('ValidationError not raised' )
234
+ # fix 'src' and expect wrong 'dest' to fail
235
+ rule ['src' ] = '192.168.1.1/24'
236
+ o = OpenWrt (rule )
237
+ try :
238
+ o .validate ()
239
+ except ValidationError as e :
240
+ # check error message
241
+ pass
242
+ else :
243
+ self .fail ('ValidationError not raised' )
244
+ # fix 'dest' and expect no ValidationError raised
245
+ rule ['src' ] = '192.168.1.1/24'
246
+ o = OpenWrt (rule )
247
+ o .validate ()
248
+
249
+ def test_parse_rules_zone (self ):
250
+ o = OpenWrt (native = """package network
251
+
252
+ config rule 'rule1'
253
+ option action 'blackhole'
254
+ option dest 'wrong'
255
+ option in 'eth0'
256
+ option out 'eth1'
257
+ option src 'wrong'
258
+ option tos '2'
259
+ """ )
260
+ try :
261
+ o .validate ()
262
+ except ValidationError as e :
263
+ # check error message
264
+ pass
265
+ else :
266
+ self .fail ('ValidationError not raised' )
267
+
213
268
_switch_netjson = {
214
269
"switch" : [
215
270
{
You can’t perform that action at this time.
0 commit comments