dynsec: Consistent behaviour when setting clientid.

This commit is contained in:
Roger A. Light 2020-11-26 12:18:57 +00:00
parent 047c09bd32
commit d8775b7d9c
3 changed files with 14 additions and 9 deletions

View File

@ -697,12 +697,16 @@ int dynsec_clients__process_modify(cJSON *j_responses, struct mosquitto *context
}
if(json_get_string(command, "clientid", &clientid, false) == MOSQ_ERR_SUCCESS){
if(clientid && strlen(clientid) > 0){
str = mosquitto_strdup(clientid);
if(str == NULL){
dynsec__command_reply(j_responses, context, "modifyClient", "Internal error", correlation_data);
return MOSQ_ERR_NOMEM;
}
mosquitto_free(client->clientid);
}else{
str = NULL;
}
client->clientid = str;
}

View File

@ -50,9 +50,9 @@ list_clients_verbose_response = {'responses':[{"command": "listClients", "data":
get_client_command = { "commands": [{
"command": "getClient", "username": "user_one"}]}
"command": "getClient", "username": "user_one", "correlationData": "42"}]}
get_client_response = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one', 'clientid': 'cid',
'textname': 'Name', 'textdescription': 'Description', 'groups': [], 'roles': []}}}]}
'textname': 'Name', 'textdescription': 'Description', 'groups': [], 'roles': []}}, "correlationData":"42"}]}
set_client_password_command = {"commands": [{
"command": "setClientPassword", "username": "user_one", "password": "password"}]}

View File

@ -80,6 +80,7 @@ create_roles_response = {'responses': [
modify_client_command1 = { "commands": [{
"command": "modifyClient", "username": "user_one",
"textname": "Modified name", "textdescription": "Modified description",
"clientid": "",
"roles":[
{'rolename':'role_one', 'priority':2},
{'rolename':'role_two'},
@ -112,7 +113,7 @@ get_client_response1 = {'responses':[{'command': 'getClient', 'data': {'client':
get_client_command2 = { "commands": [{
"command": "getClient", "username": "user_one"}]}
get_client_response2 = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one', 'clientid': 'cid',
get_client_response2 = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one',
'textname': 'Modified name', 'textdescription': 'Modified description',
'roles': [
{'rolename':'role_three', 'priority':10},
@ -126,7 +127,7 @@ get_client_response2 = {'responses':[{'command': 'getClient', 'data': {'client':
get_client_command3 = { "commands": [{
"command": "getClient", "username": "user_one"}]}
get_client_response3 = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one', 'clientid': 'cid',
get_client_response3 = {'responses':[{'command': 'getClient', 'data': {'client': {'username': 'user_one',
'textname': 'Modified name', 'textdescription': 'Modified description',
'groups': [],
'roles': [