Add code to handle response errors

Changes:
   - Added new message response
   - Add logic to except all errors and verify the message

   Version Tessted:
   redfish                         3.1.6
   redfish                         3.1.7

Tested:
   - Tested test case Redfish_Login_With_Invalid_Credentials
     from suite  redfish/service_root/test_service_root_security.robot

Resolves  openbmc/openbmc-test-automation#2195

Change-Id: I13ff4bb9e6029f1039e9b8fea6d98f02329eb081
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/redfish/service_root/test_service_root_security.robot b/redfish/service_root/test_service_root_security.robot
index 0686d6f..be1149a 100644
--- a/redfish/service_root/test_service_root_security.robot
+++ b/redfish/service_root/test_service_root_security.robot
@@ -27,12 +27,12 @@
     [Tags]  Redfish_Login_With_Invalid_Credentials
     [Template]  Login And Verify Redfish Response
 
-    # Expect status            Username               Password
-    InvalidCredentialsError*   ${OPENBMC_USERNAME}    deadpassword
-    InvalidCredentialsError*   groot                  ${OPENBMC_PASSWORD}
-    InvalidCredentialsError*   ${EMPTY}               ${OPENBMC_PASSWORD}
-    InvalidCredentialsError*   ${OPENBMC_USERNAME}    ${EMPTY}
-    InvalidCredentialsError*   ${EMPTY}               ${EMPTY}
+    # Username                Password               Expect status
+    ${OPENBMC_USERNAME}       deadpassword           InvalidCredentialsError
+    groot                     ${OPENBMC_PASSWORD}    InvalidCredentialsError
+    ${EMPTY}                  ${OPENBMC_PASSWORD}    SessionCreationError
+    ${OPENBMC_USERNAME}       ${EMPTY}               SessionCreationError
+    ${EMPTY}                  ${EMPTY}               SessionCreationError
 
 
 Redfish Login Using Unsecured HTTP
@@ -151,12 +151,12 @@
 
 Login And Verify Redfish Response
     [Documentation]  Login and verify redfish response.
-    [Arguments]  ${expected_response}  ${username}  ${password}
+    [Arguments]   ${username}  ${password}  ${expected_response}
 
     # Description of arguments:
-    # expected_response   Expected REST status.
-    # username            The username to be used to connect to the server.
-    # password            The password to be used to connect to the server.
+    # expected_response    Expected REST status.
+    # username             The username to be used to connect to the server.
+    # password             The password to be used to connect to the server.
 
     # The redfish object may preserve a valid username or password from the
     # last failed login attempt.  If we then try to login with a null username
@@ -167,8 +167,10 @@
     Redfish.Set Username  ${EMPTY}
     Redfish.Set Password  ${EMPTY}
 
-    Run Keyword And Expect Error  ${expected_response}
-    ...  Redfish.Login  ${username}  ${password}
+    ${msg}=  Run Keyword And Expect Error  *  Redfish.Login  ${username}  ${password}
+
+    # redfish package version <=3.1.6 default response is InvalidCredentialsError.
+    Should Contain Any   ${msg}  InvalidCredentialsError  ${expected_response}
 
 
 Create New Login Session