]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
v4: Define arguments for json xlats (#4027)
authorNick Porter <nick@portercomputing.co.uk>
Thu, 25 Mar 2021 10:14:55 +0000 (10:14 +0000)
committerGitHub <noreply@github.com>
Thu, 25 Mar 2021 10:14:55 +0000 (10:14 +0000)
* Define args for json xlats

* Update json tests to match new generic failure message

* Missing arguments will mean no child

* Simplify json encode tests

* Remove input argument errors from json encode test and create error test

* Correct ERROR handling for module tests

* Simplify unlang in json eval tests

* Simplify unlang in json parser tests

* Simplify unlang in json quote tests

* Enable 64bit json eval tests

src/lib/unlang/xlat_tokenize.c
src/modules/rlm_json/rlm_json.c
src/tests/modules/all.mk
src/tests/modules/json/encode.unlang
src/tests/modules/json/encode_error.attrs [new file with mode: 0644]
src/tests/modules/json/encode_error.unlang [new file with mode: 0644]
src/tests/modules/json/eval.unlang
src/tests/modules/json/parser.unlang
src/tests/modules/json/quote.unlang

index 491fc86304e3c258e014bc66a402f06f43908f12..483145a2840e455498301cb31283608b0c8adf01 100644 (file)
@@ -338,8 +338,7 @@ static inline int xlat_validate_function_mono(xlat_exp_t *node)
 {
        fr_assert(node->type == XLAT_FUNC);
 
-       if (node->call.func->args && node->call.func->args->required &&
-           (node->child->type == XLAT_LITERAL) && (talloc_array_length(node->child->fmt) == 1)) {
+       if (node->call.func->args && node->call.func->args->required && !node->child) {
                fr_strerror_const("Missing required input");
                return -1;
        }
index 705d9a5e2bb05ba5362eeb18f91b8cf63b0324d8..99fd6149faedd9668f9bfcd6fdc991c9974892fb 100644 (file)
@@ -90,6 +90,10 @@ typedef struct {
        json_object             *root;
 } rlm_json_jpath_to_eval_t;
 
+static xlat_arg_parser_t const json_quote_xlat_arg = {
+       .concat = true, .type = FR_TYPE_STRING
+};
+
 /** Ensure contents are quoted correctly for a JSON document
  *
  * @ingroup xlat_functions
@@ -110,12 +114,7 @@ static xlat_action_t json_quote_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, request
        fr_value_box_t *in_head = fr_dlist_head(in);
        char *tmp;
 
-       if (!in_head) return XLAT_ACTION_DONE;
-
-       if (fr_value_box_list_concat(ctx, in_head, in, FR_TYPE_STRING, true) < 0) {
-               RPEDEBUG("Failed concatenating input");
-               return XLAT_ACTION_FAIL;
-       }
+       if (!in_head) return XLAT_ACTION_DONE;  /* Empty input is allowed */
 
        MEM(vb = fr_value_box_alloc_null(ctx));
 
@@ -167,6 +166,10 @@ static ssize_t jpath_validate_xlat(UNUSED TALLOC_CTX *ctx, char **out, size_t ou
        return ret;
 }
 
+static xlat_arg_parser_t const json_encode_xlat_arg = {
+       .required = true, .concat = true, .type = FR_TYPE_STRING
+};
+
 /** Convert given attributes to a JSON document
  *
  * Usage is `%{json_encode:attr tmpl list}`
@@ -200,15 +203,6 @@ static xlat_action_t json_encode_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, reques
 
        fr_pair_list_init(&json_vps);
        fr_pair_list_init(&vps);
-       if (!in_head) {
-               REDEBUG("Missing attribute(s)");
-               return XLAT_ACTION_FAIL;
-       }
-
-       if (fr_value_box_list_concat(ctx, in_head, in, FR_TYPE_STRING, true) < 0) {
-               RPEDEBUG("Failed concatenating input");
-               return XLAT_ACTION_FAIL;
-       }
 
        sbuff = FR_SBUFF_IN(in_head->vb_strvalue, in_head->vb_length);
        fr_sbuff_adv_past_whitespace(&sbuff, SIZE_MAX, NULL);
@@ -297,7 +291,6 @@ static xlat_action_t json_encode_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, reques
        return XLAT_ACTION_DONE;
 }
 
-
 /** Pre-parse and validate literal jpath expressions for maps
  *
  * @param[in] cs       #CONF_SECTION that defined the map instance.
@@ -544,18 +537,20 @@ finish:
 static int mod_bootstrap(void *instance, CONF_SECTION *conf)
 {
        rlm_json_t              *inst = talloc_get_type_abort(instance, rlm_json_t);
-       xlat_t const            *xlat;
+       xlat_t                  *xlat;
        char                    *name;
        fr_json_format_t        *format = inst->format;
 
        inst->name = cf_section_name2(conf);
        if (!inst->name) inst->name = cf_section_name1(conf);
 
-       xlat_register(instance, "jsonquote", json_quote_xlat, false);
+       xlat = xlat_register(instance, "jsonquote", json_quote_xlat, false);
+       xlat_func_mono(xlat, &json_quote_xlat_arg);
        xlat_register_legacy(instance, "jpathvalidate", jpath_validate_xlat, NULL, NULL, 0, XLAT_DEFAULT_BUF_LEN);
 
        name = talloc_asprintf(inst, "%s_encode", inst->name);
        xlat = xlat_register(instance, name, json_encode_xlat, false);
+       xlat_func_mono(xlat, &json_encode_xlat_arg);
        xlat_async_instantiate_set(xlat, json_xlat_instantiate,
                                   rlm_json_t *, NULL, inst);
        talloc_free(name);
index 0375a3d201105ae42218c66ff091ab37ece16553..c9166f0f1596eb4a81e34a2c04ca6e332969228d 100644 (file)
@@ -99,7 +99,7 @@ $(OUTPUT)/%: $(DIR)/%.unlang $(TEST_BIN_DIR)/unit_test_module | build.raddb
                        echo "MODULE_TEST_DIR=$(dir $<) MODULE_TEST_UNLANG=$< $(TEST_BIN)/unit_test_module -D share/dictionary -d src/tests/modules/ -i \"$@.attrs\" -f \"$@.attrs\" -r \"$@\" -xx"; \
                        exit 1; \
                fi; \
-               FOUND=$$(grep ^$< $@.log | head -1 | sed 's/:.*//;s/.*\[//;s/\].*//'); \
+               FOUND=$$(grep -E 'Error : $<' $@.log | head -1 | sed 's/.*\[//;s/\].*//'); \
                EXPECTED=$$(grep -n ERROR $< | sed 's/:.*//'); \
                if [ "$$EXPECTED" != "$$FOUND" ]; then \
                        cat "$@.log"; \
index 202604941f3a04e5fbea52c2342925a6e4ce1ce7..86f70e0fbeccc9773e669abb4d69a75863de7292 100644 (file)
@@ -18,9 +18,7 @@ update request {
 }
 
 
-if (&Tmp-String-1 == '{"User-Name":{"type":"string","value":"john"},"Filter-Id":{"type":"string","value":["f1","f2"]},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '{"User-Name":{"type":"string","value":"john"},"Filter-Id":{"type":"string","value":["f1","f2"]},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
        test_fail
 }
 
@@ -37,15 +35,11 @@ if (&Tmp-String-1 != &Tmp-String-7 ||
        test_fail
 }
 
-if (&Tmp-String-5 == '{"User-Name":{"type":"string","value":"john"},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
-       test_pass
-} else {
+if (&Tmp-String-5 != '{"User-Name":{"type":"string","value":"john"},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
        test_fail
 }
 
-if (&Tmp-String-6 == '') {
-       test_pass
-} else {
+if (&Tmp-String-6 != '') {
        test_fail
 }
 
@@ -71,15 +65,11 @@ update request {
        &Tmp-String-2 := "%{json_object_ex_encode:&request[*]}"
 }
 
-if (&Tmp-String-1 == '{"User-Name":{"type":"string","value":"john"},"Filter-Id":{"type":"string","value":["f1","f2"]},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '{"User-Name":{"type":"string","value":"john"},"Filter-Id":{"type":"string","value":["f1","f2"]},"NAS-Port":{"type":"uint32","value":999},"Service-Type":{"type":"uint32","value":"Login-User"}}') {
        test_fail
 }
 
-if (&Tmp-String-2 == '{"pf:User-Name":{"type":"string","value":["john"]},"pf:Filter-Id":{"type":"string","value":["f1","f2"]},"pf:NAS-Port":{"type":"uint32","value":["999"]},"pf:Service-Type":{"type":"uint32","value":["1"]}}') {
-       test_pass
-} else {
+if (&Tmp-String-2 != '{"pf:User-Name":{"type":"string","value":["john"]},"pf:Filter-Id":{"type":"string","value":["f1","f2"]},"pf:NAS-Port":{"type":"uint32","value":["999"]},"pf:Service-Type":{"type":"uint32","value":["1"]}}') {
        test_fail
 }
 
@@ -87,24 +77,9 @@ if (&Tmp-String-2 == '{"pf:User-Name":{"type":"string","value":["john"]},"pf:Fil
 
 update request {
        &Tmp-String-1 := "%{json_object_encode:!&request[*]}"
-       &Tmp-String-2 := "%{json_object_ex_encode:}"
 }
 
-if (&Module-Failure-Message == 'Missing attribute(s)') {
-       test_pass
-} else {
-       test_fail
-}
-
-if (&Tmp-String-1 == '{}') {
-       test_pass
-} else {
-       test_fail
-}
-
-if (&Tmp-String-2 == '') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '{}') {
        test_fail
 }
 
@@ -122,15 +97,11 @@ update request {
        &Tmp-String-2 := "%{json_object_simple_ex_encode:&request[*]}"
 }
 
-if (&Tmp-String-1 == '{"User-Name":"john","Filter-Id":["f1","f2"],"NAS-Port":999,"Service-Type":"Login-User"}') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '{"User-Name":"john","Filter-Id":["f1","f2"],"NAS-Port":999,"Service-Type":"Login-User"}') {
        test_fail
 }
 
-if (&Tmp-String-2 == '{"pf:User-Name":["john"],"pf:Filter-Id":["f1","f2"],"pf:NAS-Port":["999"],"pf:Service-Type":["1"]}') {
-       test_pass
-} else {
+if (&Tmp-String-2 != '{"pf:User-Name":["john"],"pf:Filter-Id":["f1","f2"],"pf:NAS-Port":["999"],"pf:Service-Type":["1"]}') {
        test_fail
 }
 
@@ -138,24 +109,9 @@ if (&Tmp-String-2 == '{"pf:User-Name":["john"],"pf:Filter-Id":["f1","f2"],"pf:NA
 
 update request {
        &Tmp-String-1 := "%{json_object_simple_encode:!&request[*]}"
-       &Tmp-String-2 := "%{json_object_simple_ex_encode:}"
-}
-
-if (&Module-Failure-Message == 'Missing attribute(s)') {
-       test_pass
-} else {
-       test_fail
-}
-
-if (&Tmp-String-1 == '{}') {
-       test_pass
-} else {
-       test_fail
 }
 
-if (&Tmp-String-2 == '') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '{}') {
        test_fail
 }
 
@@ -173,15 +129,11 @@ update request {
        &Tmp-String-2 := "%{json_array_ex_encode:&request[*]}"
 }
 
-if (&Tmp-String-1 == '[{"name":"User-Name","type":"string","value":"john"},{"name":"Filter-Id","type":"string","value":"f1"},{"name":"Filter-Id","type":"string","value":"f2"},{"name":"NAS-Port","type":"uint32","value":999},{"name":"Service-Type","type":"uint32","value":"Login-User"}]') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '[{"name":"User-Name","type":"string","value":"john"},{"name":"Filter-Id","type":"string","value":"f1"},{"name":"Filter-Id","type":"string","value":"f2"},{"name":"NAS-Port","type":"uint32","value":999},{"name":"Service-Type","type":"uint32","value":"Login-User"}]') {
        test_fail
 }
 
-if (&Tmp-String-2 == '[{"name":"pf:User-Name","type":"string","value":["john"]},{"name":"pf:Filter-Id","type":"string","value":["f1","f2"]},{"name":"pf:NAS-Port","type":"uint32","value":["999"]},{"name":"pf:Service-Type","type":"uint32","value":["1"]}]') {
-       test_pass
-} else {
+if (&Tmp-String-2 != '[{"name":"pf:User-Name","type":"string","value":["john"]},{"name":"pf:Filter-Id","type":"string","value":["f1","f2"]},{"name":"pf:NAS-Port","type":"uint32","value":["999"]},{"name":"pf:Service-Type","type":"uint32","value":["1"]}]') {
        test_fail
 }
 
@@ -189,24 +141,9 @@ if (&Tmp-String-2 == '[{"name":"pf:User-Name","type":"string","value":["john"]},
 
 update request {
        &Tmp-String-1 := "%{json_array_encode:!&request[*]}"
-       &Tmp-String-2 := "%{json_array_ex_encode:}"
 }
 
-if (&Module-Failure-Message == 'Missing attribute(s)') {
-       test_pass
-} else {
-       test_fail
-}
-
-if (&Tmp-String-1 == '[]') {
-       test_pass
-} else {
-       test_fail
-}
-
-if (&Tmp-String-2 == '') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '[]') {
        test_fail
 }
 
@@ -224,15 +161,11 @@ update request {
        &Tmp-String-2 := "%{json_array_names_ex_encode:&request[*]}"
 }
 
-if (&Tmp-String-1 == '["User-Name","Filter-Id","Filter-Id","NAS-Port","Service-Type"]') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '["User-Name","Filter-Id","Filter-Id","NAS-Port","Service-Type"]') {
        test_fail
 }
 
-if (&Tmp-String-2 == '["pf:User-Name","pf:Filter-Id","pf:Filter-Id","pf:NAS-Port","pf:Service-Type"]') {
-       test_pass
-} else {
+if (&Tmp-String-2 != '["pf:User-Name","pf:Filter-Id","pf:Filter-Id","pf:NAS-Port","pf:Service-Type"]') {
        test_fail
 }
 
@@ -240,24 +173,9 @@ if (&Tmp-String-2 == '["pf:User-Name","pf:Filter-Id","pf:Filter-Id","pf:NAS-Port
 
 update request {
        &Tmp-String-1 := "%{json_array_names_encode:!&request[*]}"
-       &Tmp-String-2 := "%{json_array_names_ex_encode:}"
-}
-
-if (&Module-Failure-Message == 'Missing attribute(s)') {
-       test_pass
-} else {
-       test_fail
-}
-
-if (&Tmp-String-1 == '[]') {
-       test_pass
-} else {
-       test_fail
 }
 
-if (&Tmp-String-2 == '') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '[]') {
        test_fail
 }
 
@@ -275,15 +193,11 @@ update request {
        &Tmp-String-2 := "%{json_array_values_ex_encode:&request[*]}"
 }
 
-if (&Tmp-String-1 == '["john","f1","f2",999,"Login-User"]') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '["john","f1","f2",999,"Login-User"]') {
        test_fail
 }
 
-if (&Tmp-String-2 == '["john","f1","f2","999","1"]') {
-       test_pass
-} else {
+if (&Tmp-String-2 != '["john","f1","f2","999","1"]') {
        test_fail
 }
 
@@ -291,24 +205,9 @@ if (&Tmp-String-2 == '["john","f1","f2","999","1"]') {
 
 update request {
        &Tmp-String-1 := "%{json_array_values_encode:!&request[*]}"
-       &Tmp-String-2 := "%{json_array_values_ex_encode:}"
 }
 
-if (&Module-Failure-Message == 'Missing attribute(s)') {
-       test_pass
-} else {
-       test_fail
-}
-
-if (&Tmp-String-1 == '[]') {
-       test_pass
-} else {
-       test_fail
-}
-
-if (&Tmp-String-2 == '') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '[]') {
        test_fail
 }
 
@@ -330,3 +229,5 @@ update request {
 #          -e 's/^/if (/' \
 #          -e "s/\"$/') {/" \
 #          -e "s/$/\n  test_pass\n} else {\n   test_fail\n}\n/"
+
+test_pass
diff --git a/src/tests/modules/json/encode_error.attrs b/src/tests/modules/json/encode_error.attrs
new file mode 100644 (file)
index 0000000..d4179d2
--- /dev/null
@@ -0,0 +1,10 @@
+#
+#  Input packet
+#
+Packet-Type = Access-Request
+User-Name = 'john'
+
+#
+#  Expected answer
+#
+Packet-Type == Access-Accept
diff --git a/src/tests/modules/json/encode_error.unlang b/src/tests/modules/json/encode_error.unlang
new file mode 100644 (file)
index 0000000..33abfb3
--- /dev/null
@@ -0,0 +1,7 @@
+#
+#       json xlat input parsing test - error with no input
+#
+
+update request {
+       &Tmp-String-1 := "%{json_object_ex_encode:}"  # ERROR
+}
index 3e922d1cd25c0d3c1a397769dc2e03a80111d270..0ef43f91dce3ad1a98e0873c0d21d4065d1b02a9 100644 (file)
@@ -11,9 +11,7 @@ map json &Tmp-String-0 {
        &Tmp-String-1 := '$.foo'
 }
 
-if (&Tmp-String-1 == 'bar') {
-       test_pass
-} else {
+if (&Tmp-String-1 != 'bar') {
        test_fail
 }
 
@@ -43,51 +41,37 @@ map json &Tmp-String-0 {
 }
 
 # 1. Array type
-if (&Tmp-String-1[0] == '[ 0, 1, 2, 3, 4, 5 ]') {
-       test_pass
-} else {
+if (&Tmp-String-1[0] != '[ 0, 1, 2, 3, 4, 5 ]') {
        test_fail
 }
 
 # 2. Object type
-if (&Tmp-String-1[1] == '{ "foo": "bar", "num": 42 }') {
-       test_pass
-} else {
+if (&Tmp-String-1[1] != '{ "foo": "bar", "num": 42 }') {
        test_fail
 }
 
 # 3. Integer type
-if (&Tmp-String-1[2] == '99') {
-       test_pass
-} else {
+if (&Tmp-String-1[2] != '99') {
        test_fail
 }
 
 # 4. Double type
-if (&Tmp-String-1[3] == '5.9') {
-       test_pass
-} else {
+if (&Tmp-String-1[3] != '5.9') {
        test_fail
 }
 
 # 5. null type
-if (&Tmp-String-1[4] == 'null') {
-       test_pass
-} else {
+if (&Tmp-String-1[4] != 'null') {
        test_fail
 }
 
 # 6. Boolean true
-if (&Tmp-String-1[5] == 'yes') {
-       test_pass
-} else {
+if (&Tmp-String-1[5] != 'yes') {
        test_fail
 }
 
 # 7. Boolean false
-if (&Tmp-String-1[6] == 'no') {
-       test_pass
-} else {
+if (&Tmp-String-1[6] != 'no') {
        test_fail
 }
 
@@ -103,9 +87,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-String-1 := '$.my_array'
 }
-if (&Tmp-String-1 == '[ 0, 1, 2, 3, 4, 5 ]') {
-       test_pass
-} else {
+if (&Tmp-String-1 != '[ 0, 1, 2, 3, 4, 5 ]') {
        test_fail
 }
 update request {
@@ -116,9 +98,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 := '$.my_array[0]'
 }
-if (&Tmp-Integer-0 == 0) {
-       test_pass
-} else {
+if (&Tmp-Integer-0 != 0) {
        test_fail
 }
 update request {
@@ -129,9 +109,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 := '$.my_array[5]'       # Past the end of the array (should be skipped)
 }
-if (&Tmp-Integer-0 == 5) {
-       test_pass
-} else {
+if (&Tmp-Integer-0 != 5) {
        test_fail
 }
 update request {
@@ -142,9 +120,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 := '$.my_array[6]'       # Past the end of the array (should be skipped)
 }
-if (!&Tmp-Integer-0) {
-       test_pass
-} else {
+if (&Tmp-Integer-0) {
        test_fail
 }
 update request {
@@ -155,9 +131,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[0:2]'     # A single value
 }
-if ((&Tmp-Integer-0[0] == 0) && (&Tmp-Integer-0[1] == 1)) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 0) || (&Tmp-Integer-0[1] != 1)) {
        test_fail
 }
 update request {
@@ -168,9 +142,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[-1:6]'    # A single value (last eelement of the array)
 }
-if (&Tmp-Integer-0 == 5) {
-       test_pass
-} else {
+if (&Tmp-Integer-0 != 5) {
        test_fail
 }
 update request {
@@ -181,9 +153,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[-1:-3]'   # Start after end (should be skipped)
 }
-if (!&Tmp-Integer-0) {
-       test_pass
-} else {
+if (&Tmp-Integer-0) {
        test_fail
 }
 
@@ -191,9 +161,7 @@ if (!&Tmp-Integer-0) {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[1:-3]'
 }
-if ((&Tmp-Integer-0[0] == 1) && (&Tmp-Integer-0[1] == 2)) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 1) && (&Tmp-Integer-0[1] != 2)) {
        test_fail
 }
 update request {
@@ -204,9 +172,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[4:2:-1]'
 }
-if ((&Tmp-Integer-0[0] == 4) && (&Tmp-Integer-0[1] == 3)) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 4) || (&Tmp-Integer-0[1] != 3)) {
        test_fail
 }
 update request {
@@ -217,9 +183,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[2:4:-1]'
 }
-if (!&Tmp-Integer-0) {
-       test_pass
-} else {
+if (&Tmp-Integer-0) {
        test_fail
 }
 update request {
@@ -230,9 +194,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[2:4:1]'
 }
-if ((&Tmp-Integer-0[0] == 2) && (&Tmp-Integer-0[1] == 3)) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 2) || (&Tmp-Integer-0[1] != 3)) {
        test_fail
 }
 update request {
@@ -243,9 +205,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[1:5:2]'
 }
-if ((&Tmp-Integer-0[0] == 1) && (&Tmp-Integer-0[1] == 3)) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 1) && (&Tmp-Integer-0[1] != 3)) {
        test_fail
 }
 update request {
@@ -256,9 +216,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[1:5:4]'
 }
-if ((&Tmp-Integer-0[0] == 1) && !&Tmp-Integer-0[1]) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 1) || &Tmp-Integer-0[1]) {
        test_fail
 }
 update request {
@@ -269,9 +227,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[5:1:-4]'
 }
-if ((&Tmp-Integer-0[0] == 5) && !&Tmp-Integer-0[1]) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 5) || &Tmp-Integer-0[1]) {
        test_fail
 }
 update request {
@@ -282,9 +238,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[::3]'
 }
-if ((&Tmp-Integer-0[0] == 0) && (&Tmp-Integer-0[1] == 3) && !&Tmp-Integer-0[2]) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 0) || (&Tmp-Integer-0[1] != 3) || &Tmp-Integer-0[2]) {
        test_fail
 }
 update request {
@@ -295,9 +249,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[::-3]'
 }
-if ((&Tmp-Integer-0[0] == 5) && (&Tmp-Integer-0[1] == 2) && !&Tmp-Integer-0[2]) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 5) || (&Tmp-Integer-0[1] != 2) || &Tmp-Integer-0[2]) {
        test_fail
 }
 update request {
@@ -321,9 +273,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[3:0:-3]'
 }
-if ((&Tmp-Integer-0[0] == 3) && !&Tmp-Integer-0[1]) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 3) || &Tmp-Integer-0[1]) {
        test_fail
 }
 update request {
@@ -334,9 +284,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[0::-3]'
 }
-if ((&Tmp-Integer-0[0] == 0) && !&Tmp-Integer-0[1]) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 0) || &Tmp-Integer-0[1]) {
        test_fail
 }
 update request {
@@ -348,16 +296,14 @@ map json &Tmp-String-0 {
        &Tmp-String-1 += '$.*.*'
 }
 
-if ((&Tmp-String-1[0] == '0') && \
-    (&Tmp-String-1[1] == '1') && \
-    (&Tmp-String-1[2] == '2') && \
-    (&Tmp-String-1[3] == '3') && \
-    (&Tmp-String-1[4] == '4') && \
-    (&Tmp-String-1[5] == '5') && \
-    (&Tmp-String-1[6] == 'bar') && \
-    (&Tmp-String-1[7] == '42')) {
-       test_pass
-} else {
+if ((&Tmp-String-1[0] != '0') || \
+    (&Tmp-String-1[1] != '1') || \
+    (&Tmp-String-1[2] != '2') || \
+    (&Tmp-String-1[3] != '3') || \
+    (&Tmp-String-1[4] != '4') || \
+    (&Tmp-String-1[5] != '5') || \
+    (&Tmp-String-1[6] != 'bar') || \
+    (&Tmp-String-1[7] != '42')) {
        test_fail
 }
 
@@ -370,9 +316,7 @@ map json &Tmp-String-0 {
        &Tmp-String-1 += '$.*.*.*'
 }
 
-if (!&Tmp-String-1) {
-       test_pass
-} else {
+if (&Tmp-String-1) {
        test_fail
 }
 
@@ -381,9 +325,7 @@ map json &Tmp-String-0 {
        &Tmp-String-1 += '$.my_object[0]'
 }
 
-if (!&Tmp-String-1) {
-       test_pass
-} else {
+if (&Tmp-String-1) {
        test_fail
 }
 
@@ -392,9 +334,7 @@ map json &Tmp-String-0 {
        &Tmp-String-1 += '$.my_object.my_other_object'
 }
 
-if (!&Tmp-String-1) {
-       test_pass
-} else {
+if (&Tmp-String-1) {
        test_fail
 }
 
@@ -434,9 +374,7 @@ if (noop || ((&Tmp-Integer-0 == 4294967295) || (&Tmp-Integer-0 == 2147483647)))
 map json &Tmp-String-0 {
        &Tmp-Integer-0 := '$[3][0]'
 }
-if (&Tmp-Integer-0 == 2147483647) {
-       test_pass
-} else {
+if (&Tmp-Integer-0 != 2147483647) {
        test_fail
 }
 update request {
@@ -447,9 +385,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Signed-0 += '$[3][0,1]'
 }
-if ((&Tmp-Signed-0[0] == 2147483647) && (&Tmp-signed-0[1] == -2147483647)) {
-       test_pass
-} else {
+if ((&Tmp-Signed-0[0] != 2147483647) || (&Tmp-signed-0[1] != -2147483647)) {
        test_fail
 }
 update request {
@@ -463,9 +399,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += "$[3][%{Tmp-Integer-2}]"
 }
-if (&Tmp-Integer-0 == 2147483647) {
-       test_pass
-} else {
+if (&Tmp-Integer-0 != 2147483647) {
        test_fail
 }
 update request {
@@ -484,9 +418,7 @@ map json &Tmp-String-0 {
        &Tmp-String-1 := "$.%{Tmp-String-2}"
 }
 
-if (&Tmp-String-1 == 'baz') {
-       test_pass
-} else {
+if (&Tmp-String-1 != 'baz') {
        test_fail
 }
 update request {
@@ -523,9 +455,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-String-1 += '$..bool'
 }
-if (("%{Tmp-String-1[#]}" == 1) && (&Tmp-String-1 == 'yes')) {
-       test_pass
-} else {
+if (("%{Tmp-String-1[#]}" != 1) || (&Tmp-String-1 != 'yes')) {
        test_fail
 }
 update request {
@@ -536,9 +466,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-String-1 += '$..[1]'
 }
-if (("%{Tmp-String-1[#]}" == 3) && (&Tmp-String-1[0] == '1') && (&Tmp-String-1[1] == 'scratchy') && (&Tmp-String-1[2] == 'clawy')) {
-       test_pass
-} else {
+if (("%{Tmp-String-1[#]}" != 3) || (&Tmp-String-1[0] != '1') || (&Tmp-String-1[1] != 'scratchy') || (&Tmp-String-1[2] != 'clawy')) {
        test_fail
 }
 update request {
@@ -549,61 +477,54 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-String-1 += '$..my_cats[2]'
 }
-if (("%{Tmp-String-1[#]}" == 2) && (&Tmp-String-1[0] == 'flat') && (&Tmp-String-1[1] == 'woofy')) {
-       test_pass
-} else {
+if (("%{Tmp-String-1[#]}" != 2) || (&Tmp-String-1[0] != 'flat') || (&Tmp-String-1[1] != 'woofy')) {
        test_fail
 }
 update request {
        &Tmp-String-1 !* ANY
 }
 
-# Disabled until a json-c >= 0.10 is available in travis
-## xx. Unsigned 64bit integers
-#map json &Tmp-String-0 {
-#      &Tmp-Integer64-0 := '$[0]'
-#}
-#if (&Tmp-Integer64-0 == 9223372036854775807) {
-#      test_pass
-#} else {
-#      test_fail
-#}
-#update request {
-#      &Tmp-Integer64-0 !* ANY
-#}
-#
-## xx. Signed 64bit integers (not supported)
-#redundant {
-#      group {
-#              map json &Tmp-String-0 {
-#                      &Tmp-Integer64-0 := '$[1]'
-#              }
-#      }
-#      ok
-#}
-#if (!fail && !&Tmp-Integer64-0) {
-#      test_pass
-#} else {
-#      test_fail
-#}
-#update request {
-#      &Tmp-Integer64-0 !* ANY
-#}
-#
-## xx. Signed 64bit integers (not supported)
-#redundant {
-#      group {
-#              map json &Tmp-String-0 {
-#                      &Tmp-Integer64-0 := '$[1]'
-#              }
-#      }
-#      ok
-#}
-#if (!fail && !&Tmp-Integer64-0) {
-#      test_pass
-#} else {
-#      test_fail
-#}
-#update request {
-#      &Tmp-Integer64-0 !* ANY
-#}
+# 39. Unsigned 64bit integers
+map json &Tmp-String-0 {
+       &Tmp-Integer64-0 := '$[0]'
+}
+if (&Tmp-Integer64-0 != 9223372036854775807) {
+       test_fail
+}
+update request {
+       &Tmp-Integer64-0 !* ANY
+}
+
+# 40. Signed 64bit integers (not supported)
+redundant {
+       group {
+               map json &Tmp-String-0 {
+                       &Tmp-Integer64-0 := '$[1]'
+               }
+       }
+       ok
+}
+if (fail || &Tmp-Integer64-0) {
+       test_fail
+}
+update request {
+       &Tmp-Integer64-0 !* ANY
+}
+
+# 41. Signed 64bit integers (not supported)
+redundant {
+       group {
+               map json &Tmp-String-0 {
+                       &Tmp-Integer64-0 := '$[1]'
+               }
+       }
+       ok
+}
+if (fail || &Tmp-Integer64-0) {
+       test_fail
+}
+update request {
+       &Tmp-Integer64-0 !* ANY
+}
+
+test_pass
index 8406155695cf81a6a431f03f64cf926c36850b11..29ca29e7f93b45373fca6d00672c66f9fcd22fbb 100644 (file)
 #
 
 # 0. Expect success - Field selectors
-if ("%{jpathvalidate:$.foo.bar}" == '9:$.foo.bar') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo.bar}" != '9:$.foo.bar') {
        test_fail
 }
 
 # 1. Expect success - Field selectors
-if ("%{jpathvalidate:@.foo.bar}" == '9:@.foo.bar') {
-       test_pass
-} else {
+if ("%{jpathvalidate:@.foo.bar}" != '9:@.foo.bar') {
        test_fail
 }
 
 # 2. Expect success - Array selector
-if ("%{jpathvalidate:$.foo[1]}" == '8:$.foo[1]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[1]}" != '8:$.foo[1]') {
        test_fail
 }
 
 # 3. Expect success - Array selector
-if ("%{jpathvalidate:$.foo[1:2]}" == '10:$.foo[1:2]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[1:2]}" != '10:$.foo[1:2]') {
        test_fail
 }
 
 # 4. Expect success - Array slice selector
-if ("%{jpathvalidate:$.foo[:1]}" == '9:$.foo[:1]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[:1]}" != '9:$.foo[:1]') {
        test_fail
 }
 
 # 5. Expect success - Array slice selector
-if ("%{jpathvalidate:$.foo[1::1]}" == '11:$.foo[1::1]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[1::1]}" != '11:$.foo[1::1]') {
        test_fail
 }
 
 # 6. Expect success - Array step selector
-if ("%{jpathvalidate:$.foo[::2]}" == '10:$.foo[::2]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[::2]}" != '10:$.foo[::2]') {
        test_fail
 }
 
 # 7. Expect success - Array step selector
-if ("%{jpathvalidate:$.foo[1:1:2]}" == '12:$.foo[1:1:2]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[1:1:2]}" != '12:$.foo[1:1:2]') {
        test_fail
 }
 
 # 8. Expect success - Array multiple selectors
-if ("%{jpathvalidate:$.foo[1,1:1:2]}" == '14:$.foo[1,1:1:2]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[1,1:1:2]}" != '14:$.foo[1,1:1:2]') {
        test_fail
 }
 
 # 9. Expect success - Wildcard selector 1
-if ("%{jpathvalidate:$.*}" == '3:$.*') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.*}" != '3:$.*') {
        test_fail
 }
 
 # 10. Expect success - Wildcard selector 2
-if ("%{jpathvalidate:$.*.foo}" == '7:$.*.foo') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.*.foo}" != '7:$.*.foo') {
        test_fail
 }
 
 # 11. Expect success - Mixture of selectors
-if ("%{jpathvalidate:$.foo[::2].*.bar[::1]}" == '21:$.foo[::2].*.bar[::1]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[::2].*.bar[::1]}" != '21:$.foo[::2].*.bar[::1]') {
        test_fail
 }
 
 # 12. Expect success - Escape sequence
-if ("%{jpathvalidate:$.foo.bar\[\]}" == '13:$.foo.bar\[\]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo.bar\[\]}" != '13:$.foo.bar\[\]') {
        test_fail
 }
 
 # 13. Expect success - Non escape sequence
-if ("%{jpathvalidate:$.foo.bar\@}" == '11:$.foo.bar\@') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo.bar\@}" != '11:$.foo.bar\@') {
        test_fail
 }
 
 # 14. Expect failure - Invalid starting char
-if ("%{jpathvalidate:[.foo}" == '0:Expected root specifier \'$\', or current node specifier \'@\'') {
-       test_pass
-} else {
+if ("%{jpathvalidate:[.foo}" != '0:Expected root specifier \'$\', or current node specifier \'@\'') {
        test_fail
 }
 
 # 15. Expect failure - Invalid char following root specifier
-if ("%{jpathvalidate:$[]}" == '2:Empty selector') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$[]}" != '2:Empty selector') {
        test_fail
 }
 
 # 16. Expect failure - Invalid char following root specifier
-if ("%{jpathvalidate:$.}" == '2:Expected recursive descent \'..\' wildcard \'*\' or field specifier') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.}" != '2:Expected recursive descent \'..\' wildcard \'*\' or field specifier') {
        test_fail
 }
 
 # 17. Expect failure - Recursive descent after child delimiter
-if ("%{jpathvalidate:$...}" == '3:Recursive descent must not be followed by child delimiter \'.\'') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$...}" != '3:Recursive descent must not be followed by child delimiter \'.\'') {
        test_fail
 }
 
 # 18. Expect failure - Missing selector terminator
-if ("%{jpathvalidate:$.foo[}" == '6:Missing selector terminator \']\'') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[}" != '6:Missing selector terminator \']\'') {
        test_fail
 }
 
 # 19. Expect failure - Missing selector terminator
-if ("%{jpathvalidate:$.foo[0}" == '7:Missing selector delimiter \',\' or terminator \']\'') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[0}" != '7:Missing selector delimiter \',\' or terminator \']\'') {
        test_fail
 }
 
 # 20. Expect failure - Unexpected selector terminator
