]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Make json.encode work with local attributes
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 26 Sep 2025 22:35:46 +0000 (18:35 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 26 Sep 2025 22:35:46 +0000 (18:35 -0400)
src/modules/rlm_json/rlm_json.c
src/tests/modules/json/encode.unlang

index 311c87c75c8e50ccb206fb95bac9e8be44cde754..b294481f012c33d6276593f4df9eb2e575ca07da 100644 (file)
@@ -242,7 +242,7 @@ static xlat_action_t json_encode_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out,
                                                .attr = {
                                                        .list_def = request_attr_request,
                                                        .allow_wildcard = true,
-                                                       .dict_def = request->proto_dict,
+                                                       .dict_def = request->local_dict,
                                                }
                                              });
                if (slen <= 0) {
index 435f65b36bd2e24fc62e9588295fdce4b5596a49..c48d2de94885a14f249cfaef06242e634156f89a 100644 (file)
@@ -167,4 +167,17 @@ if !(test_string1 == '[]') {
 #          -e "s/\"$/') {/" \
 #          -e "s/$/\n  test_fail\n}\n/"
 
+# 6a Local attributes
+group {
+       string local_attr
+
+       local_attr := 'foo'
+
+       test_string1 := %json.encode("local_attr")
+
+       if !(test_string1 == '{"local_attr":{"type":"string","value":"foo"}}') {
+               test_fail
+       }
+}
+
 test_pass