@@ -26,6 +26,7 @@ def tearDown(self):
26
26
shutil .rmtree (self .tmpdir )
27
27
28
28
def conf_file_name (self ):
29
+ """Return path to test config file in test directory."""
29
30
return os .path .join (self .tmpdir , 'faucet.yaml' )
30
31
31
32
def create_config_file (self , config ):
@@ -45,7 +46,7 @@ def run_function_with_config(self, config, function, before_function=None):
45
46
before_function ()
46
47
try :
47
48
function (conf_file , LOGNAME )
48
- except cp .InvalidConfigError as err :
49
+ except cp .InvalidConfigError as _err :
49
50
return False
50
51
return True
51
52
@@ -523,6 +524,7 @@ def test_invalid_interfaces(self):
523
524
self .check_config_failure (config , cp .dp_parser )
524
525
525
526
def test_unresolved_mirror_ports (self ):
527
+ """Test invalid mirror port name."""
526
528
config = """
527
529
vlans:
528
530
office:
@@ -562,6 +564,7 @@ def test_resolved_mirror_port(self):
562
564
self .check_config_success (config , cp .dp_parser )
563
565
564
566
def test_vlans_on_mirror_ports (self ):
567
+ """Test invalid VLANs configured on a mirror port."""
565
568
config = """
566
569
vlans:
567
570
office:
@@ -579,6 +582,7 @@ def test_vlans_on_mirror_ports(self):
579
582
self .check_config_failure (config , cp .dp_parser )
580
583
581
584
def test_unresolved_output_ports (self ):
585
+ """Test invalid output port name."""
582
586
config = """
583
587
vlans:
584
588
office:
@@ -601,6 +605,7 @@ def test_unresolved_output_ports(self):
601
605
self .check_config_failure (config , cp .dp_parser )
602
606
603
607
def test_unknown_output_ports (self ):
608
+ """Test invalid mirror ACL port."""
604
609
config = """
605
610
vlans:
606
611
office:
@@ -674,6 +679,7 @@ def test_single_range_valid_config(self):
674
679
self .assertEqual (len (dp .ports ), 1 )
675
680
676
681
def test_port_range_invalid_config (self ):
682
+ """Test invalid characters used in interface_ranges."""
677
683
config = """
678
684
vlans:
679
685
office:
@@ -688,6 +694,7 @@ def test_port_range_invalid_config(self):
688
694
self .check_config_failure (config , cp .dp_parser )
689
695
690
696
def test_acl_no_actions (self ):
697
+ """Test ACL with invalid actions section."""
691
698
config = """
692
699
acls:
693
700
office-vlan-protect:
@@ -709,6 +716,7 @@ def test_acl_no_actions(self):
709
716
self .check_config_failure (config , cp .dp_parser )
710
717
711
718
def test_acl_invalid_ipv4 (self ):
719
+ """Test invalid IPv4 address in ACL."""
712
720
config = """
713
721
acls:
714
722
office-vlan-protect:
@@ -730,6 +738,7 @@ def test_acl_invalid_ipv4(self):
730
738
self .check_config_failure (config , cp .dp_parser )
731
739
732
740
def test_acl_invalid_ipv6 (self ):
741
+ """Test invalid IPv6 address in ACL."""
733
742
config = """
734
743
acls:
735
744
office-vlan-protect:
@@ -751,6 +760,7 @@ def test_acl_invalid_ipv6(self):
751
760
self .check_config_failure (config , cp .dp_parser )
752
761
753
762
def test_acl_invalid_mask (self ):
763
+ """Test invalid IPv4 mask in ACL."""
754
764
config = """
755
765
acls:
756
766
office-vlan-protect:
@@ -772,6 +782,7 @@ def test_acl_invalid_mask(self):
772
782
self .check_config_failure (config , cp .dp_parser )
773
783
774
784
def test_acl_invalid_udp_port (self ):
785
+ """Test invalid UDP port in ACL."""
775
786
config = """
776
787
acls:
777
788
access-port-protect:
@@ -792,6 +803,7 @@ def test_acl_invalid_udp_port(self):
792
803
self .check_config_failure (config , cp .dp_parser )
793
804
794
805
def test_acl_invalid_rule_name (self ):
806
+ """Test invalid name for rule in ACL."""
795
807
config = """
796
808
acls:
797
809
access-port-protect:
@@ -812,6 +824,7 @@ def test_acl_invalid_rule_name(self):
812
824
self .check_config_failure (config , cp .dp_parser )
813
825
814
826
def test_acl_and_acls_vlan_invalid (self ):
827
+ """Test cannot have acl_in and acls_in together."""
815
828
config = """
816
829
acls:
817
830
access-port-protect:
@@ -835,7 +848,7 @@ def test_acl_and_acls_vlan_invalid(self):
835
848
"""
836
849
self .check_config_failure (config , cp .dp_parser )
837
850
838
- def test_inconsistent_acl_exact_match (self ):
851
+ def test_inconsistent_exact_match (self ):
839
852
"""Test that ACLs have consistent exact_match."""
840
853
config = """
841
854
acls:
@@ -887,6 +900,7 @@ def test_acl_and_acls_port_invalid(self):
887
900
self .check_config_failure (config , cp .dp_parser )
888
901
889
902
def test_acls_vlan_valid (self ):
903
+ """Test ACLs can be combined on VLAN."""
890
904
config = """
891
905
acls:
892
906
access-port-protect:
@@ -910,6 +924,7 @@ def test_acls_vlan_valid(self):
910
924
self .check_config_success (config , cp .dp_parser )
911
925
912
926
def test_acls_port_valid (self ):
927
+ """Test ACLs can be combined on a port."""
913
928
config = """
914
929
acls:
915
930
access-port-protect:
@@ -933,10 +948,12 @@ def test_acls_port_valid(self):
933
948
self .check_config_success (config , cp .dp_parser )
934
949
935
950
def test_invalid_char (self ):
951
+ """Test config file with invalid characters."""
936
952
config = b'\x63 \xe1 '
937
953
self .check_config_failure (config , cp .dp_parser )
938
954
939
955
def test_perm_denied (self ):
956
+ """Test config file has no read permission."""
940
957
941
958
def unreadable ():
942
959
"""Make config unreadable."""
@@ -946,6 +963,7 @@ def unreadable():
946
963
self .check_config_failure (config , cp .dp_parser , before_function = unreadable )
947
964
948
965
def test_missing_route_config (self ):
966
+ """Test missing IP gateway for route."""
949
967
config = """
950
968
vlans:
951
969
office:
@@ -964,6 +982,7 @@ def test_missing_route_config(self):
964
982
self .check_config_failure (config , cp .dp_parser )
965
983
966
984
def test_invalid_dp_conf (self ):
985
+ """Test invalid DP header config."""
967
986
config = """
968
987
vlans:
969
988
office:
@@ -1034,6 +1053,7 @@ def test_invalid_key(self):
1034
1053
self .check_config_failure (config , cp .dp_parser )
1035
1054
1036
1055
def test_invalid_acl_formation (self ):
1056
+ """Test missing ACL name."""
1037
1057
config = """
1038
1058
acls:
1039
1059
# office-vlan-protect:
@@ -1643,6 +1663,7 @@ def test_unknown_port_key(self):
1643
1663
self .check_config_failure (config , cp .dp_parser )
1644
1664
1645
1665
def test_meter_config (self ):
1666
+ """Test valid meter config."""
1646
1667
config = """
1647
1668
meters:
1648
1669
lossymeter:
0 commit comments