mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-16 09:46:22 +00:00
res_pjsip_config_wizard/config: Fix template processing
The config wizard was always pulling the first occurrence of a variable from an ast_variable list but this gets the template value from the list instead of any overridden value. This patch creates ast_variable_find_last_in_list() in config.c and updates res_pjsip_config_wizard to use it instead of ast_variable_find_in_list. Now the overridden values, where they exist, are used instead of template variables. Updated test_config to test the new API. ASTERISK-25089 #close Reported-by: George Joseph <george.joseph@fairview5.com> Tested-by: George Joseph <george.joseph@fairview5.com> Change-Id: Ifa7ddefc956a463923ee6839dd1ebe021c299de4
This commit is contained in:
@@ -234,6 +234,7 @@ AST_TEST_DEFINE(config_basic_ops)
|
||||
struct ast_config *cfg = NULL;
|
||||
struct ast_category *cat = NULL;
|
||||
struct ast_variable *var;
|
||||
struct ast_variable *varlist;
|
||||
char temp[32];
|
||||
const char *cat_name;
|
||||
const char *var_value;
|
||||
@@ -537,6 +538,22 @@ AST_TEST_DEFINE(config_basic_ops)
|
||||
goto out;
|
||||
}
|
||||
|
||||
varlist = ast_variable_new("name1", "value1", "");
|
||||
ast_variable_list_append_hint(&varlist, NULL, ast_variable_new("name1", "value2", ""));
|
||||
ast_variable_list_append_hint(&varlist, NULL, ast_variable_new("name1", "value3", ""));
|
||||
|
||||
var_value = ast_variable_find_in_list(varlist, "name1");
|
||||
if (strcmp(var_value, "value1") != 0) {
|
||||
ast_test_status_update(test, "Wrong variable retrieved %s.\n", var_value);
|
||||
goto out;
|
||||
}
|
||||
|
||||
var_value = ast_variable_find_last_in_list(varlist, "name1");
|
||||
if (strcmp(var_value, "value3") != 0) {
|
||||
ast_test_status_update(test, "Wrong variable retrieved %s.\n", var_value);
|
||||
goto out;
|
||||
}
|
||||
|
||||
res = AST_TEST_PASS;
|
||||
|
||||
out:
|
||||
|
Reference in New Issue
Block a user