From 818c45e09c17e3fff53d581eb97fbd4609d5d39b Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Mon, 16 Jan 2023 22:20:41 +0000 Subject: [PATCH] acl: consistency in error messages, reformatted, and updated unittests --- vppcfg/config/acl.py | 24 ++++++++++++------------ vppcfg/unittest/yaml/error-acl2.yaml | 3 +-- vppcfg/unittest/yaml/error-acl3.yaml | 11 ++++------- vppcfg/unittest/yaml/error-acl5.yaml | 8 ++++---- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/vppcfg/config/acl.py b/vppcfg/config/acl.py index 9f86b8b..6838b71 100644 --- a/vppcfg/config/acl.py +++ b/vppcfg/config/acl.py @@ -303,57 +303,57 @@ def validate_acls(yaml): if src_low_port is None or src_high_port is None: msgs.append( - f"acl {aclname} term {terms} could not understand source port" + f"acl {aclname} term {terms} could not understand source-port" ) result = False else: if src_low_port > src_high_port: msgs.append( - f"acl {aclname} term {terms} source low port is higher than source high port" + f"acl {aclname} term {terms} source-port low value is greater than high value" ) result = False if src_low_port < 0 or src_low_port > 65535: msgs.append( - f"acl {aclname} term {terms} source low port is not between [0,65535]" + f"acl {aclname} term {terms} source-port low value is not between [0,65535]" ) result = False if src_high_port < 0 or src_high_port > 65535: msgs.append( - f"acl {aclname} term {terms} source high port is not between [0,65535]" + f"acl {aclname} term {terms} source-port high value is not between [0,65535]" ) result = False if dst_low_port is None or dst_high_port is None: msgs.append( - f"acl {aclname} term {terms} could not understand destination port" + f"acl {aclname} term {terms} could not understand destination-port" ) result = False else: if dst_low_port > dst_high_port: msgs.append( - f"acl {aclname} term {terms} destination low port is higher than destination high port" + f"acl {aclname} term {terms} destination-port low value is greater than high value" ) result = False if dst_low_port < 0 or dst_low_port > 65535: msgs.append( - f"acl {aclname} term {terms} destination low port is not between [0,65535]" + f"acl {aclname} term {terms} destination-port low value is not between [0,65535]" ) result = False if dst_high_port < 0 or dst_high_port > 65535: msgs.append( - f"acl {aclname} term {terms} destination high port is not between [0,65535]" + f"acl {aclname} term {terms} destination-port high value is not between [0,65535]" ) result = False if not proto in [1, 58]: if "icmp-code" in orig_acl_term: msgs.append( - f"acl {aclname} term {terms} icmp-code can only be specified for protocol icmp or icmp-ipv6" + f"acl {aclname} term {terms} icmp-code can only be specified for protocol icmp or ipv6-icmp" ) result = False if "icmp-type" in orig_acl_term: msgs.append( - f"acl {aclname} term {terms} icmp-type can only be specified for protocol icmp or icmp-ipv6" + f"acl {aclname} term {terms} icmp-type can only be specified for protocol icmp or ipv6-icmp" ) result = False else: @@ -361,12 +361,12 @@ def validate_acls(yaml): icmp_type_low, icmp_type_high = get_icmp_low_high(acl_term["icmp-type"]) if icmp_code_low > icmp_code_high: msgs.append( - f"acl {aclname} term {terms} icmp-code low value is higher than high value" + f"acl {aclname} term {terms} icmp-code low value is greater than high value" ) result = False if icmp_type_low > icmp_type_high: msgs.append( - f"acl {aclname} term {terms} icmp-type low value is higher than high value" + f"acl {aclname} term {terms} icmp-type low value is greater than high value" ) result = False diff --git a/vppcfg/unittest/yaml/error-acl2.yaml b/vppcfg/unittest/yaml/error-acl2.yaml index e54c914..1f749ec 100644 --- a/vppcfg/unittest/yaml/error-acl2.yaml +++ b/vppcfg/unittest/yaml/error-acl2.yaml @@ -3,8 +3,7 @@ test: errors: expected: - "acl .* term .* source and destination family do not overlap" - - "acl .* term .* family any has no source" - - "acl .* term .* family any has no destination" + - "acl .* term .* family any has no (source|destination)" count: 8 --- prefixlists: diff --git a/vppcfg/unittest/yaml/error-acl3.yaml b/vppcfg/unittest/yaml/error-acl3.yaml index fb16337..74f75bb 100644 --- a/vppcfg/unittest/yaml/error-acl3.yaml +++ b/vppcfg/unittest/yaml/error-acl3.yaml @@ -2,13 +2,10 @@ test: description: "Ways in which port ranges can fail" errors: expected: - - "acl .* term .* could not understand source port" - - "acl .* term .* could not understand destination port" - - "acl .* term .* source low port is higher than source high port" - - "acl .* term .* source (high|low) port is not between \\[0,65535\\]" - - "acl .* term .* destination (high|low) port is not between \\[0,65535\\]" - - "acl .* term .* source-port can only be specified for protocol tcp or udp" - - "acl .* term .* destination-port can only be specified for protocol tcp or udp" + - "acl .* term .* could not understand (source|destination)-port" + - "acl .* term .* (source|destination)-port low value is greater than high value" + - "acl .* term .* (source|destination)-port (low|high) value is not between \\[0,65535\\]" + - "acl .* term .* (source|destination)-port can only be specified for protocol tcp or udp" count: 7 --- acls: diff --git a/vppcfg/unittest/yaml/error-acl5.yaml b/vppcfg/unittest/yaml/error-acl5.yaml index c212978..5b2eaaa 100644 --- a/vppcfg/unittest/yaml/error-acl5.yaml +++ b/vppcfg/unittest/yaml/error-acl5.yaml @@ -2,10 +2,10 @@ test: description: "Ways in which ICMP code and type can fail" errors: expected: - - "acl .* term .* icmp-type can only be specified for protocol icmp or icmp-ipv6" - - "acl .* term .* icmp-code can only be specified for protocol icmp or icmp-ipv6" - - "acl .* term .* icmp-code low value is higher than high value" - - "acl .* term .* icmp-type low value is higher than high value" + - "acl .* term .* icmp-type can only be specified for protocol icmp or ipv6-icmp" + - "acl .* term .* icmp-code can only be specified for protocol icmp or ipv6-icmp" + - "acl .* term .* icmp-code low value is greater than high value" + - "acl .* term .* icmp-type low value is greater than high value" count: 8 --- acls: