From: Alan T. DeKok Date: Mon, 9 Sep 2024 21:10:10 +0000 (-0400) Subject: Revert "Revert "add test looping over children of a TLV"" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b9c181c448fa4397712a06f83e8d28f9a04fea1;p=thirdparty%2Ffreeradius-server.git Revert "Revert "add test looping over children of a TLV"" This reverts commit e9f45f88c36001cf8bb2534068eb8563b2130ba0. --- diff --git a/src/tests/keywords/foreach-tlv-children b/src/tests/keywords/foreach-tlv-children new file mode 100644 index 00000000000..44f8b27a044 --- /dev/null +++ b/src/tests/keywords/foreach-tlv-children @@ -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 diff --git a/src/tests/keywords/radius.conf b/src/tests/keywords/radius.conf index 0b219702800..3fc1e844b06 100644 --- a/src/tests/keywords/radius.conf +++ b/src/tests/keywords/radius.conf @@ -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"