]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove flatten / unflatten tests and keywords
authorAlan T. DeKok <aland@freeradius.org>
Thu, 7 Sep 2023 18:44:42 +0000 (14:44 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 7 Sep 2023 18:44:42 +0000 (14:44 -0400)
they are no longer necessary, as we are moving to nested attributes

src/bin/unit_test_attribute.c
src/tests/unit/protocols/dhcpv6/flatten.txt [deleted file]
src/tests/unit/protocols/radius/flatten.txt [deleted file]

index e896a03a20c79bd7fdc0ef3eab3dd34ac8fe9b48..204e2d5b49c291fd3ed5142feba89fe4e4ac325c 100644 (file)
@@ -264,8 +264,6 @@ static xlat_action_t xlat_test(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out,
 static char            proto_name_prev[128];
 static dl_t            *dl;
 static dl_loader_t     *dl_loader = NULL;
-static bool            parse_new_conditions = true;
-static bool            unflatten_after_decode = false;
 
 static fr_event_list_t *el = NULL;
 
@@ -1541,8 +1539,6 @@ static size_t command_decode_pair(command_result_t *result, command_file_ctx_t *
        fr_strerror_clear();
        ASAN_UNPOISON_MEMORY_REGION(to_dec_end, COMMAND_OUTPUT_MAX - slen);
 
-       if (unflatten_after_decode) fr_pair_unflatten(head);
-
        /*
         *      Output may be an error, and we ignore
         *      it if so.
@@ -1636,8 +1632,6 @@ static size_t command_decode_proto(command_result_t *result, command_file_ctx_t
         *      it if so.
         */
 
-       if (unflatten_after_decode) fr_pair_unflatten(head);
-
        /*
         *      Print the pairs.
         */
@@ -2005,101 +1999,6 @@ static size_t command_returned(command_result_t *result, command_file_ctx_t *cc,
        RETURN_OK(snprintf(data, COMMAND_OUTPUT_MAX, "%zd", cc->last_ret));
 }
 
-/** Common code.
- *
- */
-static size_t flatten_common(command_result_t *result, char *data, UNUSED size_t data_used, fr_pair_t *head)
-{
-       ssize_t         slen;
-       char            *p, *end;
-       fr_pair_t       *vp;
-
-       /*
-        *      Set p to be the output buffer
-        */
-       p = data;
-       end = p + COMMAND_OUTPUT_MAX;
-
-       /*
-        *      Output may be an error, and we ignore
-        *      it if so.
-        */
-
-       if (!fr_pair_list_empty(&head->vp_group)) {
-               for (vp = fr_pair_list_head(&head->vp_group);
-                    vp;
-                    vp = fr_pair_list_next(&head->vp_group, vp)) {
-                       if ((slen = fr_pair_print(&FR_SBUFF_OUT(p, end), NULL, vp)) < 0) {
-                       oob:
-                               fr_strerror_const("Out of output buffer space for printed pairs");
-                               RETURN_COMMAND_ERROR();
-                       }
-                       p += slen;
-
-                       if (fr_pair_list_next(&head->vp_group, vp)) {
-                               slen = strlcpy(p, ", ", end - p);
-                               if (is_truncated((size_t)slen, end - p)) goto oob;
-                               p += slen;
-                       }
-               }
-       } else {
-               *p = '\0';
-       }
-
-       talloc_free(head);
-
-       RETURN_OK(p - data);
-}
-
-
-/** Flatten a list of value-pairs
- *
- */
-static size_t command_flatten(command_result_t *result, command_file_ctx_t *cc,
-                             char *data, size_t data_used, char *in, size_t inlen)
-{
-       fr_dict_attr_t  const *da;
-       fr_pair_t       *head;
-       fr_dict_t const *dict = cc->tmpl_rules.attr.dict_def ? cc->tmpl_rules.attr.dict_def : cc->config->dict;
-
-       da = fr_dict_attr_by_name(NULL, fr_dict_root(fr_dict_internal()), "request");
-       fr_assert(da != NULL);
-       head = fr_pair_afrom_da(cc->tmp_ctx, da);
-
-       if (fr_pair_list_afrom_str(head, fr_dict_root(dict), in, inlen, &head->vp_group) != T_EOL) {
-               RETURN_OK_WITH_ERROR();
-       }
-
-       fr_pair_flatten(head);
-
-       return flatten_common(result, data, data_used, head);
-}
-
-
-/** Un-flatten a list of value-pairs
- *
- */
-static size_t command_unflatten(command_result_t *result, command_file_ctx_t *cc,
-                             char *data, size_t data_used, char *in, size_t inlen)
-{
-       fr_dict_attr_t  const *da;
-       fr_pair_t       *head;
-       fr_dict_t const *dict = cc->tmpl_rules.attr.dict_def ? cc->tmpl_rules.attr.dict_def : cc->config->dict;
-
-       da = fr_dict_attr_by_name(NULL, fr_dict_root(fr_dict_internal()), "request");
-       fr_assert(da != NULL);
-       head = fr_pair_afrom_da(cc->tmp_ctx, da);
-
-       if (fr_pair_list_afrom_str(head, fr_dict_root(dict), in, inlen, &head->vp_group) != T_EOL) {
-               RETURN_OK_WITH_ERROR();
-       }
-
-       fr_pair_unflatten(head);
-
-       return flatten_common(result, data, data_used, head);
-}
-
-
 static size_t command_encode_proto(command_result_t *result, command_file_ctx_t *cc,
                                  char *data, UNUSED size_t data_used, char *in, size_t inlen)
 {
@@ -2378,14 +2277,6 @@ static size_t command_migrate(command_result_t *result, UNUSED command_file_ctx_
                p += sizeof("pair_legacy_print_nested") - 1;
                out = &fr_pair_legacy_print_nested;
 
-       } else if (strncmp(p, "unflatten_after_decode", sizeof("unflatten_after_decode") - 1) == 0) {
-               p += sizeof("unflatten_after_decode") - 1;
-               out = &unflatten_after_decode;
-
-       } else if (strncmp(p, "parse_new_conditions", sizeof("parse_new_conditions") - 1) == 0) {
-               p += sizeof("parse_new_conditions") - 1;
-               out = &parse_new_conditions;
-
        } else {
                fr_strerror_const("Unknown migration flag");
                RETURN_PARSE_ERROR(0);
@@ -3061,11 +2952,6 @@ static fr_table_ptr_sorted_t     commands[] = {
                                        .usage = "exit[ <num>]",
                                        .description = "Exit with the specified error number.  If no <num> is provided, process will exit with 0"
                                }},
-       { L("flatten"),         &(command_entry_t){
-                                       .func = command_flatten,
-                                       .usage = "flatten (-|<attribute> = <value>[,<attribute = <value>])",
-                                       .description = "Parse the input pairs into a temporary group, and then flatten the resulting pairs.  The input MUST NOT be already flattened, or bad things will happen.",
-                               }},
        { L("fuzzer-out"),      &(command_entry_t){
                                        .func = command_fuzzer_out,
                                        .usage = "fuzzer-out <dir>",
@@ -3147,11 +3033,6 @@ static fr_table_ptr_sorted_t     commands[] = {
                                        .usage = "touch <file>",
                                        .description = "Touch a file, updating its created timestamp.  Useful for marking the completion of a series of tests"
                                }},
-       { L("unflatten"),               &(command_entry_t){
-                                       .func = command_unflatten,
-                                       .usage = "unflatten (-|<attribute> = <value>[,<attribute = <value>])",
-                                       .description = "The opposite of 'flatten'"
-                               }},
        { L("value "),          &(command_entry_t){
                                        .func = command_value_box_normalise,
                                        .usage = "value <type> <string>",
diff --git a/src/tests/unit/protocols/dhcpv6/flatten.txt b/src/tests/unit/protocols/dhcpv6/flatten.txt
deleted file mode 100644 (file)
index ba65198..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#  -*- text -*-
-#  Copyright (C) 2022 Network RADIUS SARL (legal@networkradius.com)
-#  This work is licensed under CC-BY version 4.0 https://creativecommons.org/licenses/by/4.0
-#
-#  Version $Id$
-#
-#
-#  Flatten attributes which were created as nested ones.
-#
-#  This test isn't strictly DHCPv6, but DHCPv6 is useful for testing structs
-#
-
-proto dhcpv6
-proto-dictionary dhcpv6
-
-#
-#  The parser needs partial names for keyed structs.
-#
-flatten Client-ID = { DUID = UUID, DUID.UUID = { Value = 0x000102030405060708090a0b0c0d0e0f } }
-match Client-ID.DUID = UUID, Client-ID.DUID.UUID.Value = 0x000102030405060708090a0b0c0d0e0f
-
-flatten Client-ID = { DUID = UUID, DUID.UUID = { Value = 0x000102030405060708090a0b0c0d0e0f } }, Client-ID = { DUID = UUID, DUID.UUID = { Value = 0x000102030405060708090a0b0c0d0e0f } }
-match Client-ID.DUID = UUID, Client-ID.DUID.UUID.Value = 0x000102030405060708090a0b0c0d0e0f, Client-ID.DUID = UUID, Client-ID.DUID.UUID.Value = 0x000102030405060708090a0b0c0d0e0f
-
-#
-#  If we try to put two sets of struct children into one parent struct, that won't work.  The result is screwed up.
-#
-flatten Client-ID = { DUID = UUID, DUID.UUID = { Value = 0x000102030405060708090a0b0c0d0e0f }, DUID = UUID, DUID.UUID = { Value = 0x000102030405060708090a0b0c0d0e0f } }
-match Client-ID.DUID = UUID, Client-ID.DUID = UUID, Client-ID.DUID.UUID.Value = 0x000102030405060708090a0b0c0d0e0f, Client-ID.DUID.UUID.Value = 0x000102030405060708090a0b0c0d0e0f
-
-#
-#  Each struct has to be in its own container.
-#
-flatten Client-ID = { DUID = UUID, DUID.UUID = { Value = 0x000102030405060708090a0b0c0d0e0f } }, Client-ID = { DUID = UUID, DUID.UUID = { Value = 0x000102030405060708090a0b0c0d0e0f } }
-match Client-ID.DUID = UUID, Client-ID.DUID.UUID.Value = 0x000102030405060708090a0b0c0d0e0f, Client-ID.DUID = UUID, Client-ID.DUID.UUID.Value = 0x000102030405060708090a0b0c0d0e0f
-
-#unflatten -
-#match Client-ID = { DUID = UUID, DUID.UUID = { Value = 0x000102030405060708090a0b0c0d0e0f } }, Client-ID = { DUID = UUID, DUID.UUID = { Value = 0x000102030405060708090a0b0c0d0e0f } }
-
-
-count
-match 10
diff --git a/src/tests/unit/protocols/radius/flatten.txt b/src/tests/unit/protocols/radius/flatten.txt
deleted file mode 100644 (file)
index 30789d4..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#  -*- text -*-
-#  Copyright (C) 2022 Network RADIUS SARL (legal@networkradius.com)
-#  This work is licensed under CC-BY version 4.0 https://creativecommons.org/licenses/by/4.0
-#
-#  Version $Id$
-#
-#  Flatten attributes which were created as nested ones.
-#
-#  This test isn't strictly RADIUS, but RADIUS is useful for everything other than structs.
-#
-proto radius
-proto-dictionary radius
-
-flatten Vendor-Specific = { Cisco = { AVPair = "foo" } }
-match Vendor-Specific.Cisco.AVPair = "foo"
-
-#
-#  Some basic unflatten tests.  Things already at the root aren't touched, and groups aren't touched.
-#
-unflatten User-Name = "foo"
-match User-Name = "foo"
-
-unflatten User-Name = "foo", User-Password = "bar"
-match User-Name = "foo", User-Password = "bar"
-
-unflatten Tag-1 = { Tunnel-Type = PPTP }
-match Tag-1 = { Tunnel-Type = PPTP }
-
-flatten Vendor-Specific = { Cisco = { AVPair = "foo", AVPair = "bar" } }
-match Vendor-Specific.Cisco.AVPair = "foo", Vendor-Specific.Cisco.AVPair = "bar"
-
-flatten Vendor-Specific = { Cisco = { AVPair = "foo" }, HP = { Privilege-Level = 1 } }
-match Vendor-Specific.Cisco.AVPair = "foo", Vendor-Specific.HP.Privilege-Level = 1
-
-flatten Vendor-Specific = { Cisco = { AVPair = "foo", AVPair = "bar"  }, HP = { Privilege-Level = 1, Command-String = "baz" } }
-match Vendor-Specific.Cisco.AVPair = "foo", Vendor-Specific.Cisco.AVPair = "bar", Vendor-Specific.HP.Privilege-Level = 1, Vendor-Specific.HP.Command-String = "baz"
-
-#
-#  The HP children are inverted on parsing, but are ordered by number when flattened.
-#
-flatten Vendor-Specific = { Cisco = { AVPair = "foo", AVPair = "bar"  }, HP = { Command-String = "baz", Privilege-Level = 1 } }
-match Vendor-Specific.Cisco.AVPair = "foo", Vendor-Specific.Cisco.AVPair = "bar", Vendor-Specific.HP.Privilege-Level = 1, Vendor-Specific.HP.Command-String = "baz"
-
-#
-#  Groups aren't flattened.
-#
-flatten Tag-1 = { Tunnel-Type = PPTP }
-match Tag-1 = { Tunnel-Type = PPTP }
-
-#
-#  TLVs
-#
-flatten Vendor-Specific = { WiMAX = { Capability = { Release = "1.0", Accounting-Capabilities = IP-Session-Based } } }
-match Vendor-Specific.WiMAX.Capability = { Release = "1.0", Accounting-Capabilities = IP-Session-Based }
-
-unflatten -
-match Vendor-Specific = { WiMAX = { Capability = { Release = "1.0", Accounting-Capabilities = IP-Session-Based } } }
-
-flatten Vendor-Specific = { WiMAX = { Capability = { Release = "1.0", Accounting-Capabilities = IP-Session-Based }, AAA-Session-Id = 0x00, Packet-Flow-Descriptor = { Packet-Data-Flow-Id = 1, Service-Data-Flow-Id = 2, Service-Profile-Id = 3 } } }
-match Vendor-Specific.WiMAX.Capability = { Release = "1.0", Accounting-Capabilities = IP-Session-Based }, Vendor-Specific.WiMAX.AAA-Session-Id = 0x00, Vendor-Specific.WiMAX.Packet-Flow-Descriptor = { Packet-Data-Flow-Id = 1, Service-Data-Flow-Id = 2, Service-Profile-Id = 3 }
-
-encode-pair -
-match 1a 11 00 00 60 b5 01 0b 00 01 05 31 2e 30 02 03 01 1a 0a 00 00 60 b5 04 04 00 00 1a 17 00 00 60 b5 1c 11 00 01 04 00 01 02 04 00 02 03 06 00 00 00 03
-
-#
-#  The opposite of the "flatten" above
-#
-unflatten Vendor-Specific.WiMAX.Capability = { Release = "1.0", Accounting-Capabilities = IP-Session-Based }, Vendor-Specific.WiMAX.AAA-Session-Id = 0x00, Vendor-Specific.WiMAX.Packet-Flow-Descriptor = { Packet-Data-Flow-Id = 1, Service-Data-Flow-Id = 2, Service-Profile-Id = 3 }
-match Vendor-Specific = { WiMAX = { Capability = { Release = "1.0", Accounting-Capabilities = IP-Session-Based }, AAA-Session-Id = 0x00, Packet-Flow-Descriptor = { Packet-Data-Flow-Id = 1, Service-Data-Flow-Id = 2, Service-Profile-Id = 3 } } }
-
-
-count
-match 30