The only options for the JSON module are to control the output
-format of the `json_encode` xlat.
+format of the `json.encode` xlat.
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
.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
.Example
```
-%{json_encode:&request[*] !&User-Password}
+%{json.encode:&request[*] !&User-Password}
```
In another (contrived) example, all the attributes in the RADIUS request will
.Example
```
-%{json_encode:&request[*] !&reply[*] &control.User-Name}
+%{json.encode:&request[*] !&reply[*] &control.User-Name}
```
#### Output format modes
#
# 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 {
# 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
# .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
# .Example
#
# ```
-# %{json_encode:&request[*] !&User-Password}
+# %{json.encode:&request[*] !&User-Password}
# ```
#
# In another (contrived) example, all the attributes in the RADIUS request will
# .Example
#
# ```
-# %{json_encode:&request[*] !&reply[*] &control.User-Name}
+# %{json.encode:&request[*] !&reply[*] &control.User-Name}
# ```
#
# #### Output format modes
{
xlat_t *c;
module_inst_ctx_t *our_mctx = NULL;
+ char inst_name[256];
fr_assert(xlat_root);
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.
*/
* Arguments are @verbatim(<plaintext>...)@endverbatim
*
@verbatim
-%{<inst>_encrypt:<plaintext>...}
+%{<inst>.encrypt:<plaintext>...}
@endverbatim
*
* If multiple arguments are provided they will be concatenated.
* Arguments are @verbatim(<plaintext>...)@endverbatim
*
@verbatim
-%{<inst>_sign:<plaintext>...}
+%{<inst>.sign:<plaintext>...}
@endverbatim
*
* If multiple arguments are provided they will be concatenated.
* Arguments are @verbatim(<ciphertext\>...)@endverbatim
*
@verbatim
-%{<inst>_decrypt:<ciphertext>...}
+%{<inst>.decrypt:<ciphertext>...}
@endverbatim
*
* If multiple arguments are provided they will be concatenated.
* 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)
* Arguments are @verbatim(<digest>)@endverbatim
*
@verbatim
-%(<inst>_certificate:fingerprint <digest>)
+%(<inst>.certificate:fingerprint <digest>)
@endverbatim
*
* @ingroup xlat_functions
/** Return the serial of the public certificate
*
@verbatim
-%(<inst>_certificate:serial)
+%(<inst>.certificate:serial)
@endverbatim
*
* @ingroup xlat_functions
}
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;
/*
/*
* 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;
*/
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;
}
/** Convert given attributes to a JSON document
*
- * Usage is `%{json_encode:attr tmpl list}`
+ * Usage is `%{json.encode:attr tmpl list}`
*
* @ingroup xlat_functions
*/
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
/** 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
/** Return the node that is currently servicing a particular key
*
@verbatim
-%(redis_node:<key> [<index>])
+%(redis.node:<key> [<index>])
@endverbatim
*
* @ingroup xlat_functions
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;
# = 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
}
# 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
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
&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
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
#
# 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
# 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
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
&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
-&Tmp-Octets-0 := "%(cipher_rsa_certificate:serial)"
+&Tmp-Octets-0 := "%(cipher_rsa.certificate:serial)"
if ("%(length:%{Tmp-Octets-0})" != 1) {
test_fail
-&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}") {
#
-# 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
# 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
}
# 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
}
# 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
}
# 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
}
# 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
}
# 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
# Convert `make json.test` unlang update output to tests, for when
# things need updating.
-#
+#
# cat \
# | cut -c44- \
# | sed -e 's/\\"/"/g' \
#
# 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
%(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
}
# 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)
}
# Kill that one too
-if ("%(redis:@%(redis_node:b) DEBUG SEGFAULT)" != '') {
+if ("%(redis:@%(redis.node:b) DEBUG SEGFAULT)" != '') {
test_fail
}
#
# 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') && \
# 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
}
}
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})"