@@ -213,12 +213,23 @@ def test_valid__line(self):
213213 obj .line = kwargs ["line" ]
214214 self ._test_attrs (obj = obj , req_d = req_d , msg = f"{ kwargs = } " )
215215
216- def test_invalid__line (self ):
217- """Acl.line"""
216+ def test_invalid__line__skip (self ):
217+ """Acl.line skip invalid line"""
218+ expected = ACL_NAME_IOS
219+ for line in [
220+ f"{ ACL_NAME_IOS } \n permit ip any any 0.0.0.0" # option
221+ f"{ ACL_NAME_IOS_STD } \n permit host 10.0.0.1 0.0.0.0" # option
222+ ]:
223+ obj = Acl (line , platform = "ios" )
224+ result = str (obj ).strip ()
225+ self .assertEqual (result , expected , msg = f"{ line = } " )
226+
227+ def test_invalid__line__error (self ):
228+ """Acl.line raise error"""
218229 for line , error , in [
219230 ("ip access-list extended\n permit ip any any" , ValueError ), # no name
220231 ("ip access-listy\n permit ip any any" , ValueError ), # no name
221- ("ip access-list extended NAME NAME\n permit ip any any" , ValueError ), # 2 names
232+ (f" { ACL_NAME_IOS } NAME\n permit ip any any" , ValueError ), # 2 names
222233 (PERMIT_IP , ValueError ),
223234 ]:
224235 with self .assertRaises (error , msg = f"{ line = } " ):
@@ -341,12 +352,15 @@ def test_valid__type(self):
341352 host_ext = f"{ ACL_NAME_IOS } \n " \
342353 f" { REMARK } \n " \
343354 f" permit tcp host 10.0.0.1 eq 1 host 10.0.0.2 eq 2 ack log"
344- host_std = f"{ ACL_NAME_IOS_STD } \n " \
345- f" { REMARK } \n " \
346- f" permit host 10.0.0.1"
347- host_std_ = f"{ ACL_NAME_IOS_STD } \n " \
355+ host1_std = f"{ ACL_NAME_IOS_STD } \n " \
356+ f" { REMARK } \n " \
357+ f" permit host 10.0.0.1"
358+ host2_std = f"{ ACL_NAME_IOS_STD } \n " \
348359 f" { REMARK } \n " \
349360 f" permit 10.0.0.1"
361+ host3_std = f"{ ACL_NAME_IOS_STD } \n " \
362+ f" { REMARK } \n " \
363+ f" permit 10.0.0.1 0.0.0.0"
350364 host_ext_ = f"{ ACL_NAME_IOS } \n " \
351365 f" { REMARK } \n permit ip host 10.0.0.1 any"
352366 wild_ext = f"{ ACL_NAME_IOS } \n " \
@@ -379,17 +393,19 @@ def test_valid__type(self):
379393 ("extended" , "extended" , wild_ext , wild_ext ),
380394 ("extended" , "extended" , aceg_ext , aceg_ext ),
381395 # extended to standard
382- ("extended" , "standard" , host_ext , host_std ),
396+ ("extended" , "standard" , host_ext , host1_std ),
383397 ("extended" , "standard" , wild_ext , wild_std ),
384398 ("extended" , "standard" , aceg_ext , aceg_std ),
385399 # standard to standard
386- ("standard" , "standard" , host_std , host_std ),
387- ("standard" , "standard" , host_std_ , host_std ),
400+ ("standard" , "standard" , host1_std , host1_std ),
401+ ("standard" , "standard" , host2_std , host1_std ),
402+ ("standard" , "standard" , host3_std , host1_std ),
388403 ("standard" , "standard" , wild_std , wild_std ),
389404 ("standard" , "standard" , aceg_std , aceg_std ),
390405 # standard to extended
391- ("standard" , "extended" , host_std , host_ext_ ),
392- ("standard" , "extended" , host_std_ , host_ext_ ),
406+ ("standard" , "extended" , host1_std , host_ext_ ),
407+ ("standard" , "extended" , host2_std , host_ext_ ),
408+ ("standard" , "extended" , host3_std , host_ext_ ),
393409 ("standard" , "extended" , wild_std , wild_ext_ ),
394410 ("standard" , "extended" , aceg_std , aceg_ext_ ),
395411 ]:
0 commit comments