Project

General

Profile

Bug #16684

Updated by François ARMAND about 4 years ago

When testing authorized network API, I get for GET: 

 <pre> 
 % curl -k -X GET -H "X-API-TOKEN: 976051bb-a539-4685-ab1c-a70182a1d89f-system" https://xxxx/rudder/api/latest/settings/authorizedNetworks/root | jq . 
 { 
   "action": "getAuthorizedNetworks", 
   "id": "root", 
   "result": "success", 
   "data": { 
     "settings": [ 
       "192.168.52.0/24", 
       "192.168.52.0/24" 
     ] 
   } 
 } 
 </pre> 

 So I tried to update with that POST, but it deleted everything: 

 <pre> 
 % curl -k -X POST -H "Content-Type: application/json" -H "X-API-TOKEN: 976051bb-a539-4685-ab1c-a70182a1d89f-system" https://xxxx/rudder/api/latest/settings/authorizedNetworks/root https://192.168.52.2/rudder/api/latest/settings/authorizedNetworks/root -d '{"settings":["192.168.52.0/16"]}'    | jq . 
 { 
   "action": "modifyAuthorizedNetworks", 
   "id": "root", 
   "result": "success", 
   "data": { 
     "settings": [] 
   } 
 } 
 </pre> 

 The actual JSON is: 

 <pre> 
 % curl -k -X POST -H "Content-Type: application/json" -H "X-API-TOKEN: 976051bb-a539-4685-ab1c-a70182a1d89f-system" https://xxxx/rudder/api/latest/settings/authorizedNetworks/root https://192.168.52.2/rudder/api/latest/settings/authorizedNetworks/root -d '{"authorizedNetworks":["192.168.52.0/24"]}'    | jq . 
 { 
   "action": "modifyAuthorizedNetworks", 
   "id": "root", 
   "result": "success", 
   "data": { 
     "settings": [ 
       "192.168.52.0/24" 
     ] 
   } 
 } 
 </pre> 

 Two things here:  

 - in the "data" part, the name should be @authorizedNetworks@ and not @settings@,  
 - if the @authorizedNetworks@ key is missing in POSTed JSON, we should do nothing.  

 Finally, for consistancy with other settings, I believe we should use @settings/authorized_networks/@

Back