-if ("%{jpathvalidate:$.foo]}" == '5:Expected field specifier \'.\' or selector \'[\'') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo]}" != '5:Expected field specifier \'.\' or selector \'[\'') {
        test_fail
 }
 
 # 21. Expect failure - Empty selector
-if ("%{jpathvalidate:$.foo[,}" == '6:Empty selector') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[,}" != '6:Empty selector') {
        test_fail
 }
 
 # 22. Expect failure - Empty selector
-if ("%{jpathvalidate:$.foo[,]}" == '6:Empty selector') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[,]}" != '6:Empty selector') {
        test_fail
 }
 
 # 23. Expect failure - Empty selector
-if ("%{jpathvalidate:$.foo[]}" == '6:Empty selector') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[]}" != '6:Empty selector') {
        test_fail
 }
 
 # 24. Expect failure - Empty selector
-if ("%{jpathvalidate:$.foo[1,1:1:2,]}" == '14:Empty selector') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[1,1:1:2,]}" != '14:Empty selector') {
        test_fail
 }
 
 # 25. Expect failure - Bad array index
-if ("%{jpathvalidate:$.foo[a]}" == '6:Expected num, \':\' or \']\'') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[a]}" != '6:Expected num, \':\' or \']\'') {
        test_fail
 }
 
 # 26. Expect failure - Bad array end
