]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Revert "Revert "add test looping over children of a TLV""
authorAlan T. DeKok <aland@freeradius.org>
Mon, 9 Sep 2024 21:10:10 +0000 (17:10 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 10 Sep 2024 12:14:29 +0000 (08:14 -0400)
This reverts commit e9f45f88c36001cf8bb2534068eb8563b2130ba0.

src/tests/keywords/foreach-tlv-children [new file with mode: 0644]
src/tests/keywords/radius.conf

diff --git a/src/tests/keywords/foreach-tlv-children b/src/tests/keywords/foreach-tlv-children
new file mode 100644 (file)
index 0000000..44f8b27
--- /dev/null
@@ -0,0 +1,37 @@
+#
+#  PRE: foreach
+#
+#  Loop over children of a TLV.
+#
+#  Note that the only data types compatible with all data types are "string" or "octets"
+#
+string out
+
+&my-tlv := {
+       &a = 1
+       &b = 2
+       &c = "foo"
+       &d = 127.0.0.1
+}
+
+
+&out = ""
+
+#
+#  Home-brew concat!
+#
+foreach string child (&my-tlv.[*]) {
+       &out += &child
+       &out += " "
+}
+
+#
+#  Sad trailing space, but we can delete it!
+#
+&out -= ' '
+
+if (&out != '1 2 foo 127.0.0.1') {
+       test_fail
+}
+
+success
index 0b219702800feef3a1cecabec58f68fb03b805d1..3fc1e844b0620963cae1741d5a2938bdc33882fb 100644 (file)
@@ -135,6 +135,15 @@ server default {
                type = Access-Request
        }
 
+       dictionary {
+               tlv my-tlv {
+                       uint32 a
+                       uint32 b
+                       string c
+                       ipaddr d
+               }
+       }
+
        recv Access-Request {
                &control.Password.Cleartext := "hello"