]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add tests for nested groups
authorAlan T. DeKok <aland@freeradius.org>
Wed, 5 Apr 2023 19:07:59 +0000 (15:07 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 5 Apr 2023 19:09:22 +0000 (15:09 -0400)
and update parsing rules to not leave namespace as internal

src/lib/server/map.c
src/tests/keywords/edit-rhs-group

index 610d82db5ff9c71cb9d33937a6bdda3d5c30f611..43d2494a88bc8462940e9ddeba2259e3bd52b16b 100644 (file)
@@ -851,7 +851,7 @@ do_children:
                         *      is used as the parsing context of the
                         *      inner section.
                         */
-                       child_lhs_rules.attr.prefix = TMPL_ATTR_REF_PREFIX_NO;
+                       child_lhs_rules.attr.prefix = TMPL_ATTR_REF_PREFIX_AUTO;
                        child_lhs_rules.attr.namespace = tmpl_attr_tail_da(map->lhs);
 
                        /*
@@ -865,9 +865,16 @@ do_children:
                                dict = fr_dict_by_da(ref);
                                internal = fr_dict_internal();
 
-                               if ((dict != internal) && (dict != child_lhs_rules.attr.dict_def)) {
-                                       child_lhs_rules.attr.dict_def = dict;
-                                       child_lhs_rules.attr.namespace = ref;
+                               if (dict != internal) {
+                                       if (dict != child_lhs_rules.attr.dict_def) {
+                                               child_lhs_rules.attr.dict_def = dict;
+                                               child_lhs_rules.attr.namespace = ref;
+                                       }
+                               } else {
+                                       /*
+                                        *      We're internal: don't use it, and instead rely on dict_def.
+                                        */
+                                       child_lhs_rules.attr.namespace = NULL;
                                }
                        }
 
index 2334fe2f2fc7ebb737cf3e8177841c810106125c..e6698f98db92adc1394fe49b751746004d9b774c 100644 (file)
@@ -9,4 +9,24 @@ if (!&request.Tmp-Group-0) {
        test_fail
 }
 
+&request.Tmp-Group-0 += {
+       &User-Name = "hello"
+}
+
+if !(&request.Tmp-Group-0.User-Name == "hello") {
+       test_fail
+}
+
+
+&request.Tmp-Group-0 += {
+       &Tmp-Group-1 = {
+               &User-Name = "foo"
+       }
+}
+
+if !(&request.Tmp-Group-0.Tmp-Group-1.User-Name == "foo") {
+       test_fail
+}
+
+
 success