Adding 1 testcase to GUI user management.
1. Edit And Verify User Property
Change-Id: Icbb1a07bdc57d9130f89eacf850a03d71f0e08fd
Signed-off-by: Anusha Dathatri <adathatr@in.ibm.com>
diff --git a/gui/test/users/test_obmc_gui_manage_user.robot b/gui/test/users/test_obmc_gui_manage_user.robot
index de361b5..894b95d 100644
--- a/gui/test/users/test_obmc_gui_manage_user.robot
+++ b/gui/test/users/test_obmc_gui_manage_user.robot
@@ -32,6 +32,13 @@
... modify=User has been updated successfully
... add_dup=Username exists
&{user_invalid_password} root=rootPwd1
+${max_num_users} ${15}
+${xpath_table_base} //*[@id="user-accounts"]/div[4]/div[2]
+&{user_table_column_xpath_mapping} Username=/div[1]
+ ... Enabled=/div[2]
+ ... Role=/div[3]
+ ... Edit=/div[5]/button[1]
+ ... Delete=/div[5]/button[2]
@@ -101,6 +108,17 @@
LogOut OpenBMC GUI
Login And Verify Message root &{user_invalid_password}[root] Invalid username or password
+Edit And Verify User Property
+ [Documentation] Edit and verify the user property.
+ [Tags] Edit_And_Verify_User_Property
+ [Setup] Run Keywords Test Setup Execution AND Delete Given Users
+
+ Add Or Modify User testUser1 &{user_password}[testUser1] User
+ Reload Page
+ Edit User Role testUser1 &{user_password}[testUser1] Callback
+ ${user_role}= Get User Property Value testUser1 Role
+ Should Be Equal ${user_role} Callback
+
*** Keywords ***
Test Setup Execution
@@ -113,9 +131,10 @@
Wait Until Page Contains User account information
Add Or Modify User
- [Documentation] Creates or edits user.
+ [Documentation] Create or edit user.
[Arguments] ${username} ${password} ${role}=Administrator ${enabled}=${True}
... ${action}=add
+
# Description of argument(s):
# username Name of the user to be created.
# role Role of the new user.
@@ -128,7 +147,6 @@
... Input Text ${xpath_input_username} ${username}
Input Password ${xpath_input_password} ${password}
Input Password ${xpath_input_retype_password} ${password}
- Log ${role}
Select From List By Value ${xpath_input_user_role} ${role}
Run Keyword If '${enabled}' == 'True' Click Element ${xpath_input_enabled_checkbox}
Run Keyword If '${action}' == 'modify'
@@ -138,8 +156,9 @@
Page Should Contain &{action_msg_relation}[${action}]
Delete Given Users
- [Documentation] Deletes users based on the input.
+ [Documentation] Delete given users.
[Arguments] ${delete_user}=nonRoot
+
# Description of argument(s):
# delete_user values - nonRoot/username
# If nonRoot - Deletes all non-root users,
@@ -149,27 +168,77 @@
Run Keyword If '${delete_user}' != 'nonRoot' Page Should Contain ${delete_user}
# Row id that gets deleted in every iteration.
${deleting_row_id}= Set Variable 1
- :FOR ${row} IN RANGE 1 16
- \ ${xpath_user}= Set Variable //*[@id="user-accounts"]/div[4]/div[2]/div[${deleting_row_id}]/div[1]
+ :FOR ${row} IN RANGE 1 ${max_num_users+1}
+ \ ${xpath_user}= Get Xpath For User Table Attribute Username ${row}
\ ${status}= Run Keyword And Return Status Page Should Contain Element ${xpath_user}
\ Exit For Loop If '${status}' == 'False'
\ ${user}= Get Text ${xpath_user}
- \ ${deleting_row_id} Run Keyword If '${user}' == 'root' or '${deleting_row_id}' == '2' Set Variable 2
- \ ... ELSE Set Variable 1
+ \ ${deleting_row_id} Set Variable If '${user}' == 'root' or '${deleting_row_id}' == '2'
+ \ ... 2 1
\ Continue For Loop If '${user}' == 'root'
\ ${xpath_delete_user} Run Keyword If '${user}' == '${delete_user}' or '${delete_user}' == 'nonRoot'
- \ ... Set Variable //*[@id="user-accounts"]/div[4]/div[2]/div[${deleting_row_id}]/div[5]/button[2]
+ \ ... Get Xpath For User Table Attribute Delete ${deleting_row_id}
\ Run Keyword If '${user}' == '${delete_user}' or '${delete_user}' == 'nonRoot'
\ ... Run Keywords Click Button ${xpath_delete_user}
\ ... AND Page Should Contain User has been deleted successfully
\ ... AND Reload Page
\ ... AND Exit For Loop If '${user}' == '${delete_user}'
+Get User Property Value
+ [Documentation] Return property value for the given user.
+ [Arguments] ${username} ${property}=Role
+
+ # Description of argument(s):
+ # username BMC Username.
+ # property User property (e.g. "Role" or "Enabled").
+
+ # Maximum user limit is 15. Hence iterating only 15 times.
+ :FOR ${row_num} IN RANGE 1 ${max_num_users+1}
+ \ ${xpath_user}= Get Xpath For User Table Attribute Username ${row_num}
+ \ Page Should Contain Element ${xpath_user}
+ \ ${xpath_property}= Get Xpath For User Table Attribute ${property} ${row_num}
+ \ ${user}= Get Text ${xpath_user}
+ \ Run Keyword And Return If '${user}' == '${username}' Get Text ${xpath_property}
+
Login And Verify Message
[Documentation] Verifies the error message displayed on screen while logging in.
[Arguments] ${username} ${password} ${msg}
+ # Description of argument(s):
+ # username BMC Username.
+ # password BMC Password.
+ # msg Message which is expected to be found on login page after login attempt.
+
Input Text ${xpath_textbox_username} ${username}
Input Password ${xpath_textbox_password} ${password}
Click Element ${xpath_button_login}
Page Should Contain ${msg}
+
+Edit User Role
+ [Documentation] Change the role of user to the given value.
+ [Arguments] ${username} ${password} ${user_role}
+
+ # Description of argument(s):
+ # username BMC Username.
+ # password BMC Password.
+ # user_role The user role to be assigned ("administrator", "user", "operator", "callback").
+
+ # Maximum user limit is 15. Hence iterating only 15 times.
+ :FOR ${row_num} IN RANGE 1 ${max_num_users+1}
+ \ ${xpath_user}= Get Xpath For User Table Attribute Username ${row_num}
+ \ Page Should Contain Element ${xpath_user}
+ \ ${xpath_edit_user}= Get Xpath For User Table Attribute Edit ${row_num}
+ \ ${user}= Get Text ${xpath_user}
+ \ Run Keyword If '${user}' == '${username}' Run Keywords Click Element ${xpath_edit_user}
+ \ ... AND Add Or Modify user ${username} ${password} ${user_role} action=modify
+ \ ... AND Exit For Loop
+
+Get Xpath For User Table Attribute
+ [Documentation] Get xpath for given user table attribute.
+ [Arguments] ${attribute} ${row_num}
+
+ # Description of argument(s):
+ # attribute User table attribute ("Username", "Enabled", "Role", "Edit", "Delete").
+ # row_num Row number.
+
+ [Return] ${xpath_table_base}/div[${row_num}]&{user_table_column_xpath_mapping}[${attribute}]