Update redfish rsp code for cert update/install

Changes:
    - Updated redfish response code to expect either 200 or 204
      while updating or installing certificate via redfish.
    - Both client / server certificate response code updated.

Tested:
     - Ran All The Scripts Successfully

Change-Id: Iae3c9c68b433e78c7c51a8891c0df1ac084b8595
Signed-off-by: ganesanb <ganesanb@ami.com>
diff --git a/lib/dmtf_redfishtool_utils.robot b/lib/dmtf_redfishtool_utils.robot
index 936e3d1..b8df802 100644
--- a/lib/dmtf_redfishtool_utils.robot
+++ b/lib/dmtf_redfishtool_utils.robot
@@ -22,11 +22,10 @@
     # expected_error  Expected error optionally provided in testcase (e.g. 401 /
     #                 authentication error, etc. ).
 
-    ${rc}  ${cmd_output}=  Run and Return RC and Output  ${cmd_args} GET ${uri}
-    Run Keyword If  ${rc} == 0
-    ...    Should Be True  ${expected_error} == 200
-    ...  ELSE
-    ...    Is HTTP error Expected  ${cmd_output}  ${expected_error}
+    ${cmd}=  Catenate  ${cmd_args} GET ${uri}
+    Log  ${cmd}
+    ${rc}  ${cmd_output}=  Run and Return RC and Output  ${cmd}
+    Run Keyword If  ${rc} != 0  Is HTTP error Expected  ${cmd_output}  ${expected_error}
 
     [Return]  ${cmd_output}
 
@@ -42,11 +41,10 @@
     # expected_error  Expected error optionally provided in testcase (e.g. 401 /
     #                 authentication error, etc. ).
 
-    ${rc}  ${cmd_output}=  Run and Return RC and Output  ${cmd_args} PATCH ${uri} --data=${payload}
-    Run Keyword If  ${rc} == 0
-    ...    Should Be True  ${expected_error} == 200
-    ...  ELSE
-    ...    Is HTTP error Expected  ${cmd_output}  ${expected_error}
+    ${cmd}=  Catenate  ${cmd_args} PATCH ${uri} --data=${payload}
+    Log  ${cmd}
+    ${rc}  ${cmd_output}=  Run and Return RC and Output  ${cmd}
+    Run Keyword If  ${rc} != 0  Is HTTP error Expected  ${cmd_output}  ${expected_error}
 
     [Return]  ${cmd_output}
 
@@ -62,12 +60,11 @@
     # cmd_args        Commandline arguments.
     # expected_error  Expected error optionally provided in testcase (e.g. 401 /
     #                 authentication error, etc. ).
-
-    ${rc}  ${cmd_output}=  Run and Return RC and Output  ${cmd_args} POST ${uri} --data=${payload}
-    Run Keyword If  ${rc} == 0
-    ...    Should Be True  ${expected_error} == 200
-    ...  ELSE
-    ...    Is HTTP error Expected  ${cmd_output}  ${expected_error}
+    
+    ${cmd}=  Catenate  ${cmd_args} POST ${uri} --data=${payload}
+    Log  ${cmd}
+    ${rc}  ${cmd_output}=  Run and Return RC and Output  ${cmd}
+    Run Keyword If  ${rc} != 0  Is HTTP error Expected  ${cmd_output}  ${expected_error}
 
     [Return]  ${cmd_output}
 
@@ -82,11 +79,10 @@
     # expected_error  Expected error optionally provided in testcase (e.g. 401 /
     #                 authentication error, etc. ).
 
-    ${rc}  ${cmd_output}=  Run and Return RC and Output  ${cmd_args} DELETE ${uri}
-    Run Keyword If  ${rc} == 0
-    ...    Should Be True  ${expected_error} == 200
-    ...  ELSE
-    ...    Is HTTP error Expected  ${cmd_output}  ${expected_error}
+    ${cmd}=  Catenate  ${cmd_args} DELETE ${uri}
+    Log  ${cmd}
+    ${rc}  ${cmd_output}=  Run and Return RC and Output  ${cmd}
+    Run Keyword If  ${rc} != 0  Is HTTP error Expected  ${cmd_output}  ${expected_error}
 
     [Return]  ${cmd_output}
 
@@ -99,7 +95,23 @@
     # cmd_output      Output of an HTTP operation.
     # error_expected  Expected error.
 
-    Should Be True  ${error_expected} != 200
+    ${cmd_rsp}=  Get Regexp Matches  ${cmd_output}  200|204
+    ${cmd_rsp_status}=  Run Keyword And Return Status  Should Not Be Empty  ${cmd_rsp}
+    Return From Keyword IF  ${cmd_rsp_status} == True
+    ${matches}=  Get Regexp Matches  ${error_expected}  200|204
+    ${rsp_status}=  Run Keyword And Return Status  Should Be Empty  ${matches}
+    Run Keyword If  ${rsp_status} == False
+    ...  Fail  msg=${cmd_output}
     @{words} =  Split String  ${error_expected}  ,
     @{errorString}=  Split String  ${cmd_output}  ${SPACE}
-    Should Contain Any  ${errorString}  @{words}
+    FOR  ${error}  IN  @{words}
+      ${status}=  Run Keyword And Return Status  Should Contain Any  ${errorString}  ${error}
+      Return From Keyword If  ${status} == True
+    END
+    ${rsp_code}=  Run Keyword If  ${status} == False  Get Regexp Matches  ${cmd_output}  [0-9][0-9][0-9]
+    ${rsp_code_status}=  Run Keyword And Return Status  Should Not Be Empty  ${rsp_code}
+    Run Keyword If  ${rsp_code_status} == True
+    ...    Fail  msg=Getting status code as ${rsp_code[0]} instead of ${error_expected}, status code mismatch.
+    ...  ELSE
+    ...    Fail  msg=${cmd_output}
+