]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
migrate more tests to new methods
authorAlan T. DeKok <aland@freeradius.org>
Sat, 19 Aug 2023 12:57:20 +0000 (08:57 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 20 Aug 2023 14:42:10 +0000 (10:42 -0400)
src/tests/keywords/all.mk
src/tests/keywords/change-proto [new file with mode: 0644]
src/tests/keywords/change-proto.attrs [new file with mode: 0644]
src/tests/keywords/if-regex-multivalue
src/tests/keywords/unknown
src/tests/keywords/vendor-specific-error [moved from src/tests/keywords/vendor_specific with 100% similarity]
src/tests/keywords/vendor-specific.raw [moved from src/tests/keywords/vendor_specific.raw with 64% similarity]
src/tests/keywords/xlat-dhcpv4

index bcbc361bab0ae0589668cbb8655891ee429e24b0..fe578d9ef03d42a1609ec5438a728953cd9b4f3f 100644 (file)
@@ -65,13 +65,13 @@ endif
 #
 
 #  Tests for the "update" keyword
-KEYWORD_UPDATE_TESTS := update-attr-ref-null update-error-3 update-group-error update-null-value-assign update-remove-index update-filter
+KEYWORD_UPDATE_TESTS := update-attr-ref-null update-error-3 update-group-error update-null-value-assign update-remove-index update-filter update-proto update-proto-error vendor-specific-error comments smash
 
 # Tests for rewriting "udpate"
-KEYWORD_UPDATE_REWRITE_TESTS := update-all update-array update-delete update-remove-any update-group update-hex update-remove-value update-index update-list-error update-remove-list update-prepend unknown-update  update-error update-error-2 update-exec-error update-list-null-rhs update-exec
+KEYWORD_UPDATE_REWRITE_TESTS := update-all update-array update-delete update-remove-any update-group update-hex update-remove-value update-index update-list-error update-remove-list update-prepend unknown-update update-error update-error-2 update-exec-error update-list-null-rhs update-exec
 
-# Tests which can use new conditions, but which can't use tmpl_tokenize_all_nested=yes
-KEYWORD_UPDATE_TMPL_TESTS      := foreach-regex xlat-dhcpv4
+# the protocol decoder puts the attributes into a flat namespace
+KEYWORD_UPDATE_TMPL_TESTS      := xlat-dhcpv4
 
 #
 #  Migration support.  Some of the tests don't run under the new
@@ -80,11 +80,11 @@ KEYWORD_UPDATE_TMPL_TESTS   := foreach-regex xlat-dhcpv4
 ifneq "$(findstring ${1}, paircmp if-paircmp)" ""
 $(OUTPUT)/${1}: NEW_COND=-S use_new_conditions=no
 
-else ifneq "$(findstring ${1}, comments update-to-edit if-regex-multivalue smash unknown $(KEYWORD_UPDATE_TESTS) vendor_specific vendor_specific.raw xlat-unknown update-proto update-proto-error)" ""
+else ifneq "$(findstring ${1}, update-to-edit $(KEYWORD_UPDATE_TESTS) xlat-unknown )" ""
 $(OUTPUT)/${1}: NEW_COND=-S use_new_conditions=yes
 
 else ifneq "$(findstring ${1}, $(KEYWORD_UPDATE_REWRITE_TESTS))" ""
-$(OUTPUT)/${1}: NEW_COND=-S use_new_conditions=yes -S rewrite_update=yes
+$(OUTPUT)/${1}: NEW_COND=-S use_new_conditions=yes -S rewrite_update=yes -S tmpl_tokenize_all_nested=yes
 
 else ifneq "$(findstring ${1}, $(KEYWORD_UPDATE_TMPL_TESTS))" ""
 $(OUTPUT)/${1}: NEW_COND=-S use_new_conditions=yes -S forbid_update=yes
diff --git a/src/tests/keywords/change-proto b/src/tests/keywords/change-proto
new file mode 100644 (file)
index 0000000..8779815
--- /dev/null
@@ -0,0 +1,9 @@
+#
+#  PROTOCOL: dhcpv4
+#
+#  Not really, but it's a way to test cross-protocol issues
+#
+&Proto.radius.User-Name = 'uid'
+&Password.With-Header = 'userPassword'
+
+success
diff --git a/src/tests/keywords/change-proto.attrs b/src/tests/keywords/change-proto.attrs
new file mode 100644 (file)
index 0000000..6065f63
--- /dev/null
@@ -0,0 +1,4 @@
+Packet-Type = Discover
+
+Result-Status == success
+Packet-Type == Offer
index 75525fd51be8bcfdabb96368a72659c16daa46a3..e1f989e319f4b8d71894e7fb7811b15020a208f0 100644 (file)
@@ -2,11 +2,8 @@
 # PRE: update if
 #
 
-update request {
-       &Vendor-Specific.Cisco.AVPair := 'foo=bar'
-       &Vendor-Specific.Cisco.AVPair += 'bar=baz'
-       &Vendor-Specific.Cisco.AVPair += 'baz=foo'
-}
+&Vendor-Specific.Cisco.AVPair := { 'foo=bar', 'bar=baz', 'baz=foo' }
+
 
 if (&Vendor-Specific.Cisco.AVPair[1] =~ /bar=(.*)/) {
        if (!("%{1}" == 'baz')) {
index c3790cb938fe74071ca5a3b7623f10cc406ac8e1..f498fc91940191701563fe60151cf5a1343344f5 100644 (file)
@@ -1,9 +1,7 @@
 #
 #  PRE: wimax
 #
-update request {
-       &Vendor-Specific.FreeRADIUS.Proxied-To  := 127.0.0.2
-}
+&Vendor-Specific.FreeRADIUS.Proxied-To  := 127.0.0.2
 
 #
 #  Check that a known but malformed attr is malformed
similarity index 64%
rename from src/tests/keywords/vendor_specific.raw
rename to src/tests/keywords/vendor-specific.raw
index 331140aa447d8a69da746bfd8330b8bf5b6a68da..2b168967fc955c717cb1d4b7f3138b70854e0e01 100644 (file)
@@ -1,11 +1,6 @@
-#
-#  PRE: vendor_specific
-#
 #  Tests for Vendor-Specific
 #
-update request {
-       &raw.26 := 0x01020304
-}
+&raw.26 := 0x01020304
 
 if (!&raw.26) {
        test_fail
index 6035c5d0fac6cd87ff93eae56ef9bccc5caaa78e..eb88cd843fe5df6febdb1f3c60327415d89d0da9 100644 (file)
@@ -3,6 +3,8 @@
 #
 
 &Tmp-Octets-0 := 0x520d0103abcdef0206010203040506
+
+# the protocol decoder puts the attributes into a flat namespace
 if (!("%(dhcpv4.decode:%{Tmp-Octets-0})" == 2)) {
        test_fail
 }