Verify Login with Deleted Redfish Users

Change-Id: I5762275824c7756aa8f953d28b6edccd2b8e2af0
Signed-off-by: Sandhya Somashekar <sansomas@in.ibm.com>
diff --git a/redfish/account_service/test_user_account.robot b/redfish/account_service/test_user_account.robot
index 99900d8..0ebe3f7 100644
--- a/redfish/account_service/test_user_account.robot
+++ b/redfish/account_service/test_user_account.robot
@@ -40,6 +40,17 @@
        user_user      TestPwd123  User            ${True}  12
        callback_user  TestPwd123  Callback        ${True}  !#@D#RF#@!D
 
+Verify Login with Deleted Redfish Users
+    [Documentation]  Verify login with deleted Redfish Users
+    [Tags]  Verify_Login_with_Deleted_Redfish_Users
+    [Template]  Verify Login with Deleted Redfish User
+
+     # username       password    role_id         enabled
+       admin_user     TestPwd123  Administrator   ${True}
+       operator_user  TestPwd123  Operator        ${True}
+       user_user      TestPwd123  User            ${True}
+       callback_user  TestPwd123  Callback        ${True}
+
 
 *** Keywords ***
 
@@ -62,8 +73,10 @@
     # Description of argument(s):
     # username            The username to be created.
     # password            The password to be assigned.
-    # role_id             The role id of the user to be created.
-    # enabled             The decision if it should be enabled.
+    # role_id             The role id of the user to be created
+    #                     (e.g. "Administrator", "Operator", etc.).
+    # enabled             Indicates whether the username being created
+    #                     should be enabled (${True}, ${False}).
 
     # Example:
     #{
@@ -79,7 +92,7 @@
     #  }
     #},
 
-    # Delete if the user exist.
+    # Make sure the user account in question does not already exist.
     Run Keyword And Ignore Error
     ...  Redfish.Delete  /redfish/v1/AccountService/Accounts/${userName}
 
@@ -111,11 +124,13 @@
     # Description of argument(s):
     # username            The username to be created.
     # password            The password to be assigned.
-    # role_id             The role id of the user to be created.
-    # enabled             The decision if it should be enabled.
+    # role_id             The role id of the user to be created
+    #                     (e.g. "Administrator", "Operator", etc.).
+    # enabled             Indicates whether the username being created
+    #                     should be enabled (${True}, ${False}).
     # wrong_password      Any invalid password.
 
-    # Delete if the user exist.
+    # Make sure the user account in question does not already exist.
     Run Keyword And Ignore Error
     ...  Redfish.Delete  /redfish/v1/AccountService/Accounts/${userName}
 
@@ -142,3 +157,42 @@
     Redfish.Delete  /redfish/v1/AccountService/Accounts/${userName}
 
 
+Verify Login with Deleted Redfish User
+    [Documentation]  Verify Login with Deleted Redfish User
+    [Arguments]   ${username}  ${password}  ${role_id}  ${enabled}
+
+    # Description of argument(s):
+    # username            The username to be created.
+    # password            The password to be assigned.
+    # role_id             The role id of the user to be created
+    #                     (e.g. "Administrator", "Operator", etc.).
+    # enabled             Indicates whether the username being created
+    #                     should be enabled (${True}, ${False}).
+
+    # Make sure the user account in question does not already exist.
+    Run Keyword And Ignore Error
+    ...  Redfish.Delete  /redfish/v1/AccountService/Accounts/${userName}
+
+    Redfish.Login
+
+    # Create specified user.
+    ${payload}=  Create Dictionary
+    ...  UserName=${username}  Password=${password}  RoleId=${role_id}  Enabled=${enabled}
+    Redfish.Post  /redfish/v1/AccountService/Accounts  body=&{payload}
+    ...  valid_status_codes=[${HTTP_CREATED}]
+
+    Redfish.Logout
+
+    # Login with created user.
+    Redfish.Login  ${username}  ${password}
+
+    Redfish.Logout
+
+    Redfish.Login
+
+    # Delete newly created user.
+    Redfish.Delete  /redfish/v1/AccountService/Accounts/${userName}
+
+    # Attempt to login with deleted user account.
+    Run Keyword And Expect Error  InvalidCredentialsError*
+    ...  Redfish.Login  ${username}  ${password}