]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
tests for nested edit groups
authorAlan T. DeKok <aland@freeradius.org>
Wed, 20 Jul 2022 18:41:38 +0000 (14:41 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 20 Jul 2022 18:41:38 +0000 (14:41 -0400)
src/tests/keywords/edit-nested [new file with mode: 0644]

diff --git a/src/tests/keywords/edit-nested b/src/tests/keywords/edit-nested
new file mode 100644 (file)
index 0000000..e81de6d
--- /dev/null
@@ -0,0 +1,80 @@
+#
+#  PRE: if edit-list
+#
+update control {
+       &User-Name := "foo"
+}
+
+#
+#  Create a nested group.
+#
+#  @todo - we only support ONE layer of nesting under &control,
+#  &request, etc. for now.  We should support more.
+#
+#  i.e. &control.Tmp-Group-0.Tmp-Group-1 := { ... } will NOT work.
+#
+#  There are also issues with changing dictionaries.  Putting RADIUS
+#  attributes into a Tmp-Group (internal dict) will work, but they
+#  cannot be referenced.
+#
+&control.Tmp-Group-0 := {
+       &Tmp-Integer-0 = 1
+}
+
+if (!&control.Tmp-Group-0.Tmp-Integer-0) {
+       test_fail;
+}
+
+if (&control.Tmp-Group-0.Tmp-Integer-0 != 1) {
+       test_fail;
+}
+
+#
+#  Edit it in place.
+#
+&control.Tmp-Group-0.Tmp-Integer-0 += 5
+
+if (&control.Tmp-Group-0.Tmp-Integer-0 != 6) {
+       test_fail;
+}
+
+#
+#  Delete it.
+#
+&control.Tmp-Group-0 -= &Tmp-Integer-0
+
+if (&control.Tmp-Group-0.Tmp-Integer-0) {
+       test_fail;
+}
+
+#
+#  @todo - there's no way to say "is group empty" :(
+#
+
+#
+#  Append something to it
+#
+&control.Tmp-Group-0 += {
+       &Tmp-IP-Address-0 = 127.0.0.1
+}
+
+if (&control.Tmp-Group-0.Tmp-IP-Address-0 != 127.0.0.1) {
+       test_fail;
+}
+
+#
+#  Multiple members
+#
+&control.Tmp-Group-0 += {
+       &Tmp-Octets-0 = 0xabcdef
+}
+
+if (&control.Tmp-Group-0.Tmp-IP-Address-0 != 127.0.0.1) {
+       test_fail;
+}
+
+if (&control.Tmp-Group-0.Tmp-Octets-0 != 0xabcdef) {
+       test_fail;
+}
+
+success