*** Settings ***
Suite Setup Prepare Enviorment
+Resource ../Resource/scripts_variables.robot
Resource ../Resource/resource.robot
Resource ../Resource/Keywords.robot
+Library ../Scripts/find_error_script.py
Library OperatingSystem
Library REST ${url}
*** Test Cases ***
-prepare logs for tests
- Remove log files
- Save logs
-
Set General Configuration
Sleep 2s
Set General Configuration request
Integer response status 200
- String response body enableRic false
+ Boolean response body enableRic false
+
+prepare logs for tests
+ Remove log files
+ Save logs
-Verify e2mgr logs - Third retry to retrieve from db
- ${result} find_error_script.find_error ${EXECDIR} ${e2mgr_log_filename} ${save_general_configuration}
+Verify e2mgr logs - Save General Configuration
+ ${result} find_error_script.find_error ${EXECDIR} ${e2mgr_log_filename} ${save_general_configuration}
Should Be Equal As Strings ${result} True
\ No newline at end of file
# The Jenkins job requires a tag to build the Docker image.
# Global-JJB script assumes this file is in the repo root.
---
-tag: 5.2.0
+tag: 5.2.1
request := models.GeneralConfigurationRequest{}
- if !c.extractJsonBody(r, &request, writer){
+ if !c.extractJsonBodyDisallowUnknownFields(r, &request, writer){
return
}
c.handleRequest(writer, &r.Header, httpmsghandlerprovider.SetGeneralConfigurationRequest, request, false)
return true
}
+func (c *NodebController) extractJsonBodyDisallowUnknownFields(r *http.Request, request models.Request, writer http.ResponseWriter) bool {
+ defer r.Body.Close()
+
+ decoder := json.NewDecoder(r.Body)
+ decoder.DisallowUnknownFields()
+
+ if err := decoder.Decode(&request); err != nil {
+ c.logger.Errorf("[Client -> E2 Manager] #NodebController.extractJsonBody - unable to extract json body - error: %s", err)
+ c.handleErrorResponse(e2managererrors.NewInvalidJsonError(), writer)
+ return false
+ }
+
+ return true
+}
+
func (c *NodebController) extractJsonBody(r *http.Request, request models.Request, writer http.ResponseWriter) bool {
defer r.Body.Close()
body, err := ioutil.ReadAll(io.LimitReader(r.Body, LimitRequest))
writer := httptest.NewRecorder()
- httpRequest, _ := http.NewRequest("PUT", "https://localhost:3800/v1/nodeb/parameters", strings.NewReader("{}{}"))
+ httpRequest, _ := http.NewRequest("PUT", "https://localhost:3800/v1/nodeb/parameters", strings.NewReader("{\"enableRic\":false, \"someValue\":false}"))
controller.SetGeneralConfiguration(writer, httpRequest)