From: Arran Cudbard-Bell Date: Tue, 5 Nov 2019 01:38:29 +0000 (-0600) Subject: Add support for test dictionaries in unit_test_attribute X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12b3588ceb868679d64a8b030565c2a2598d482c;p=thirdparty%2Ffreeradius-server.git Add support for test dictionaries in unit_test_attribute --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index 88f1407ccaf..35c4485fc79 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -50,8 +50,9 @@ typedef struct rad_request REQUEST; # include #endif -#include #include +#include +#include #include #define EXIT_WITH_FAILURE \ @@ -166,13 +167,13 @@ typedef struct { typedef struct { TALLOC_CTX *tmp_ctx; //!< Talloc context for test points. - char const *path; //!< Current path we're operating in. + char *path; //!< Current path we're operating in. int lineno; //!< Current line number. char const *filename; //!< Current file we're operating on. uint32_t test_count; //!< How many tests we've executed in this file. fr_dict_t *dict; //!< Base dictionary. - fr_dict_t *proto_dict; //!< Protocol specific dictionary. + fr_dict_t *active_dict; //!< Protocol specific dictionary. CONF_SECTION *features; //!< Enabled features. } command_ctx_t; @@ -204,6 +205,8 @@ static ssize_t xlat_test(UNUSED TALLOC_CTX *ctx, UNUSED char **out, UNUSED size_ static char proto_name_prev[128]; static dl_t *dl; static dl_loader_t *dl_loader; +static char const *raddb_dir = RADDBDIR; +static char const *dict_dir = DICTDIR; size_t process_line(command_result_t *result, command_ctx_t *cc, char *data, size_t data_used, char *in, size_t inlen); static int process_file(bool *exit_now, TALLOC_CTX *ctx, CONF_SECTION *features, @@ -783,6 +786,50 @@ static ssize_t load_test_point_by_command(void **symbol, char *command, char con return p - command; } +/** Common dictionary load function + * + * Callers call fr_dict_dir_set to set the dictionary root to + * load dictionaries from, then provide a relative path to + * navigate through test subdirectories or protocols + */ +static int dictionary_load_common(command_result_t *result, command_ctx_t *cc, char *in, char *default_subdir) +{ + static char *name, *dir, *tmp = NULL; + char *q; + int ret; + + if (in[0] == '\0') { + fr_strerror_printf("Missing dictionary name"); + RETURN_PARSE_ERROR(0); + } + + /* + * Decrease ref count if we're loading in a new dictionary + */ + if (cc->active_dict) fr_dict_free(&cc->active_dict); + + q = strchr(in, ' '); + if (q) { + name = tmp = talloc_bstrndup(NULL, in, q - in); + q++; + dir = q; + } else { + name = in; + dir = default_subdir; + } + + ret = fr_dict_protocol_afrom_file(&cc->active_dict, name, dir); + talloc_free(tmp); + if (ret < 0) RETURN_COMMAND_ERROR(); + + /* + * Dump the dictionary if we're in super debug mode + */ + if (fr_debug_lvl > 5) fr_dict_dump(cc->active_dict); + + RETURN_OK(0); +} + static fr_cmd_t *command_head = NULL; static int command_func(UNUSED FILE *fp, UNUSED FILE *fp_err, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info) @@ -867,7 +914,7 @@ static size_t command_normalise_attribute(command_result_t *result, command_ctx_ VALUE_PAIR *head = NULL; size_t len; - if (fr_pair_list_afrom_str(NULL, cc->proto_dict ? cc->proto_dict : cc->dict, in, &head) != T_EOL) { + if (fr_pair_list_afrom_str(NULL, cc->active_dict ? cc->active_dict : cc->dict, in, &head) != T_EOL) { RETURN_OK_WITH_ERROR(); } @@ -882,6 +929,22 @@ static size_t command_normalise_attribute(command_result_t *result, command_ctx_ RETURN_OK(len); } +/** Change the working directory + * + */ +static size_t command_cd(command_result_t *result, command_ctx_t *cc, + char *data, UNUSED size_t data_used, char *in, size_t inlen) +{ + TALLOC_FREE(cc->path); /* Free old directories */ + + cc->path = fr_file_realpath(cc->tmp_ctx, in, inlen); + if (!cc->path) RETURN_COMMAND_ERROR(); + + strlcpy(data, cc->path, COMMAND_OUTPUT_MAX); + + RETURN_OK(talloc_array_length(cc->path) - 1); +} + /* * Clear the data buffer */ @@ -1020,7 +1083,7 @@ static size_t command_condition_normalise(command_result_t *result, command_ctx_ cf_filename_set(cs, cc->filename); cf_lineno_set(cs, cc->lineno); - dec_len = fr_cond_tokenize(cs, &cond, &error, cc->proto_dict ? cc->proto_dict : cc->dict, in); + dec_len = fr_cond_tokenize(cs, &cond, &error, cc->active_dict ? cc->active_dict : cc->dict, in); if (dec_len <= 0) { fr_strerror_printf("ERROR offset %d %s", (int) -dec_len, error); @@ -1096,7 +1159,10 @@ static size_t command_decode_pair(command_result_t *result, command_ctx_t *cc, * Decode hex from input text */ slen = hex_to_bin((uint8_t *)data, COMMAND_OUTPUT_MAX, p, inlen); - if (slen <= 0) RETURN_PARSE_ERROR(-(slen)); + if (slen <= 0) { + CLEAR_TEST_POINT(cc); + RETURN_PARSE_ERROR(-(slen)); + } to_dec = (uint8_t *)data; to_dec_end = to_dec + slen; @@ -1107,14 +1173,16 @@ static size_t command_decode_pair(command_result_t *result, command_ctx_t *cc, */ fr_cursor_init(&cursor, &head); while (to_dec < to_dec_end) { - slen = tp->func(cc->tmp_ctx, &cursor, cc->proto_dict ? cc->proto_dict : cc->dict, + slen = tp->func(cc->tmp_ctx, &cursor, cc->active_dict ? cc->active_dict : cc->dict, (uint8_t *)to_dec, (to_dec_end - to_dec), decoder_ctx); if (slen < 0) { fr_pair_list_free(&head); + CLEAR_TEST_POINT(cc); RETURN_OK_WITH_ERROR(); } if ((size_t)slen > (size_t)(to_dec_end - to_dec)) { fr_perror("Internal sanity check failed at %d", __LINE__); + CLEAR_TEST_POINT(cc); RETURN_COMMAND_ERROR(); } to_dec += slen; @@ -1140,6 +1208,7 @@ static size_t command_decode_pair(command_result_t *result, command_ctx_t *cc, if (is_truncated(len, end - p)) { oob: fr_strerror_printf("Out of output buffer space"); + CLEAR_TEST_POINT(cc); RETURN_COMMAND_ERROR(); } p += len; @@ -1154,8 +1223,8 @@ static size_t command_decode_pair(command_result_t *result, command_ctx_t *cc, } else { /* zero-length to_decibute */ *p = '\0'; } - CLEAR_TEST_POINT(cc); + CLEAR_TEST_POINT(cc); RETURN_OK(p - data); } @@ -1190,7 +1259,7 @@ static size_t command_dictionary_attribute_parse(command_result_t *result, comma static size_t command_dictionary_dump(command_result_t *result, command_ctx_t *cc, UNUSED char *data, size_t data_used, UNUSED char *in, UNUSED size_t inlen) { - fr_dict_dump(cc->proto_dict ? cc->proto_dict : cc->dict); + fr_dict_dump(cc->active_dict ? cc->active_dict : cc->dict); /* * Don't modify the contents of the data buffer @@ -1198,49 +1267,6 @@ static size_t command_dictionary_dump(command_result_t *result, command_ctx_t *c RETURN_OK(data_used); } - -/** Dynamically load a protocol dictionary - * - */ -static size_t command_dictionary_load(command_result_t *result, command_ctx_t *cc, - UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen) -{ - char *name, *dir, *tmp = NULL; - char *q; - int ret; - - if (in[0] == '\0') { - fr_strerror_printf("Load-dictionary syntax is \"dictionary-load []\""); - RETURN_PARSE_ERROR(0); - } - - /* - * Decrease ref count if we're loading in a new dictionary - */ - if (cc->proto_dict) fr_dict_free(&cc->proto_dict); - - q = strchr(in, ' '); - if (q) { - name = tmp = talloc_bstrndup(NULL, in, q - in); - q++; - dir = q; - } else { - name = in; - dir = NULL; - } - - ret = fr_dict_protocol_afrom_file(&cc->proto_dict, name, dir); - talloc_free(tmp); - if (ret < 0) RETURN_OK_WITH_ERROR(); - - /* - * Dump the dictionary if we're in super debug mode - */ - if (fr_debug_lvl > 5) fr_dict_dump(cc->proto_dict); - - RETURN_OK(0); -} - static size_t command_encode_dns_label(command_result_t *result, UNUSED command_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen) { @@ -1349,6 +1375,7 @@ static size_t command_encode_pair(command_result_t *result, command_ctx_t *cc, slen = load_test_point_by_command((void **)&tp, p, "tp_encode"); if (!tp) { fr_strerror_printf_push("Failed locating encode testpoint"); + CLEAR_TEST_POINT(cc); RETURN_COMMAND_ERROR(); } @@ -1356,10 +1383,12 @@ static size_t command_encode_pair(command_result_t *result, command_ctx_t *cc, fr_skip_whitespace(p); if (tp->test_ctx && (tp->test_ctx(&encoder_ctx, cc->tmp_ctx) < 0)) { fr_strerror_printf_push("Failed initialising encoder testpoint"); + CLEAR_TEST_POINT(cc); RETURN_COMMAND_ERROR(); } - if (fr_pair_list_afrom_str(cc->tmp_ctx, cc->proto_dict ? cc->proto_dict : cc->dict, p, &head) != T_EOL) { + if (fr_pair_list_afrom_str(cc->tmp_ctx, cc->active_dict ? cc->active_dict : cc->dict, p, &head) != T_EOL) { + CLEAR_TEST_POINT(cc); RETURN_OK_WITH_ERROR(); } @@ -1368,6 +1397,7 @@ static size_t command_encode_pair(command_result_t *result, command_ctx_t *cc, slen = tp->func(enc_p, enc_end - enc_p, &cursor, encoder_ctx); if (slen < 0) { fr_pair_list_free(&head); + CLEAR_TEST_POINT(cc); RETURN_OK_WITH_ERROR(); } enc_p += slen; @@ -1381,6 +1411,26 @@ static size_t command_encode_pair(command_result_t *result, command_ctx_t *cc, RETURN_OK(hex_print(data, COMMAND_OUTPUT_MAX, encoded, enc_p - encoded)); } +/** Encode a RADIUS attribute writing the result to the data buffer as space separated hexits + * + */ +static size_t command_encode_raw(command_result_t *result, UNUSED command_ctx_t *cc, + char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen) +{ + size_t len; + uint8_t encoded[(COMMAND_OUTPUT_MAX / 2) - 1]; + + len = encode_rfc(in, encoded, sizeof(encoded)); + if (len <= 0) RETURN_PARSE_ERROR(0); + + if (len >= sizeof(encoded)) { + fr_strerror_printf("Encoder output would overflow output buffer"); + RETURN_OK_WITH_ERROR(); + } + + RETURN_OK(hex_print(data, COMMAND_OUTPUT_MAX, encoded, len)); +} + /** Incomplete - Will be used to encode packets * */ @@ -1418,25 +1468,6 @@ static size_t command_exit(command_result_t *result, UNUSED command_ctx_t *cc, RETURN_EXIT(atoi(in)); } -/** Dynamically load a protocol library - * - */ -static size_t command_proto_load(command_result_t *result, UNUSED command_ctx_t *cc, - UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen) -{ - ssize_t slen; - - if (*in == '\0') { - fr_strerror_printf("Load syntax is \"load \""); - RETURN_PARSE_ERROR(0); - } - - slen = load_proto_library(in); - if (slen <= 0) RETURN_PARSE_ERROR(-(slen)); - - RETURN_OK(0); -} - /** Compare the data buffer to an expected value * */ @@ -1541,24 +1572,32 @@ static size_t command_no(command_result_t *result, command_ctx_t *cc, return data_used; } -/** Encode a RADIUS attribute writing the result to the data buffer as space separated hexits +/** Dynamically load a protocol library * */ -static size_t command_encode_raw(command_result_t *result, UNUSED command_ctx_t *cc, - char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen) +static size_t command_proto(command_result_t *result, UNUSED command_ctx_t *cc, + UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen) { - size_t len; - uint8_t encoded[(COMMAND_OUTPUT_MAX / 2) - 1]; - - len = encode_rfc(in, encoded, sizeof(encoded)); - if (len <= 0) RETURN_PARSE_ERROR(0); + ssize_t slen; - if (len >= sizeof(encoded)) { - fr_strerror_printf("Encoder output would overflow output buffer"); - RETURN_OK_WITH_ERROR(); + if (*in == '\0') { + fr_strerror_printf("Load syntax is \"load \""); + RETURN_PARSE_ERROR(0); } - RETURN_OK(hex_print(data, COMMAND_OUTPUT_MAX, encoded, len)); + fr_dict_dir_set(dict_dir); + slen = load_proto_library(in); + if (slen <= 0) RETURN_PARSE_ERROR(-(slen)); + + RETURN_OK(0); +} + +static size_t command_proto_dictionary(command_result_t *result, command_ctx_t *cc, + UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen) +{ + fr_dict_dir_set(dict_dir); + + return dictionary_load_common(result, cc, in, NULL); } /** Touch a file to indicate a test completed @@ -1573,6 +1612,14 @@ static size_t command_touch(command_result_t *result, UNUSED command_ctx_t *cc, RETURN_OK(0); } +static size_t command_test_dictionary(command_result_t *result, command_ctx_t *cc, + UNUSED char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen) +{ + fr_dict_dir_set(cc->path); + + return dictionary_load_common(result, cc, in, "."); +} + static size_t command_value_box_normalise(command_result_t *result, UNUSED command_ctx_t *cc, char *data, UNUSED size_t data_used, char *in, UNUSED size_t inlen) { @@ -1684,7 +1731,7 @@ static size_t command_xlat_normalise(command_result_t *result, command_ctx_t *cc fmt[len] = '\0'; dec_len = xlat_tokenize(fmt, &head, fmt, - &(vp_tmpl_rules_t) { .dict_def = cc->proto_dict ? cc->proto_dict : cc->dict }); + &(vp_tmpl_rules_t) { .dict_def = cc->active_dict ? cc->active_dict : cc->dict }); if (dec_len <= 0) { fr_strerror_printf("ERROR offset %d '%s'", (int) -dec_len, fr_strerror()); @@ -1721,6 +1768,11 @@ static fr_table_ptr_sorted_t commands[] = { .usage = "attribute = ", .description = "Parse and reprint an attribute value pair, writing \"ok\" to the data buffer on success" }}, + { "cd ", &(command_entry_t){ + .func = command_cd, + .usage = "cd ", + .description = "Change the directory for loading dictionaries and $INCLUDEs, writing the full path into the data buffer on success" + }}, { "clear", &(command_entry_t){ .func = command_clear, .usage = "clear", @@ -1771,11 +1823,6 @@ static fr_table_ptr_sorted_t commands[] = { .usage = "dictionary-dump", .description = "Print the contents of the currently active protocol dictionary to stdout", }}, - { "dictionary-load ", &(command_entry_t){ - .func = command_dictionary_load, - .usage = "dictionary-load []", - .description = "Switch the active protocol dictionary", - }}, { "encode-dns-label ", &(command_entry_t){ .func = command_encode_dns_label, .usage = "encode-dns-label (-|string[,string])", @@ -1801,11 +1848,6 @@ static fr_table_ptr_sorted_t commands[] = { .usage = "exit[ ]", .description = "Exit with the specified error number. If no is provided, process will exit with 0" }}, - { "load ", &(command_entry_t){ - .func = command_proto_load, - .usage = "load ", - .description = "Switch the active protocol to the one specified, unloading the previous protocol", - }}, { "match", &(command_entry_t){ .func = command_match, .usage = "match ", @@ -1826,11 +1868,26 @@ static fr_table_ptr_sorted_t commands[] = { .usage = "no ...", .description = "Negate the result of a command returning 'ok'" }}, + { "proto ", &(command_entry_t){ + .func = command_proto, + .usage = "proto ", + .description = "Switch the active protocol to the one specified, unloading the previous protocol", + }}, + { "proto-dictionary ", &(command_entry_t){ + .func = command_proto_dictionary, + .usage = "proto-dictionary []", + .description = "Switch the active dictionary. Root is set to the default dictionary path, or the one specified with -d. is relative to the root.", + }}, { "raw ", &(command_entry_t){ .func = command_encode_raw, .usage = "raw ", .description = "Create nested attributes from OID strings and values" }}, + { "test-dictionary ", &(command_entry_t){ + .func = command_test_dictionary, + .usage = "test-dictionary []", + .description = "Switch the active dictionary. Root is set to the path containing the current test file (override with cd ). is relative to the root.", + }}, { "touch ", &(command_entry_t){ .func = command_touch, .usage = "touch ", @@ -1917,15 +1974,19 @@ size_t process_line(command_result_t *result, command_ctx_t *cc, char *data, siz return data_used; } -static void command_ctx_init(command_ctx_t *cc, TALLOC_CTX *ctx, char const *path, char const *filename, - fr_dict_t *dict, CONF_SECTION *features) +static command_ctx_t *command_ctx_alloc(TALLOC_CTX *ctx, char const *path, char const *filename, + fr_dict_t *dict, CONF_SECTION *features) { - memset(cc, 0, sizeof(*cc)); + command_ctx_t *cc; + + cc = talloc_zero(ctx, command_ctx_t); cc->tmp_ctx = talloc_named_const(ctx, 0, "tmp_ctx"); - cc->path = path; + cc->path = talloc_strdup(cc, path); cc->dict = dict; cc->filename = filename; cc->features = features; + + return cc; } static void command_ctx_reset(command_ctx_t *cc, TALLOC_CTX *ctx) @@ -1945,9 +2006,9 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, CONF_SECTION *features, ssize_t data_used = 0; /* How much data the last command wrote */ static char path[PATH_MAX] = { '\0' }; - command_ctx_t cc; + command_ctx_t *cc; - command_ctx_init(&cc, ctx, path, filename, dict, features); + cc = command_ctx_alloc(ctx, root_dir, filename, dict, features); /* * Open the file, or stdin @@ -1979,11 +2040,11 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, CONF_SECTION *features, command_result_t result = { .rcode = RESULT_OK }; /* Reset to OK */ char *p = strchr(buffer, '\n'); - cc.lineno++; + cc->lineno++; if (!p) { if (!feof(fp)) { - ERROR("Line %d too long in %s", cc.lineno, cc.path); + ERROR("Line %d too long in %s", cc->lineno, cc->path); ret = -1; goto finish; } @@ -1991,13 +2052,13 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, CONF_SECTION *features, *p = '\0'; } - data_used = process_line(&result, &cc, data, data_used, buffer, strlen(buffer)); + data_used = process_line(&result, cc, data, data_used, buffer, strlen(buffer)); switch (result.rcode) { /* * Command completed successfully */ case RESULT_OK: - cc.test_count++; + cc->test_count++; continue; /* @@ -2025,13 +2086,13 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, CONF_SECTION *features, command = fr_table_value_by_longest_prefix(&match_len, commands, buffer, -1, NULL); if (!command) { - ERROR("%s[%d]: Unknown command: %s", cc.path, cc.lineno, p); + ERROR("%s[%d]: Unknown command: %s", cc->path, cc->lineno, p); ret = -1; goto finish; } if (command->func == command_eof) { - command_ctx_reset(&cc, ctx); + command_ctx_reset(cc, ctx); break; } } @@ -2042,7 +2103,7 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, CONF_SECTION *features, */ case RESULT_PARSE_ERROR: case RESULT_COMMAND_ERROR: - PERROR("%s[%d]", filename, cc.lineno); + PERROR("%s[%d]", filename, cc->lineno); ret = -1; goto finish; @@ -2067,11 +2128,12 @@ finish: if (fp && (fp != stdin)) fclose(fp); /* - * Free any residual resources re loaded. + * Free any residual resources we loaded. */ - TALLOC_FREE(cc.tmp_ctx); - fr_dict_free(&cc.proto_dict); unload_proto_library(); + fr_dict_free(&cc->active_dict); + talloc_free(cc); + return ret; } @@ -2118,8 +2180,6 @@ static void commands_print(void) int main(int argc, char *argv[]) { int c; - char const *raddb_dir = RADDBDIR; - char const *dict_dir = DICTDIR; char const *receipt_file = NULL; int *inst = &c; CONF_SECTION *cs, *features; @@ -2258,7 +2318,7 @@ int main(int argc, char *argv[]) * Read tests from stdin */ if (argc < 2) { - ret = process_file(&exit_now, autofree, features, dict, NULL, "-"); + ret = process_file(&exit_now, autofree, features, dict, dirname(argv[0]), "-"); /* * ...or process each file in turn. @@ -2267,7 +2327,7 @@ int main(int argc, char *argv[]) int i; for (i = 1; i < argc; i++) { - ret = process_file(&exit_now, autofree, features, dict, NULL, argv[i]); + ret = process_file(&exit_now, autofree, features, dict, dirname(argv[i]), basename(argv[i])); if ((ret != 0) || exit_now) break; } } @@ -2293,5 +2353,11 @@ cleanup: */ fr_strerror_free(); + /* + * Explicitly free children to make + * memory errors on exit less confusing. + */ + talloc_free_children(autofree); + return ret; } diff --git a/src/lib/util/all.mk b/src/lib/util/all.mk index 0f8bc19ffaa..5be813afa1e 100644 --- a/src/lib/util/all.mk +++ b/src/lib/util/all.mk @@ -20,6 +20,7 @@ SOURCES := \ event.c \ fopencookie.c \ fifo.c \ + file.c \ fring.c \ getaddrinfo.c \ hash.c \ diff --git a/src/tests/unit/condition/base.txt b/src/tests/unit/condition/base.txt index 5cb5776088a..68d5afe8008 100644 --- a/src/tests/unit/condition/base.txt +++ b/src/tests/unit/condition/base.txt @@ -9,7 +9,7 @@ # A bunch of errors, in the order that the error strings # appear in parser.c # -dictionary-load radius +proto-dictionary radius condition &request:User-Name == &reply:User-Name match &User-Name == &reply:User-Name diff --git a/src/tests/unit/condition/regex.txt b/src/tests/unit/condition/regex.txt index dd545d659de..289470c2d43 100644 --- a/src/tests/unit/condition/regex.txt +++ b/src/tests/unit/condition/regex.txt @@ -1,4 +1,4 @@ -dictionary-load radius +proto-dictionary radius condition &User-Name !~ /^foo\nbar$/ match !&User-Name =~ /^foo\nbar$/ diff --git a/src/tests/unit/protocols/dhcpv4/base.txt b/src/tests/unit/protocols/dhcpv4/base.txt index b1040041f67..dd6226a654e 100644 --- a/src/tests/unit/protocols/dhcpv4/base.txt +++ b/src/tests/unit/protocols/dhcpv4/base.txt @@ -1,8 +1,8 @@ # # Test vectors for DHCP attributes # -load dhcpv4 -dictionary-load dhcpv4 +proto dhcpv4 +proto-dictionary dhcpv4 # # DHCP TLV types diff --git a/src/tests/unit/protocols/dhcpv6/addresses.txt b/src/tests/unit/protocols/dhcpv6/addresses.txt index f2ac6ab9906..0be098c143d 100644 --- a/src/tests/unit/protocols/dhcpv6/addresses.txt +++ b/src/tests/unit/protocols/dhcpv6/addresses.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # Encode ipv6address diff --git a/src/tests/unit/protocols/dhcpv6/bools.txt b/src/tests/unit/protocols/dhcpv6/bools.txt index 3baaca05afc..579c9b0658e 100644 --- a/src/tests/unit/protocols/dhcpv6/bools.txt +++ b/src/tests/unit/protocols/dhcpv6/bools.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # Bool diff --git a/src/tests/unit/protocols/dhcpv6/dates.txt b/src/tests/unit/protocols/dhcpv6/dates.txt index 50ef350289a..3a61d292f6a 100644 --- a/src/tests/unit/protocols/dhcpv6/dates.txt +++ b/src/tests/unit/protocols/dhcpv6/dates.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # Date. Like a 32bit unix timestamp but starts from 1st Jan 2000 instead of 1st Jan 1970 diff --git a/src/tests/unit/protocols/dhcpv6/dictionary b/src/tests/unit/protocols/dhcpv6/dictionary new file mode 100644 index 00000000000..4421a8e76d4 --- /dev/null +++ b/src/tests/unit/protocols/dhcpv6/dictionary @@ -0,0 +1,51 @@ +PROTOCOL DHCPv6 3 +BEGIN-PROTOCOL DHCPv6 + +# +# Basic options needed by the DHCPv6 pair encoder and decoder +# +ATTRIBUTE Packet-Type 65536 uint32 internal +ATTRIBUTE Transaction-ID 65537 uint32 internal + +ATTRIBUTE Option-Request 65535 uint16 array # Magic option listing requested options + +# +# Test attributes +# +ATTRIBUTE Test-string 1 string +ATTRIBUTE Test-octets 2 octets + +ATTRIBUTE Test-ipaddr 3 ipaddr +ATTRIBUTE Test-ipv4addr 4 ipv4addr +ATTRIBUTE Test-ipv4prefix 5 ipv4prefix +ATTRIBUTE Test-ipv6addr 6 ipv6addr +ATTRIBUTE Test-ipv6prefix 7 ipv6prefix +ATTRIBUTE Test-ifid 8 ifid +ATTRIBUTE Test-ether 11 ether + +ATTRIBUTE Test-bool 12 bool + +ATTRIBUTE Test-uint8 13 uint8 +ATTRIBUTE Test-uint16 14 uint16 +ATTRIBUTE Test-uint32 15 uint32 +ATTRIBUTE Test-uint64 16 uint64 + +ATTRIBUTE Test-int8 17 int8 +ATTRIBUTE Test-int16 18 int16 +ATTRIBUTE Test-int32 19 int32 +ATTRIBUTE Test-int64 20 int64 + +ATTRIBUTE Test-float32 21 float32 + +ATTRIBUTE Test-time-delta 23 time_delta +ATTRIBUTE Test-date 24 date + +ATTRIBUTE Test-size 26 size + +ATTRIBUTE Test-tlv 27 tlv +ATTRIBUTE Test-struct 28 struct + +ATTRIBUTE Test-vsa 30 vsa +ATTRIBUTE Test-group 32 group + +END-PROTOCOL DHCPv6 diff --git a/src/tests/unit/protocols/dhcpv6/dns_wire_format.txt b/src/tests/unit/protocols/dhcpv6/dns_wire_format.txt index 646f03c518c..72754602df6 100644 --- a/src/tests/unit/protocols/dhcpv6/dns_wire_format.txt +++ b/src/tests/unit/protocols/dhcpv6/dns_wire_format.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 encode-pair SIP-Server-Domain-Name-List = "foo.ca" match 00 15 00 08 03 66 6f 6f 02 63 61 00 diff --git a/src/tests/unit/protocols/dhcpv6/fixed_element_arrays.txt b/src/tests/unit/protocols/dhcpv6/fixed_element_arrays.txt index 68a8fce1d14..640b4a0f18e 100644 --- a/src/tests/unit/protocols/dhcpv6/fixed_element_arrays.txt +++ b/src/tests/unit/protocols/dhcpv6/fixed_element_arrays.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # Array of 16bit integers diff --git a/src/tests/unit/protocols/dhcpv6/integers.txt b/src/tests/unit/protocols/dhcpv6/integers.txt index d067716adc6..003f2fd16ee 100644 --- a/src/tests/unit/protocols/dhcpv6/integers.txt +++ b/src/tests/unit/protocols/dhcpv6/integers.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # 1 byte unsigned integer (uint8) diff --git a/src/tests/unit/protocols/dhcpv6/microsoft.txt b/src/tests/unit/protocols/dhcpv6/microsoft.txt index c702e7db280..26dc2dce255 100644 --- a/src/tests/unit/protocols/dhcpv6/microsoft.txt +++ b/src/tests/unit/protocols/dhcpv6/microsoft.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # Microsoft VSAs. We have no idea what the contents are, and the documentation doesn't say. diff --git a/src/tests/unit/protocols/dhcpv6/rfc3315.txt b/src/tests/unit/protocols/dhcpv6/rfc3315.txt index 1a589cc5c7a..da36c020a48 100644 --- a/src/tests/unit/protocols/dhcpv6/rfc3315.txt +++ b/src/tests/unit/protocols/dhcpv6/rfc3315.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # Encoding an option header: diff --git a/src/tests/unit/protocols/dhcpv6/rfc3319.txt b/src/tests/unit/protocols/dhcpv6/rfc3319.txt index 89776d885da..797a9d54711 100644 --- a/src/tests/unit/protocols/dhcpv6/rfc3319.txt +++ b/src/tests/unit/protocols/dhcpv6/rfc3319.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # 3.1 SIP Servers Domain Name List diff --git a/src/tests/unit/protocols/dhcpv6/rfc3646.txt b/src/tests/unit/protocols/dhcpv6/rfc3646.txt index e807c0a0408..a415b953c2c 100644 --- a/src/tests/unit/protocols/dhcpv6/rfc3646.txt +++ b/src/tests/unit/protocols/dhcpv6/rfc3646.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # Encoding an option header: diff --git a/src/tests/unit/protocols/dhcpv6/rfc6355.txt b/src/tests/unit/protocols/dhcpv6/rfc6355.txt index 8ace778c529..94d43e69be6 100644 --- a/src/tests/unit/protocols/dhcpv6/rfc6355.txt +++ b/src/tests/unit/protocols/dhcpv6/rfc6355.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # Encoding an option header: diff --git a/src/tests/unit/protocols/dhcpv6/rfc8415.txt b/src/tests/unit/protocols/dhcpv6/rfc8415.txt index a37c627b790..4d0d831d4fc 100644 --- a/src/tests/unit/protocols/dhcpv6/rfc8415.txt +++ b/src/tests/unit/protocols/dhcpv6/rfc8415.txt @@ -5,8 +5,8 @@ # # Test vectors for DHCPv6 protocol # -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # 8. Client/Server Message Formats diff --git a/src/tests/unit/protocols/dhcpv6/strings.txt b/src/tests/unit/protocols/dhcpv6/strings.txt index df1197bcbd4..e9617b2daf1 100644 --- a/src/tests/unit/protocols/dhcpv6/strings.txt +++ b/src/tests/unit/protocols/dhcpv6/strings.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # Simple string type diff --git a/src/tests/unit/protocols/dhcpv6/tlvs.txt b/src/tests/unit/protocols/dhcpv6/tlvs.txt index 35ba2410d71..184f3b86126 100644 --- a/src/tests/unit/protocols/dhcpv6/tlvs.txt +++ b/src/tests/unit/protocols/dhcpv6/tlvs.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # TLV with array type values diff --git a/src/tests/unit/protocols/dhcpv6/variable_element_arrays.txt b/src/tests/unit/protocols/dhcpv6/variable_element_arrays.txt index 7d6a91b1751..bda53e44c8b 100644 --- a/src/tests/unit/protocols/dhcpv6/variable_element_arrays.txt +++ b/src/tests/unit/protocols/dhcpv6/variable_element_arrays.txt @@ -1,5 +1,5 @@ -load dhcpv6 -dictionary-load dhcpv6 +proto dhcpv6 +proto-dictionary dhcpv6 # # Array of strings, each substring should have a 16bit length field containing its length diff --git a/src/tests/unit/protocols/eap/aka/decode.txt b/src/tests/unit/protocols/eap/aka/decode.txt index 0c06e3c83e7..9b7dd3295f0 100644 --- a/src/tests/unit/protocols/eap/aka/decode.txt +++ b/src/tests/unit/protocols/eap/aka/decode.txt @@ -6,8 +6,8 @@ need-feature tls # Load the EAP-SIM module -load eap-aka-sim -dictionary-load eap-aka-sim eap/aka-sim +proto eap-aka-sim +proto-dictionary eap-aka-sim eap/aka-sim # # Encode some AKA attributes with special formats diff --git a/src/tests/unit/protocols/eap/aka/encode.txt b/src/tests/unit/protocols/eap/aka/encode.txt index e10cfd6a603..6c85d3a7310 100644 --- a/src/tests/unit/protocols/eap/aka/encode.txt +++ b/src/tests/unit/protocols/eap/aka/encode.txt @@ -6,8 +6,8 @@ need-feature tls # Load the EAP-AKA/SIM encoder/decoder -load eap-aka-sim -dictionary-load eap-aka-sim eap/aka-sim +proto eap-aka-sim +proto-dictionary eap-aka-sim eap/aka-sim # # Encode some AKA attributes with special formats diff --git a/src/tests/unit/protocols/eap/aka/error.txt b/src/tests/unit/protocols/eap/aka/error.txt index bdb8fdb2870..b282ac0adab 100644 --- a/src/tests/unit/protocols/eap/aka/error.txt +++ b/src/tests/unit/protocols/eap/aka/error.txt @@ -8,8 +8,8 @@ need-feature tls # Load the EAP-AKA/SIM encoder/decoder -load eap-aka-sim -dictionary-load eap-aka-sim eap/aka-sim +proto eap-aka-sim +proto-dictionary eap-aka-sim eap/aka-sim # AKA_RES with invalid length (too small) decode-pair.aka_tp_decode 04 03 aa bb aa aa aa aa bb bb bb bb diff --git a/src/tests/unit/protocols/eap/sim/decode.txt b/src/tests/unit/protocols/eap/sim/decode.txt index f5139ceb35d..f42c17b1b4f 100644 --- a/src/tests/unit/protocols/eap/sim/decode.txt +++ b/src/tests/unit/protocols/eap/sim/decode.txt @@ -8,8 +8,8 @@ need-feature tls # Load the EAP-AKA/SIM encoder/decoder -load eap-aka-sim -dictionary-load eap-aka-sim eap/aka-sim +proto eap-aka-sim +proto-dictionary eap-aka-sim eap/aka-sim # Boolean attribute decode-pair.sim_tp_decode 0d 01 00 00 diff --git a/src/tests/unit/protocols/eap/sim/encode.txt b/src/tests/unit/protocols/eap/sim/encode.txt index 71508820355..fdd17c6467c 100644 --- a/src/tests/unit/protocols/eap/sim/encode.txt +++ b/src/tests/unit/protocols/eap/sim/encode.txt @@ -6,8 +6,8 @@ need-feature tls # Load the EAP-AKA/SIM encoder/decoder -load eap-aka-sim -dictionary-load eap-aka-sim eap/aka-sim +proto eap-aka-sim +proto-dictionary eap-aka-sim eap/aka-sim # Boolean attribute encode-pair.sim_tp_encode Any-ID-Req = yes diff --git a/src/tests/unit/protocols/eap/sim/error.txt b/src/tests/unit/protocols/eap/sim/error.txt index 33b3c288b2a..d9474969bd0 100644 --- a/src/tests/unit/protocols/eap/sim/error.txt +++ b/src/tests/unit/protocols/eap/sim/error.txt @@ -8,8 +8,8 @@ need-feature tls # Load the EAP-AKA/SIM encoder/decoder -load eap-aka-sim -dictionary-load eap-aka-sim eap/aka-sim +proto eap-aka-sim +proto-dictionary eap-aka-sim eap/aka-sim # Zero length attribute decode-pair.sim_tp_decode 0d 00 diff --git a/src/tests/unit/protocols/ethernet/base.txt b/src/tests/unit/protocols/ethernet/base.txt index ddc0caea51b..c6f48b681e9 100644 --- a/src/tests/unit/protocols/ethernet/base.txt +++ b/src/tests/unit/protocols/ethernet/base.txt @@ -1,7 +1,7 @@ # # Tests for the ethernet encoder/decoder # -load ethernet +proto ethernet encode-proto.libfreeradius_ethernet Ethernet-Src-Address = 0x010203040506, Ethernet-Dst-Address = 0x060504030201 # data 06 04 05 04 03 02 01 01 02 03 04 05 06 00 00 diff --git a/src/tests/unit/protocols/radius/errors.txt b/src/tests/unit/protocols/radius/errors.txt index 6a44445c686..7c7fd507fde 100644 --- a/src/tests/unit/protocols/radius/errors.txt +++ b/src/tests/unit/protocols/radius/errors.txt @@ -1,8 +1,8 @@ # # Bad attributes # -load radius -dictionary-load radius +proto radius +proto-dictionary radius decode-pair 01 04 00 match fr_radius_decode_pair: Insufficient data diff --git a/src/tests/unit/protocols/radius/extended.txt b/src/tests/unit/protocols/radius/extended.txt index 106b867909a..1fdb6aa8f1b 100644 --- a/src/tests/unit/protocols/radius/extended.txt +++ b/src/tests/unit/protocols/radius/extended.txt @@ -1,6 +1,6 @@ # Load libfreeradius-radius -load radius -dictionary-load radius +proto radius +proto-dictionary radius # Example attributes as used in RFC 6929 raw 241.1 "bob" diff --git a/src/tests/unit/protocols/radius/lucent.txt b/src/tests/unit/protocols/radius/lucent.txt index cd652caed1c..a1bcf159a5a 100644 --- a/src/tests/unit/protocols/radius/lucent.txt +++ b/src/tests/unit/protocols/radius/lucent.txt @@ -1,5 +1,5 @@ -load radius -dictionary-load radius +proto radius +proto-dictionary radius encode-pair Lucent-Max-Shared-Users = 1 match 1a 0d 00 00 12 ee 00 02 07 00 00 00 01 diff --git a/src/tests/unit/protocols/radius/rfc.txt b/src/tests/unit/protocols/radius/rfc.txt index 95d38b311f4..c0058f98a74 100644 --- a/src/tests/unit/protocols/radius/rfc.txt +++ b/src/tests/unit/protocols/radius/rfc.txt @@ -74,8 +74,8 @@ # The output data is the hex version of the encode-paird attribute. # -load radius -dictionary-load radius +proto radius +proto-dictionary radius encode-pair User-Name = "bob" match 01 05 62 6f 62 diff --git a/src/tests/unit/protocols/radius/struct.txt b/src/tests/unit/protocols/radius/struct.txt index 4c05863b5b5..55ca04ff515 100644 --- a/src/tests/unit/protocols/radius/struct.txt +++ b/src/tests/unit/protocols/radius/struct.txt @@ -1,5 +1,5 @@ -load radius -dictionary-load radius +proto radius +proto-dictionary radius # # Structs in RADIUS diff --git a/src/tests/unit/protocols/radius/tunnel.txt b/src/tests/unit/protocols/radius/tunnel.txt index 81c1b9fd97f..c1649da3c00 100644 --- a/src/tests/unit/protocols/radius/tunnel.txt +++ b/src/tests/unit/protocols/radius/tunnel.txt @@ -1,5 +1,5 @@ -load radius -dictionary-load radius +proto radius +proto-dictionary radius # # We can't look at the data here, because the encode-paird Tunnel-Password has a 2 byte diff --git a/src/tests/unit/protocols/radius/unit.txt b/src/tests/unit/protocols/radius/unit.txt index 66cb5e4a0c4..9bc8537c4d0 100644 --- a/src/tests/unit/protocols/radius/unit.txt +++ b/src/tests/unit/protocols/radius/unit.txt @@ -1,6 +1,6 @@ # Load libfreeradius-radius -load radius -dictionary-load radius +proto radius +proto-dictionary radius # # And using the dictionaries diff --git a/src/tests/unit/protocols/radius/vendor.txt b/src/tests/unit/protocols/radius/vendor.txt index 849eb8c0cf0..5f20277813f 100644 --- a/src/tests/unit/protocols/radius/vendor.txt +++ b/src/tests/unit/protocols/radius/vendor.txt @@ -1,5 +1,5 @@ -load radius -dictionary-load radius +proto radius +proto-dictionary radius encode-pair SN-VPN-Name = "foo" match 1a 0d 00 00 1f e4 00 02 00 07 66 6f 6f diff --git a/src/tests/unit/protocols/radius/wimax.txt b/src/tests/unit/protocols/radius/wimax.txt index 5ea63e5b0a2..e29c012e22b 100644 --- a/src/tests/unit/protocols/radius/wimax.txt +++ b/src/tests/unit/protocols/radius/wimax.txt @@ -1,5 +1,5 @@ -load radius -dictionary-load radius +proto radius +proto-dictionary radius # # Test vectors for WiMAX attributes. diff --git a/src/tests/unit/xlat/base.txt b/src/tests/unit/xlat/base.txt index 630f685c9ee..4d3a28a1773 100644 --- a/src/tests/unit/xlat/base.txt +++ b/src/tests/unit/xlat/base.txt @@ -1,4 +1,4 @@ -dictionary-load radius +proto-dictionary radius # # Literals