]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
tests and cleanups for logical and
authorAlan T. DeKok <aland@freeradius.org>
Tue, 4 Jul 2023 20:46:39 +0000 (16:46 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 4 Jul 2023 20:46:39 +0000 (16:46 -0400)
src/lib/unlang/xlat_expr.c
src/tests/keywords/logical-and [new file with mode: 0644]

index 054fb92fe6a8305dc52ca839af00eb584f5a803e..4371d9b32b4aeb88b8dd99c396a6484f24eb4cd3 100644 (file)
@@ -1219,14 +1219,11 @@ static xlat_action_t xlat_logical_resume(TALLOC_CTX *ctx, fr_dcursor_t *out,
                rctx->box->vb_bool = false;
 
                /*
-                *      Try for another match, if possible.
+                *      we didn't match, (&&), so we're done.
                 */
-               if (inst->stop_on_match) goto next;
-
-               goto done;
+               if (!inst->stop_on_match) goto done;
        }
 
-next:
        fr_value_box_list_talloc_free(&rctx->list);
        rctx->current++;
 
diff --git a/src/tests/keywords/logical-and b/src/tests/keywords/logical-and
new file mode 100644 (file)
index 0000000..fd67fe6
--- /dev/null
@@ -0,0 +1,30 @@
+#
+#  PRE: edit
+#
+&request += {
+       &Tmp-Integer-0 = 0
+       &Tmp-Integer-1 = 1
+}
+
+#
+#  ! (true && true) --> false
+#
+if !((&Tmp-Integer-0 == 0) && (&Tmp-Integer-1 == 1)) {
+       test_fail
+}
+
+#
+#  false && true --> false
+#
+if ((&Tmp-Integer-0 == 1) && (&Tmp-Integer-1 == 1)) {
+       test_fail
+}
+
+#
+#  true && false -> false
+#
+if ((&Tmp-Integer-0 == 0) && (&Tmp-Integer-1 == 0)) {
+       test_fail
+}
+
+success