REST upload response for bad POST action

Changes:
    - Rename keyword and tag.
    - Add to skip list for older REST code.

Refer: https://gerrit.openbmc-project.xyz/#/c/9596/

Resolves  openbmc/openbmc-test-automation#1341

Change-Id: Ic61c1b8bd3d797ba039fdf952b6a55cc82d575f6
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/test_lists/HW_CI b/test_lists/HW_CI
index a0784ec..3771c65 100644
--- a/test_lists/HW_CI
+++ b/test_lists/HW_CI
@@ -11,6 +11,7 @@
 -i REST_Login_Session_To_BMC
 -i Verify_REST_Get_Message_JSON_Compliant
 -i Verify_REST_Post_Message_JSON_Compliant
+-i Verify_REST_Bad_Request_Post_Message_JSON_Compliant
 -i REST_Put_Message_JSON_Format_Compliance_Test
 -i Verify_REST_JSON_Data_On_Success
 -i Verify_REST_JSON_Data_On_Failure
diff --git a/test_lists/witherspoon/skip_test_witherspoon_GA1 b/test_lists/witherspoon/skip_test_witherspoon_GA1
index 8513536..d2463bc 100755
--- a/test_lists/witherspoon/skip_test_witherspoon_GA1
+++ b/test_lists/witherspoon/skip_test_witherspoon_GA1
@@ -42,3 +42,4 @@
 # NA for GA1 service pack.
 -e Verify_Core_Dump_Size
 -e REST_Upload_Stability_Test
+-e Verify_REST_Bad_Request_Post_Message_JSON_Compliant
diff --git a/tests/test_rest_interfaces.robot b/tests/test_rest_interfaces.robot
index 2ef3e49..a15593c 100644
--- a/tests/test_rest_interfaces.robot
+++ b/tests/test_rest_interfaces.robot
@@ -173,6 +173,44 @@
     Should Be Equal As Strings  ${jsondata["status"]}  ok
 
 
+Verify REST Bad Request Post Message JSON Compliant
+    [Documentation]  Verify REST "POST" message is JSON format compliant.
+    [Tags]  Verify_REST_Bad_Request_Post_Message_JSON_Compliant
+    # Example:
+    # {
+    #   "data": {
+    #        "description": "Version already exists or failed to be extracted"
+    #    },
+    #    "message": "400 Bad Request",
+    #    "status": "error"
+    # }
+
+    # Generate 1KB file size
+    Run  dd if=/dev/zero of=dummyfile bs=1 count=0 seek=1KB
+    OperatingSystem.File Should Exist  dummyfile
+
+    # Get the content of the file and upload to BMC
+    ${image_data}=  OperatingSystem.Get Binary File  dummyfile
+
+    # Get REST session to BMC
+    Initialize OpenBMC
+
+    # Create the REST payload headers and data
+    ${data}=  Create Dictionary  data  ${image_data}
+    ${headers}=  Create Dictionary  Content-Type=application/octet-stream
+    ...  Accept=application/octet-stream
+    Set To Dictionary  ${data}  headers  ${headers}
+
+    ${resp}=  Post Request  openbmc  /upload/image  &{data}
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_BAD_REQUEST}
+    ${jsondata}=  To JSON  ${resp.content}
+    Should Be Equal  ${jsondata["data"]["description"]}
+    ...  Version already exists or failed to be extracted
+    Should Be Equal As Strings  ${jsondata["message"]}  400 Bad Request
+    Should Be Equal As Strings  ${jsondata["status"]}  error
+    Delete All Error Logs
+
+
 Verify REST Put Message JSON Compliant
     [Documentation]  Verify REST "PUT" message is JSON format compliant.
     [Tags]  REST_Put_Message_JSON_Format_Compliance_Test