]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Register instance specific module xlats as <instance>.<function>
authorNick Porter <nick@portercomputing.co.uk>
Fri, 19 May 2023 16:14:25 +0000 (17:14 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 19 May 2023 18:35:45 +0000 (14:35 -0400)
18 files changed:
doc/antora/modules/raddb/pages/mods-available/json.adoc
raddb/mods-available/json
src/lib/unlang/xlat_func.c
src/modules/rlm_cipher/rlm_cipher.c
src/modules/rlm_escape/rlm_escape.c
src/modules/rlm_json/rlm_json.c
src/modules/rlm_redis/rlm_redis.c
src/tests/keywords/escape
src/tests/modules/cipher/fingerprint.unlang
src/tests/modules/cipher/rsa_encrypt_decrypt.unlang
src/tests/modules/cipher/rsa_sign_verify.unlang
src/tests/modules/cipher/serial.unlang
src/tests/modules/cipher/valid.unlang
src/tests/modules/json/encode.unlang
src/tests/modules/redis/cluster_key.unlang
src/tests/modules/redis/cluster_node_fail.unlang
src/tests/modules/redis/cluster_reset.inc
src/tests/modules/rest/rest_xlat.unlang

index a15fab909a84265a496c831a6f901e1091b71bba..0ef06abf63d076a20b4719e0c3443d56e3696f44 100644 (file)
@@ -77,7 +77,7 @@ map json "%(rest:GET http://example.org/api/user/%{User-Name})" {
 
 
 The only options for the JSON module are to control the output
-format of the `json_encode` xlat.
+format of the `json.encode` xlat.
 
 
 
@@ -187,7 +187,7 @@ Escapes string for use as a JSON string.
 The string caipirinha/gelada should be caipirinha\\/gelada to be a valid JSON string.
 ```
 
-### %{json_encode:...}
+### %{json.encode:...}
 
 Generates a JSON document from a given list of attribute templates. The
 format of document generated can be controlled with the 'encode' section in
@@ -210,7 +210,7 @@ it, `link:https://freeradius.org/rfc/rfc2865.html#User-Name[User-Name]` and `lin
 .Example
 
 ```
-%{json_encode:&User-Name &Calling-Station-Id}
+%{json.encode:&User-Name &Calling-Station-Id}
 ```
 
 The following will include all attributes in the RADIUS request, except for
@@ -219,7 +219,7 @@ The following will include all attributes in the RADIUS request, except for
 .Example
 
 ```
-%{json_encode:&request[*] !&User-Password}
+%{json.encode:&request[*] !&User-Password}
 ```
 
 In another (contrived) example, all the attributes in the RADIUS request will
@@ -229,7 +229,7 @@ be included in the document, _except_ any attributes in the RADIUS reply.
 .Example
 
 ```
-%{json_encode:&request[*] !&reply[*] &control.User-Name}
+%{json.encode:&request[*] !&reply[*] &control.User-Name}
 ```
 
 #### Output format modes
index 5bfad2bbb3d68ecdab925def6a69a071636cd0a4..f9028642300ceeeca5da83b7c44cc3da8f900104 100644 (file)
@@ -81,7 +81,7 @@ json {
 
        #
        #  The only options for the JSON module are to control the output
-       #  format of the `json_encode` xlat.
+       #  format of the `json.encode` xlat.
        #
        encode {
 
@@ -204,7 +204,7 @@ json {
 #  The string caipirinha/gelada should be caipirinha\\/gelada to be a valid JSON string.
 #  ```
 #
-#  ### %{json_encode:...}
+#  ### %{json.encode:...}
 #
 #  Generates a JSON document from a given list of attribute templates. The
 #  format of document generated can be controlled with the 'encode' section in
@@ -227,7 +227,7 @@ json {
 #  .Example
 #
 #  ```
-#  %{json_encode:&User-Name &Calling-Station-Id}
+#  %{json.encode:&User-Name &Calling-Station-Id}
 #  ```
 #
 #  The following will include all attributes in the RADIUS request, except for
@@ -236,7 +236,7 @@ json {
 #  .Example
 #
 #  ```
-#  %{json_encode:&request[*] !&User-Password}
+#  %{json.encode:&request[*] !&User-Password}
 #  ```
 #
 #  In another (contrived) example, all the attributes in the RADIUS request will
@@ -246,7 +246,7 @@ json {
 #  .Example
 #
 #  ```
-#  %{json_encode:&request[*] !&reply[*] &control.User-Name}
+#  %{json.encode:&request[*] !&reply[*] &control.User-Name}
 #  ```
 #
 #  #### Output format modes
index 5de229bab30c4a6d356c72e20046a1515e0ea7b7..c5b24c589d189afdb0285494d82f39e21d18de7e 100644 (file)
@@ -173,6 +173,7 @@ xlat_t *xlat_func_register_module(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx
 {
        xlat_t  *c;
        module_inst_ctx_t *our_mctx = NULL;
+       char inst_name[256];
 
        fr_assert(xlat_root);
 
@@ -181,6 +182,15 @@ xlat_t *xlat_func_register_module(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx
                return NULL;
        }
 
+       /*
+        *      Name xlats other than those which are just the module instance
+        *      as <instance name>.<function name>
+        */
+       if (mctx && name != mctx->inst->name) {
+               snprintf(inst_name, sizeof(inst_name), "%s.%s", mctx->inst->name, name);
+               name = inst_name;
+       }
+
        /*
         *      If it already exists, replace the instance.
         */
index 8729bf1e412a1c29d7501c1cda01eaf90fa630ca..6abfe0b480c67dfd27d47d495194364fa375e2e5 100644 (file)
@@ -575,7 +575,7 @@ static xlat_arg_parser_t const cipher_rsa_encrypt_xlat_arg[] = {
  * Arguments are @verbatim(<plaintext>...)@endverbatim
  *
 @verbatim
-%{<inst>_encrypt:<plaintext>...}
+%{<inst>.encrypt:<plaintext>...}
 @endverbatim
  *
  * If multiple arguments are provided they will be concatenated.
@@ -636,7 +636,7 @@ static xlat_arg_parser_t const cipher_rsa_sign_xlat_arg[] = {
  * Arguments are @verbatim(<plaintext>...)@endverbatim
  *
 @verbatim
-%{<inst>_sign:<plaintext>...}
+%{<inst>.sign:<plaintext>...}
 @endverbatim
  *
  * If multiple arguments are provided they will be concatenated.
@@ -714,7 +714,7 @@ static xlat_arg_parser_t const cipher_rsa_decrypt_xlat_arg[] = {
  * Arguments are @verbatim(<ciphertext\>...)@endverbatim
  *
 @verbatim
-%{<inst>_decrypt:<ciphertext>...}
+%{<inst>.decrypt:<ciphertext>...}
 @endverbatim
  *
  * If multiple arguments are provided they will be concatenated.
@@ -775,7 +775,7 @@ static xlat_arg_parser_t const cipher_rsa_verify_xlat_arg[] = {
  * Arguments are @verbatim(<signature>, <plaintext>...)@endverbatim
  *
 @verbatim
-%(<inst>_verify:<signature> <plaintext>...)
+%(<inst>.verify:<signature> <plaintext>...)
 @endverbatim
  *
  * If multiple arguments are provided (after @verbatim<signature>@endverbatim)
@@ -890,7 +890,7 @@ static xlat_arg_parser_t const cipher_certificate_xlat_args[] = {
  * Arguments are @verbatim(<digest>)@endverbatim
  *
 @verbatim
-%(<inst>_certificate:fingerprint <digest>)
+%(<inst>.certificate:fingerprint <digest>)
 @endverbatim
  *
  * @ingroup xlat_functions
@@ -939,7 +939,7 @@ static xlat_action_t cipher_fingerprint_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
 /** Return the serial of the public certificate
  *
 @verbatim
-%(<inst>_certificate:serial)
+%(<inst>.certificate:serial)
 @endverbatim
  *
  * @ingroup xlat_functions
@@ -1293,28 +1293,22 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
                }
 
                if (inst->rsa->private_key_file) {
-                       char *xlat_name;
                        xlat_t *xlat;
 
                        /*
                         *      Register decrypt xlat
                         */
-                       xlat_name = talloc_asprintf(inst, "%s_decrypt", mctx->inst->name);
-                       xlat = xlat_func_register_module(inst, mctx, xlat_name, cipher_rsa_decrypt_xlat, FR_TYPE_STRING);
+                       xlat = xlat_func_register_module(inst, mctx, "decrypt", cipher_rsa_decrypt_xlat, FR_TYPE_STRING);
                        xlat_func_mono_set(xlat, cipher_rsa_decrypt_xlat_arg);
-                       talloc_free(xlat_name);
 
                        /*
                         *      Verify sign xlat
                         */
-                       xlat_name = talloc_asprintf(inst, "%s_verify", mctx->inst->name);
-                       xlat = xlat_func_register_module(inst, mctx, xlat_name, cipher_rsa_verify_xlat, FR_TYPE_BOOL);
+                       xlat = xlat_func_register_module(inst, mctx, "verify", cipher_rsa_verify_xlat, FR_TYPE_BOOL);
                        xlat_func_args_set(xlat, cipher_rsa_verify_xlat_arg);
-                       talloc_free(xlat_name);
                }
 
                if (inst->rsa->certificate_file) {
-                       char *xlat_name;
                        xlat_t *xlat;
 
                        /*
@@ -1336,28 +1330,21 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
                        /*
                         *      Register encrypt xlat
                         */
-                       xlat_name = talloc_asprintf(inst, "%s_encrypt", mctx->inst->name);
-                       xlat = xlat_func_register_module(inst, mctx, xlat_name, cipher_rsa_encrypt_xlat, FR_TYPE_OCTETS);
+                       xlat = xlat_func_register_module(inst, mctx, "encrypt", cipher_rsa_encrypt_xlat, FR_TYPE_OCTETS);
                        xlat_func_mono_set(xlat, cipher_rsa_encrypt_xlat_arg);
-                       talloc_free(xlat_name);
 
                        /*
                         *      Register sign xlat
                         */
-                       xlat_name = talloc_asprintf(inst, "%s_sign", mctx->inst->name);
-                       xlat = xlat_func_register_module(inst, mctx, xlat_name, cipher_rsa_sign_xlat, FR_TYPE_OCTETS);
+                       xlat = xlat_func_register_module(inst, mctx, "sign", cipher_rsa_sign_xlat, FR_TYPE_OCTETS);
                        xlat_func_mono_set(xlat, cipher_rsa_sign_xlat_arg);
-                       talloc_free(xlat_name);
 
                        /*
                         *      FIXME: These should probably be split into separate xlats
                         *      so we can optimise for return types.
                         */
-                       xlat_name = talloc_asprintf(inst, "%s_certificate", mctx->inst->name);
-                       xlat = xlat_func_register_module(inst, mctx, xlat_name, cipher_certificate_xlat, FR_TYPE_VOID);
+                       xlat = xlat_func_register_module(inst, mctx, "certificate", cipher_certificate_xlat, FR_TYPE_VOID);
                        xlat_func_args_set(xlat, cipher_certificate_xlat_args);
-
-                       talloc_free(xlat_name);
                }
                break;
 
index dc1cc5c5ffe04bcabaf2d1a45b81f13cb66a366a..82f707d48e2c1c03b29f17c3700a8dfb0580ba65 100644 (file)
@@ -193,18 +193,15 @@ static xlat_action_t unescape_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
  */
 static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       char            *unescape;
        xlat_t          *xlat;
 
-       MEM(unescape = talloc_asprintf(NULL, "un%s", mctx->inst->name));
-       xlat = xlat_func_register_module(NULL, mctx, mctx->inst->name, escape_xlat, FR_TYPE_STRING);
+       xlat = xlat_func_register_module(NULL, mctx, "escape", escape_xlat, FR_TYPE_STRING);
        xlat_func_mono_set(xlat, escape_xlat_arg);
        xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE);
 
-       xlat = xlat_func_register_module(NULL, mctx, unescape, unescape_xlat, FR_TYPE_STRING);
+       xlat = xlat_func_register_module(NULL, mctx, "unescape", unescape_xlat, FR_TYPE_STRING);
        xlat_func_mono_set(xlat, unescape_xlat_arg);
        xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE);
-       talloc_free(unescape);
 
        return 0;
 }
index eac3de93d905196aca8439ff05792515767afa78..d7ccd80e601104feb9a47a9b69fb04ba94bafbb2 100644 (file)
@@ -161,7 +161,7 @@ static xlat_arg_parser_t const json_encode_xlat_arg[] = {
 
 /** Convert given attributes to a JSON document
  *
- * Usage is `%{json_encode:attr tmpl list}`
+ * Usage is `%{json.encode:attr tmpl list}`
  *
  * @ingroup xlat_functions
  */
@@ -528,13 +528,10 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        rlm_json_t              *inst = talloc_get_type_abort(mctx->inst->data, rlm_json_t);
        CONF_SECTION            *conf = mctx->inst->conf;
        xlat_t                  *xlat;
-       char                    *name;
        fr_json_format_t        *format = inst->format;
 
-       name = talloc_asprintf(inst, "%s_encode", mctx->inst->name);
-       xlat = xlat_func_register_module(inst, mctx, name, json_encode_xlat, FR_TYPE_STRING);
+       xlat = xlat_func_register_module(inst, mctx, "encode", json_encode_xlat, FR_TYPE_STRING);
        xlat_func_mono_set(xlat, json_encode_xlat_arg);
-       talloc_free(name);
 
        /*
         *      Check the output format type and warn on unused
index e443bb65af23ae5e846faa98d682c5e11b8b0420..bdbbeabd4f877b7bb5e2a2d38e971730d27e49d9 100644 (file)
@@ -239,7 +239,7 @@ static xlat_arg_parser_t const redis_remap_xlat_args[] = {
 /** Force a redis cluster remap
  *
 @verbatim
-%{redis_remap:<redis server ip>:<redis server port>}
+%{redis.remap:<redis server ip>:<redis server port>}
 @endverbatim
  *
  * @ingroup xlat_functions
@@ -301,7 +301,7 @@ static xlat_arg_parser_t const redis_node_xlat_args[] = {
 /** Return the node that is currently servicing a particular key
  *
 @verbatim
-%(redis_node:<key> [<index>])
+%(redis.node:<key> [<index>])
 @endverbatim
  *
  * @ingroup xlat_functions
@@ -856,35 +856,28 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
 static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
        rlm_redis_t     *inst = talloc_get_type_abort(mctx->inst->data, rlm_redis_t);
-       char            *name;
        xlat_t          *xlat;
 
        xlat = xlat_func_register_module(inst, mctx, mctx->inst->name, redis_xlat, FR_TYPE_VOID);
        xlat_func_args_set(xlat, redis_args);
 
        /*
-        *      %(redis_node:<key>[ idx])
+        *      %(redis.node:<key>[ idx])
         */
-       name = talloc_asprintf(NULL, "%s_node", mctx->inst->name);
-       if (unlikely((xlat = xlat_func_register_module(inst, mctx, name, redis_node_xlat, FR_TYPE_STRING)) == NULL)) return -1;
+       if (unlikely((xlat = xlat_func_register_module(inst, mctx, "node", redis_node_xlat, FR_TYPE_STRING)) == NULL)) return -1;
        xlat_func_args_set(xlat, redis_node_xlat_args);
-       talloc_free(name);
 
-       name = talloc_asprintf(NULL, "%s_remap", mctx->inst->name);
-       if (unlikely((xlat = xlat_func_register_module(inst, mctx, name, redis_remap_xlat, FR_TYPE_STRING)) == NULL)) return -1;
+       if (unlikely((xlat = xlat_func_register_module(inst, mctx, "remap", redis_remap_xlat, FR_TYPE_STRING)) == NULL)) return -1;
        xlat_func_args_set(xlat, redis_remap_xlat_args);
-       talloc_free(name);
 
        /*
         *      Loop over the lua functions, registering an xlat
         *      that'll call that function specifically.
         */
        talloc_foreach(inst->lua.funcs, func) {
-               name = talloc_asprintf(NULL, "%s.%s", mctx->inst->name, func->name);
-               if (unlikely((xlat = xlat_func_register_module(inst, mctx, name, redis_lua_func_xlat, FR_TYPE_VOID)) == NULL)) return -1;
+               if (unlikely((xlat = xlat_func_register_module(inst, mctx, func->name, redis_lua_func_xlat, FR_TYPE_VOID)) == NULL)) return -1;
                xlat_func_args_set(xlat, redis_lua_func_args);
                xlat_func_async_instantiate_set(xlat, redis_lua_func_instantiate, redis_lua_func_inst_t, NULL, func);
-               talloc_free(name);
        }
 
        return 0;
index 8af127cd3392c35de568cfcbd312168c5263c5e8..60f6f1ddb1a156a7c2aaeefec6d64db33f44e446 100644 (file)
 # = not followed by hex and without 2 following chars
 &Tmp-String-8 := 'a=Az=y'
 
-if (!(<string>"%{escape:%{Tmp-String-0}}" == &Tmp-String-0)) {
+if (!(<string>"%{escape.escape:%{Tmp-String-0}}" == &Tmp-String-0)) {
        test_fail
 }
 
-if (!(<string>"%{escape:%{Tmp-String-1}}" == &Tmp-String-3)) {
+if (!(<string>"%{escape.escape:%{Tmp-String-1}}" == &Tmp-String-3)) {
        test_fail
 }
 
-if (!(<string>"%{escape:%{Tmp-String-2}}" == &Tmp-String-4)) {
+if (!(<string>"%{escape.escape:%{Tmp-String-2}}" == &Tmp-String-4)) {
        test_fail
 }
 
-if (!(<string>"%{unescape:%{Tmp-String-0}}" == &Tmp-String-0)) {
+if (!(<string>"%{escape.unescape:%{Tmp-String-0}}" == &Tmp-String-0)) {
        test_fail
 }
 
-if (!(<string>"%{unescape:%{Tmp-String-3}}" == "%{Tmp-String-1}")) {
+if (!(<string>"%{escape.unescape:%{Tmp-String-3}}" == "%{Tmp-String-1}")) {
        test_fail
 }
 
-if (!(<string>"%{unescape:%{Tmp-String-4}}" == &Tmp-String-2)) {
+if (!(<string>"%{escape.unescape:%{Tmp-String-4}}" == &Tmp-String-2)) {
        test_fail
 }
 
-if (!(<string>"%{escape:%{Tmp-String-6}}" == &Tmp-String-7)) {
+if (!(<string>"%{escape.escape:%{Tmp-String-6}}" == &Tmp-String-7)) {
        test_fail
 }
 
-if (!(<string>"%{unescape:%{Tmp-String-7}}" == &Tmp-String-6)) {
+if (!(<string>"%{escape.unescape:%{Tmp-String-7}}" == &Tmp-String-6)) {
        test_fail
 }
 
-if (!(<string>"%{unescape:%{Tmp-String-8}}" == &Tmp-String-8)) {
+if (!(<string>"%{escape.unescape:%{Tmp-String-8}}" == &Tmp-String-8)) {
        test_fail
 }
 
index ce1b69a61b3d181f8b1d984bef8da2089d9b1dd6..83ae8deda3c3021412ef357dd151e64e45323220 100644 (file)
@@ -2,7 +2,7 @@
 #  We can't really check the values here as the certs change periodically
 #  but we can test the digest length, and for smoke...
 #
-&Tmp-Octets-0 := "%(cipher_rsa_certificate:fingerprint sha1)"
+&Tmp-Octets-0 := "%(cipher_rsa.certificate:fingerprint sha1)"
 
 if ("%(length:%{Tmp-Octets-0})" != 20) {
        test_fail
@@ -10,7 +10,7 @@ if ("%(length:%{Tmp-Octets-0})" != 20) {
        test_pass
 }
 
-&Tmp-Octets-0 := "%(cipher_rsa_certificate:fingerprint sha256)"
+&Tmp-Octets-0 := "%(cipher_rsa.certificate:fingerprint sha256)"
 
 if ("%(length:%{Tmp-Octets-0})" != 32) {
        test_fail
index d7c5942d8d562599f454b93e9904b613f956bef1..e86dfac24a89249408526d1b182bb7a072111edc 100644 (file)
@@ -1,5 +1,5 @@
 &Tmp-String-0 := "Hello world!"
-&Tmp-Octets-0 := "%{cipher_rsa_encrypt:%{Tmp-String-0}}"
+&Tmp-Octets-0 := "%{cipher_rsa.encrypt:%{Tmp-String-0}}"
 
 if (!&Tmp-Octets-0) {
        test_fail
@@ -15,7 +15,7 @@ else {
        test_pass
 }
 
-&Tmp-String-1 := "%{cipher_rsa_decrypt:%{Tmp-Octets-0}}"
+&Tmp-String-1 := "%{cipher_rsa.decrypt:%{Tmp-Octets-0}}"
 
 if (&Tmp-String-0 != &Tmp-String-1) {
        test_fail
@@ -27,7 +27,7 @@ else {
 #
 #  Padding scheme should ensure ciphertext is not consistent
 #
-&Tmp-Octets-1 := "%{cipher_rsa_encrypt:%{Tmp-String-0}}"
+&Tmp-Octets-1 := "%{cipher_rsa.encrypt:%{Tmp-String-0}}"
 
 if (&Tmp-Octets-0 == &Tmp-Octets-1) {
        test_fail
@@ -40,7 +40,7 @@ else {
 #  Repeat tests to ensure there are no issues with EVP_PKEY_CTX reuse
 #
 &Tmp-String-0 := "Goodbye world!"
-&Tmp-Octets-0 := "%{cipher_rsa_encrypt:%{Tmp-String-0}}"
+&Tmp-Octets-0 := "%{cipher_rsa.encrypt:%{Tmp-String-0}}"
 
 if (!&Tmp-Octets-0) {
        test_fail
@@ -56,7 +56,7 @@ else {
        test_pass
 }
 
-&Tmp-String-1 := "%{cipher_rsa_decrypt:%{Tmp-Octets-0}}"
+&Tmp-String-1 := "%{cipher_rsa.decrypt:%{Tmp-Octets-0}}"
 
 if (&Tmp-String-0 != &Tmp-String-1) {
        test_fail
index 3c19bb850ba4866e2f7a3c49b4cf20ed4239d77c..5325fc66c03370d07467179d7af60d0f2962770a 100644 (file)
@@ -1,86 +1,64 @@
 &Tmp-String-0 := "Hello world!"
-&Tmp-Octets-0 := "%{cipher_rsa_sign:%{Tmp-String-0}}"
+&Tmp-Octets-0 := "%{cipher_rsa.sign:%{Tmp-String-0}}"
 
 if (!&Tmp-Octets-0) {
        test_fail
 }
-else {
-       test_pass
-}
 
 if (<octets>&Tmp-String-0[0] == &Tmp-Octets-0[0]) {
        test_fail
 }
-else {
-       test_pass
-}
 
 #
 #  Pass the signature and the original message to the verification function
 #
-&Tmp-String-0 := "%(cipher_rsa_verify:%{Tmp-Octets-0} %{Tmp-String-0})"
+&Tmp-String-0 := "%(cipher_rsa.verify:%{Tmp-Octets-0} %{Tmp-String-0})"
 
 if (&Tmp-String-0 != 'yes') {
        test_fail
 }
-else {
-       test_pass
-}
 
 #
 #  Verification should now fail
 #
 &Tmp-String-0 := "Goodbye world!"
-&Tmp-String-0 := "%(cipher_rsa_verify:%{Tmp-Octets-0} %{Tmp-String-0})"
+&Tmp-String-0 := "%(cipher_rsa.verify:%{Tmp-Octets-0} %{Tmp-String-0})"
 
 if (&Tmp-String-0 != 'no') {
        test_fail
 }
-else {
-       test_pass
-}
 
 #
 #  Repeat tests to ensure there are no issues with EVP_PKEY_CTX reuse
 #
 &Tmp-String-0 := "Hello nurse!"
-&Tmp-Octets-0 := "%{cipher_rsa_sign:%{Tmp-String-0}}"
+&Tmp-Octets-0 := "%{cipher_rsa.sign:%{Tmp-String-0}}"
 
 if (!&Tmp-Octets-0) {
        test_fail
 }
-else {
-       test_pass
-}
 
 if (<octets>&Tmp-String-0[0] == &Tmp-Octets-0[0]) {
        test_fail
 }
-else {
-       test_pass
-}
 
 #
 #  Pass the signature and the original message to the verification function
 #
-&Tmp-String-0 := "%(cipher_rsa_verify:%{Tmp-Octets-0} %{Tmp-String-0})"
+&Tmp-String-0 := "%(cipher_rsa.verify:%{Tmp-Octets-0} %{Tmp-String-0})"
 
 if (&Tmp-String-0 != 'yes') {
        test_fail
 }
-else {
-       test_pass
-}
 
 #
 #  Verification should now fail
 #
 &Tmp-String-0 := "Goodbye nurse!"
-&Tmp-String-0 := "%(cipher_rsa_verify:%{Tmp-Octets-0} %{Tmp-String-0})"
+&Tmp-String-0 := "%(cipher_rsa.verify:%{Tmp-Octets-0} %{Tmp-String-0})"
 
 if (&Tmp-String-0 != 'no') {
        test_fail
 }
-else {
-       test_pass
-}
+
+test_pass
index 3e85aa5d092fa206023ab6a6507ff386a4576b86..01a168a5622632efe2fa52cf96f252bbf7b741a8 100644 (file)
@@ -1,4 +1,4 @@
-&Tmp-Octets-0 := "%(cipher_rsa_certificate:serial)"
+&Tmp-Octets-0 := "%(cipher_rsa.certificate:serial)"
 
 if ("%(length:%{Tmp-Octets-0})" != 1) {
        test_fail
index d8aac72735de83399da08dd2e27e38a64eae6c59..aed4692c0b5667eb9820991a33b5eedd6732021d 100644 (file)
@@ -1,5 +1,5 @@
-&Tmp-Date-0 := "%(cipher_rsa_certificate:notBefore)"
-&Tmp-Date-1 := "%(cipher_rsa_certificate:notAfter)"
+&Tmp-Date-0 := "%(cipher_rsa.certificate:notBefore)"
+&Tmp-Date-1 := "%(cipher_rsa.certificate:notAfter)"
 
 # Check the cert validity period is 30 days
 if (<uint32>"%{expr:%(integer:%{Tmp-Date-1}) - %(integer:%{Tmp-Date-0})}" != <uint32>"%{expr:86400 * 60}") {
index 1f9edd99fda0646041204fae7059d9f5e99ed252..d04d54cf98fd3ec05574af18360808bdf9a352c0 100644 (file)
@@ -1,18 +1,18 @@
 #
-#      json_encode tests
+#      json.encode tests
 #
 &request -= &Packet-Type[*]
 
 # 0. Check basic xlat parsing
-&control.Tmp-String-1 := "%{json_encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_encode:&request.[*] }"
-&control.Tmp-String-3 := "%{json_encode: &request.[*]}"
-&control.Tmp-String-4 := "%{json_encode:        &request.[*]   }"
-&control.Tmp-String-5 := "%{json_encode: &request.[*]    !&Filter-Id }"
-&control.Tmp-String-6 := "%{json_encode:&request.[*] ! }"
+&control.Tmp-String-1 := "%{json.encode:&request.[*]}"
+&control.Tmp-String-2 := "%{json.encode:&request.[*] }"
+&control.Tmp-String-3 := "%{json.encode: &request.[*]}"
+&control.Tmp-String-4 := "%{json.encode:        &request.[*]   }"
+&control.Tmp-String-5 := "%{json.encode: &request.[*]    !&Filter-Id }"
+&control.Tmp-String-6 := "%{json.encode:&request.[*] ! }"
 #  Check defaults are the same as output_mode "object":
-&control.Tmp-String-7 := "%{json_object_encode:&request.[*]}"
-&control.Tmp-String-8 := "%{json_object_no_encode:&request.[*]}"
+&control.Tmp-String-7 := "%{json_object.encode:&request.[*]}"
+&control.Tmp-String-8 := "%{json_object_no.encode:&request.[*]}"
 
 if (!(&control.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
@@ -43,8 +43,8 @@ if !(&control.Tmp-String-6 == "") {
 
 # These are unsorted dictionaries. Hopefully json-c doesn't suddenly
 # decide that it's going to use a different ordering of the keys...
-&control.Tmp-String-1 := "%{json_object_encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_object_ex_encode:&request.[*]}"
+&control.Tmp-String-1 := "%{json_object.encode:&request.[*]}"
+&control.Tmp-String-2 := "%{json_object_ex.encode:&request.[*]}"
 
 if !(&control.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
@@ -56,15 +56,15 @@ if !(&control.Tmp-String-2 == '{"pf:User-Name":{"type":"string","value":["john"]
 }
 
 # 1b. "object" empty inputs
-&control.Tmp-String-1 := "%{json_object_encode:!&request.[*]}"
+&control.Tmp-String-1 := "%{json_object.encode:!&request.[*]}"
 
 if !(&control.Tmp-String-1 == '{}') {
        test_fail
 }
 
 # 2a. Output mode "object_simple" tests
-&control.Tmp-String-1 := "%{json_object_simple_encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_object_simple_ex_encode:&request.[*]}"
+&control.Tmp-String-1 := "%{json_object_simple.encode:&request.[*]}"
+&control.Tmp-String-2 := "%{json_object_simple_ex.encode:&request.[*]}"
 
 if !(&control.Tmp-String-1 == '{"User-Name":"john","Filter-Id":["f1","f2"],"NAS-Port":999,"Service-Type":"Login-User"}') {
        test_fail
@@ -75,15 +75,15 @@ if !(&control.Tmp-String-2 == '{"pf:User-Name":["john"],"pf:Filter-Id":["f1","f2
 }
 
 # 2b. "object_simple" empty inputs
-&control.Tmp-String-1 := "%{json_object_simple_encode:!&request.[*]}"
+&control.Tmp-String-1 := "%{json_object_simple.encode:!&request.[*]}"
 
 if !(&control.Tmp-String-1 == '{}') {
        test_fail
 }
 
 # 3a. Output mode "array" tests
-&control.Tmp-String-1 := "%{json_array_encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_array_ex_encode:&request.[*]}"
+&control.Tmp-String-1 := "%{json_array.encode:&request.[*]}"
+&control.Tmp-String-2 := "%{json_array_ex.encode:&request.[*]}"
 
 if !(&control.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
@@ -94,15 +94,15 @@ if !(&control.Tmp-String-2 == '[{"name":"pf:User-Name","type":"string","value":[
 }
 
 # 3b. "array" empty inputs
-&control.Tmp-String-1 := "%{json_array_encode:!&request.[*]}"
+&control.Tmp-String-1 := "%{json_array.encode:!&request.[*]}"
 
 if !(&control.Tmp-String-1 == '[]') {
        test_fail
 }
 
 # 4a. Output mode "array_of_names" tests
-&control.Tmp-String-1 := "%{json_array_names_encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_array_names_ex_encode:&request.[*]}"
+&control.Tmp-String-1 := "%{json_array_names.encode:&request.[*]}"
+&control.Tmp-String-2 := "%{json_array_names_ex.encode:&request.[*]}"
 
 if !(&control.Tmp-String-1 == '["User-Name","Filter-Id","Filter-Id","NAS-Port","Service-Type"]') {
        test_fail
@@ -113,15 +113,15 @@ if !(&control.Tmp-String-2 == '["pf:User-Name","pf:Filter-Id","pf:Filter-Id","pf
 }
 
 # 4b. "array_of_names" empty inputs
-&control.Tmp-String-1 := "%{json_array_names_encode:!&request.[*]}"
+&control.Tmp-String-1 := "%{json_array_names.encode:!&request.[*]}"
 
 if !(&control.Tmp-String-1 == '[]') {
        test_fail
 }
 
 # 5a. Output mode "array_of_values" tests
-&control.Tmp-String-1 := "%{json_array_values_encode:&request.[*]}"
-&control.Tmp-String-2 := "%{json_array_values_ex_encode:&request.[*]}"
+&control.Tmp-String-1 := "%{json_array_values.encode:&request.[*]}"
+&control.Tmp-String-2 := "%{json_array_values_ex.encode:&request.[*]}"
 
 if !(&control.Tmp-String-1 == '["john","f1","f2",999,"Login-User"]') {
        test_fail
@@ -132,7 +132,7 @@ if !(&control.Tmp-String-2 == '["john","f1","f2","999","1"]') {
 }
 
 # 5b. "array_of_values" empty inputs
-&control.Tmp-String-1 := "%{json_array_values_encode:!&request.[*]}"
+&control.Tmp-String-1 := "%{json_array_values.encode:!&request.[*]}"
 
 if !(&control.Tmp-String-1 == '[]') {
        test_fail
@@ -140,7 +140,7 @@ if !(&control.Tmp-String-1 == '[]') {
 
 # Convert `make json.test` unlang update output to tests, for when
 # things need updating.
-#  
+#
 #  cat \
 #    | cut -c44- \
 #    | sed -e 's/\\"/"/g' \
index 5a622a25cb5edb7177d52b267720f0b60cd2f858..a053697ed859a9406fe089d0b9fd28d19c581d54 100644 (file)
@@ -38,19 +38,19 @@ if ("%(redis:SET d "%{control.Tmp-String-2}")" == 'OK') {
 #
 #  Now check they are where we expect
 #
-if ("%(redis:@%(redis_node:b 0) GET b)" == "%{control.Tmp-String-0}") {
+if ("%(redis:@%(redis.node:b 0) GET b)" == "%{control.Tmp-String-0}") {
        test_pass
 } else {
        test_fail
 }
 
-if ("%(redis:@%(redis_node:c 0) GET c)" == "%{control.Tmp-String-1}") {
+if ("%(redis:@%(redis.node:c 0) GET c)" == "%{control.Tmp-String-1}") {
        test_pass
 } else {
        test_fail
 }
 
-if ("%(redis:@%(redis_node:d 0) GET d)" == "%{control.Tmp-String-2}") {
+if ("%(redis:@%(redis.node:d 0) GET d)" == "%{control.Tmp-String-2}") {
        test_pass
 } else {
        test_fail
index 3775c324fa665369fc964bffd36fc805b77d0abc..d4cab510c2fdc5bf68fd882d30844bc1354b41f9 100644 (file)
@@ -12,13 +12,13 @@ if (!("%(redis:SET b 'boom')" == 'OK')) {
 %(delay:0.5)
 
 #  Note the current master
-&Tmp-String-1 := %(redis_node:b 0)
+&Tmp-String-1 := %(redis.node:b 0)
 
 #  Note the current replica
-&Tmp-String-2 := %(redis_node:b 1)
+&Tmp-String-2 := %(redis.node:b 1)
 
 #  Cause one of the redis cluster nodes to SEGV
-if ("%(redis:@%(redis_node:b 0) DEBUG SEGFAULT)" != '') {
+if ("%(redis:@%(redis.node:b 0) DEBUG SEGFAULT)" != '') {
        test_fail
 }
 
@@ -30,9 +30,9 @@ if (!("%(redis:@%{Tmp-String-2} CLUSTER FAILOVER TAKEOVER)" == 'OK')) {
 #  Allow time for the takeover to propagate to other nodes
 foreach &control.Tmp-Integer-0 {
        # Keep remapping the cluster
-       %(redis_remap:%{Tmp-String-2})
+       %(redis.remap:%{Tmp-String-2})
 
-       if (%(redis_node:b 0) == &Tmp-String-2) {
+       if (%(redis.node:b 0) == &Tmp-String-2) {
                break
        }
        %(delay:0.5)
@@ -43,7 +43,7 @@ if (!("%(redis:GET b)" == 'boom')) {
 }
 
 #  Kill that one too
-if ("%(redis:@%(redis_node:b) DEBUG SEGFAULT)" != '') {
+if ("%(redis:@%(redis.node:b) DEBUG SEGFAULT)" != '') {
        test_fail
 }
 
index ae4a42a0d787b2841305d2b3902958bfe609d602..677c7a1912bc1788f62e2c6aec5aea0d8fac1427 100644 (file)
@@ -66,7 +66,7 @@ foreach &control.Tmp-Integer-0 {
        #
        #  Force a remap as the slaves don't show up in the cluster immediately
        #
-       if ("%(redis_remap:%{Tmp-String-0}:30001)" == 'success') {
+       if ("%(redis.remap:%{Tmp-String-0}:30001)" == 'success') {
                #  Hashes to Redis cluster node master 0 (1)
                if (("%(redis:SET b "%{control.Tmp-String-0}")" == 'OK') && \
                    ("%(redis:SET c "%{control.Tmp-String-1}")" == 'OK') && \
@@ -76,9 +76,9 @@ foreach &control.Tmp-Integer-0 {
                        #  so we now need to figure out which slave each of those keys
                        #  ended up on.
                        #
-                       if (("%(redis:-@%(redis_node:b 1) GET b)" == "%{control.Tmp-String-0}") && \
-                           ("%(redis:-@%(redis_node:c 1) GET c)" == "%{control.Tmp-String-1}") && \
-                           ("%(redis:-@%(redis_node:d 1) GET d)" == "%{control.Tmp-String-2}")) {
+                       if (("%(redis:-@%(redis.node:b 1) GET b)" == "%{control.Tmp-String-0}") && \
+                           ("%(redis:-@%(redis.node:c 1) GET c)" == "%{control.Tmp-String-1}") && \
+                           ("%(redis:-@%(redis.node:d 1) GET d)" == "%{control.Tmp-String-2}")) {
                                break
                        }
                }
index a6c2cadcac24431e5e8cf17c641db611944c3d8f..cc05ebfb0f2897dbb9f07ef4c4cf3bbabb701fbd 100644 (file)
@@ -70,7 +70,7 @@ if (!(&control.Tmp-String-3[0] == 'Bob') || !(&control.Tmp-String-3[1] == 'dummy
        test_fail
 }
 
-&control.Tmp-String-2 = "%{json_encode:&NAS-IP-Address}"
+&control.Tmp-String-2 = "%{json.encode:&NAS-IP-Address}"
 
 # POST to https with JSON body data
 &Tmp-String-2 := "%(rest:POST https://%{Tmp-String-0}:%{Tmp-Integer-1}/user/%{User-Name}/mac/%{Called-Station-Id}?section=accounting %{control.Tmp-String-2})"