-if ("%{jpathvalidate:$.foo[0:a]}" == '8:Expected num, \':\' or \']\'') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[0:a]}" != '8:Expected num, \':\' or \']\'') {
        test_fail
 }
 
 # 27. Expect failure - Bad array slice
-if ("%{jpathvalidate:$.foo[0:0:a]}" == '10:Expected num or \']\'') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[0:0:a]}" != '10:Expected num or \']\'') {
        test_fail
 }
 
 # 28. Expect failure - Bad array slice value
-if ("%{jpathvalidate:$.foo[0:0:0]}" == '10:Step cannot be 0') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[0:0:0]}" != '10:Step cannot be 0') {
        test_fail
 }
 
 # 29. Expect failure - Field too long
-if ("%{jpathvalidate:$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}" == '134:Exceeded maximum field name length') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}" != '134:Exceeded maximum field name length') {
        test_fail
 }
 
 # 30. Expect success - Field ok
-if ("%{jpathvalidate:$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}" == '134:$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}" != '134:$.foo.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') {
        test_fail
 }
 
 # 31. Expect failure - Empty field
-if ("%{jpathvalidate:$.foo.[]}" == '6:Empty field specifier') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo.[]}" != '6:Empty field specifier') {
        test_fail
 }
 
 # 32. Expect success - Nested array
