]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add tests of if using nested && and ||
authorNick Porter <nick@portercomputing.co.uk>
Wed, 7 Feb 2024 10:27:57 +0000 (10:27 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 7 Feb 2024 10:27:57 +0000 (10:27 +0000)
src/tests/keywords/if-nested-logic [new file with mode: 0644]

diff --git a/src/tests/keywords/if-nested-logic b/src/tests/keywords/if-nested-logic
new file mode 100644 (file)
index 0000000..bf8d0da
--- /dev/null
@@ -0,0 +1,38 @@
+#
+# PRE: if
+#
+
+&request += {
+       &Filter-Id = 'foo'
+       &Filter-Id = 'bar'
+}
+
+if !(&NAS-Port || &Filter-Id) {
+       test_fail
+}
+
+if !(!(!(&Filter-Id))) {
+       test_fail
+}
+
+if (&Filter-Id[0] && &Filter-Id[1] && &Filter-Id[2]) {
+       test_fail
+}
+
+if !(((&Filter-Id[0] == 'baz') && (&Filter-Id[1] == 'boing')) || ((&Filter-Id[0] == 'foo') && (&Filter-Id[1] == 'bar')))  {
+       test_fail
+}
+
+if !(((&Filter-Id[0] == 'foo') && (&Filter-Id[1] == 'boing')) || ((&Filter-Id[0] == 'foo') && (&Filter-Id[1] == 'bar')))  {
+       test_fail
+}
+
+if !((&NAS-Port || &Filter-Id) && (&Calling-Station-Id || &User-Name)) {
+       test_fail
+}
+
+if !(((&NAS-Port || &Filter-Id) && !&User-Name) || (&Calling-Station-Id || &User-Name)) {
+       test_fail
+}
+
+success