Added User deletion code in teardown.
Moved code for deletion of created user list to Test Teardown.
so that in case if testcase fail, created user will delete.
Tested: Run robot redfish/account_service/test_ipmi_redfish_user.robot
Signed-off-by: Nagarjun B <nagarjunb@ami.com>
Change-Id: Ibc9ab6f30e3182b13d901e7e6d8ab7d75ce5e19c
diff --git a/redfish/account_service/test_ipmi_redfish_user.robot b/redfish/account_service/test_ipmi_redfish_user.robot
index 97ed2a9..c004d6d 100644
--- a/redfish/account_service/test_ipmi_redfish_user.robot
+++ b/redfish/account_service/test_ipmi_redfish_user.robot
@@ -201,6 +201,8 @@
Verify Failure To Exceed Max Number Of Users
[Documentation] Verify failure attempting to exceed the max number of user accounts.
[Tags] Verify_Failure_To_Exceed_Max_Number_Of_Users
+ [Teardown] Run Keywords Test Teardown Execution
+ ... AND Delete Users Via Redfish ${username_list}
# Get existing user count.
${resp}= Redfish.Get /redfish/v1/AccountService/Accounts/
@@ -226,10 +228,6 @@
Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload}
... valid_status_codes=[${HTTP_BAD_REQUEST}]
- FOR ${saved_user_list} IN @{username_list}
- Redfish.Delete ${saved_user_list}
- END
-
Create IPMI User Without Any Privilege And Verify Via Redfish
[Documentation] Create user using IPMI without privilege and verify via redfish.
@@ -275,6 +273,22 @@
[Return] ${random_username} ${random_userid}
+Delete Users Via Redfish
+ [Documentation] Delete all the users via redfish from given list.
+ [Arguments] ${user_list}
+
+ # Description of argument(s):
+ # user_list List of user which are to be deleted.
+
+ Redfish.Login
+
+ FOR ${user} IN @{user_list}
+ Redfish.Delete ${user}
+ END
+
+ Redfish.Logout
+
+
Test Setup Execution
[Documentation] Do test case setup tasks.