From: Alan T. DeKok Date: Wed, 5 Apr 2023 19:07:59 +0000 (-0400) Subject: add tests for nested groups X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c29c02f0effb1d45786588a9616663cc0c36f475;p=thirdparty%2Ffreeradius-server.git add tests for nested groups and update parsing rules to not leave namespace as internal --- diff --git a/src/lib/server/map.c b/src/lib/server/map.c index 610d82db5f..43d2494a88 100644 --- a/src/lib/server/map.c +++ b/src/lib/server/map.c @@ -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; } } diff --git a/src/tests/keywords/edit-rhs-group b/src/tests/keywords/edit-rhs-group index 2334fe2f2f..e6698f98db 100644 --- a/src/tests/keywords/edit-rhs-group +++ b/src/tests/keywords/edit-rhs-group @@ -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