[RIC-395] - E2M new REST API - E2M Set Parameters - Automation + Decoder

Change-Id: I4cefd6da49c6e67103ad07d2612b41aa6f955fbf
Signed-off-by: Irina <ib565x@intl.att.com>
diff --git a/Automation/Tests/SetGeneralConfiguration/set_general_configuration.robot b/Automation/Tests/SetGeneralConfiguration/set_general_configuration.robot
index da7356b..c6f74c1 100644
--- a/Automation/Tests/SetGeneralConfiguration/set_general_configuration.robot
+++ b/Automation/Tests/SetGeneralConfiguration/set_general_configuration.robot
@@ -23,8 +23,10 @@
 
 *** 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}
 
@@ -33,16 +35,16 @@
 
 *** 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
 
-Verify e2mgr logs - Third retry to retrieve from db
-   ${result}    find_error_script.find_error     ${EXECDIR}  ${e2mgr_log_filename}   ${save_general_configuration}
+prepare logs for tests
+    Remove log files
+    Save logs
+
+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
diff --git a/E2Manager/container-tag.yaml b/E2Manager/container-tag.yaml
index 273b7ac..3e5978b 100644
--- a/E2Manager/container-tag.yaml
+++ b/E2Manager/container-tag.yaml
@@ -1,4 +1,4 @@
 # 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
diff --git a/E2Manager/controllers/nodeb_controller.go b/E2Manager/controllers/nodeb_controller.go
index 49e821d..cef57f9 100644
--- a/E2Manager/controllers/nodeb_controller.go
+++ b/E2Manager/controllers/nodeb_controller.go
@@ -103,7 +103,7 @@
 
 	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)
@@ -165,6 +165,21 @@
 	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))
diff --git a/E2Manager/controllers/nodeb_controller_test.go b/E2Manager/controllers/nodeb_controller_test.go
index 1543674..8209228 100644
--- a/E2Manager/controllers/nodeb_controller_test.go
+++ b/E2Manager/controllers/nodeb_controller_test.go
@@ -300,7 +300,7 @@
 
 	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)