-if ("%{jpathvalidate:$[0][1]}" == '7:$[0][1]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$[0][1]}" != '7:$[0][1]') {
        test_fail
 }
 
 # 33. Expect success - Nested array with multiple indicies
-if ("%{jpathvalidate:$[0][1,2]}" == '9:$[0][1,2]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$[0][1,2]}" != '9:$[0][1,2]') {
        test_fail
 }
 
 # 34. Expect failure - Recursive descent followed by nothing
-if ("%{jpathvalidate:$..}" == '2:Path may not end in recursive descent') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$..}" != '2:Path may not end in recursive descent') {
        test_fail
 }
 
 # 35. Expect success - Recursive descent followed by field
-if ("%{jpathvalidate:$..foo}" == '6:$..foo') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$..foo}" != '6:$..foo') {
        test_fail
 }
 
 # 36. Expect success - Recursive descent followed by selector
-if ("%{jpathvalidate:$..[0]}" == '6:$..[0]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$..[0]}" != '6:$..[0]') {
        test_fail
 }
 
 # 37. Expect success - Recursive descent followed by two selectors
-if ("%{jpathvalidate:$..foo[0]}" == '9:$..foo[0]') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$..foo[0]}" != '9:$..foo[0]') {
        test_fail
 }
 
 # 38. Expect success - Recursive descent followed by wildcard
-if ("%{jpathvalidate:$..*}" == '4:$..*') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$..*}" != '4:$..*') {
        test_fail
 }
 
 # 39. Expect failure - Filter expressions NYI
-if ("%{jpathvalidate:$.foo[?@.bar = baz]}" == '6:Filter expressions not yet implemented') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[?@.bar = baz]}" != '6:Filter expressions not yet implemented') {
        test_fail
 }
 
 # 40. Expect failure - Expressions NYI
-if ("%{jpathvalidate:$.foo[(@.bar = baz)]}" == '6:Expressions not yet implemented') {
-       test_pass
-} else {
+if ("%{jpathvalidate:$.foo[(@.bar = baz)]}" != '6:Expressions not yet implemented') {
        test_fail
 }
 
+test_pass
index 16a5e98ef87e7ec41d1045ff48b59ae34f3d9e32..58fe477f57dbc019cf6960f0f92081e8ef9be313 100644 (file)
@@ -12,15 +12,11 @@ update request {
 }
 
 # Check for correct escapes
-if (&Tmp-String-2 == 'foo\/bar') {
-       test_pass
-} else {
+if (&Tmp-String-2 != 'foo\/bar') {
        test_fail
 }
 
-if (&Tmp-String-3 == 'foo\"bar') {
-       test_pass
-} else {
+if (&Tmp-String-3 != 'foo\"bar') {
        test_fail
 }
 
@@ -35,17 +31,15 @@ update request {
        &Tmp-String-4 := "%{jsonquote:}"
 }
 
-if (&Tmp-String-4 == '') {
-       test_pass
-} else {
+if (&Tmp-String-4 != '') {
        test_fail
 }
 
 #
 #  Quoting nothing is not an error
 #
-if (!&Module-Failure-Message) {
-       test_pass
-} else {
+if (&Module-Failure-Message) {
        test_fail
 }
+
+test_pass
\ No newline at end of file