Add user previlege test cases
Change-Id: I648de68cf51267d3fdd3bd3893e9fb5ca56f0f95
Signed-off-by: manashsarma <manashsarma@in.ibm.com>
diff --git a/redfish/dmtf_tools/test_redfishtool.robot b/redfish/dmtf_tools/test_redfishtool.robot
index ff05c18..43f2d7a 100644
--- a/redfish/dmtf_tools/test_redfishtool.robot
+++ b/redfish/dmtf_tools/test_redfishtool.robot
@@ -20,6 +20,8 @@
${root_cmd_args} redfishtool raw -r ${OPENBMC_HOST} -u ${OPENBMC_USERNAME} -p ${OPENBMC_PASSWORD} -S Always
${min_number_sensors} ${15}
+${min_number_roles} ${4}
+${min_number_users} ${1}
*** Test Cases ***
@@ -74,8 +76,64 @@
Should Be True ${status} == False
+Verify Redfishtool Login With Deleted Redfish Users
+ [Documentation] Verify login with deleted user via Redfishtool.
+ [Tags] Verify_Redfishtool_Login_With_Deleted_Redfish_Users
+
+ Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
+ Redfishtool Delete User "UserT100"
+ Redfishtool Access Resource /redfish/v1/AccountService/Accounts "UserT100" "TestPwd123" ${HTTP_UNAUTHORIZED}
+
+Verify Redfishtool Error Upon Creating Same Users With Different Privileges
+ [Documentation] Verify error upon creating same users with different previleges.
+ [Tags] Verify_Redfishtool_Error_Upon_Creating_Same_Users_With_Different_Privileges
+ [Teardown] Redfishtool Delete User "UserT100"
+
+ Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
+ Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true expected_error=${HTTP_BAD_REQUEST}
+
+
+Verify Redfishtool Admin User Privilege
+ [Documentation] Verify previlege of admin user.
+ [Tags] Verify_Redfishtool_Admin_User_Privilege
+ [Teardown] Run Keywords Redfishtool Delete User "UserT100" AND
+ ... Redfishtool Delete User "UserT101"
+
+ Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true
+
+ # Verify if an user can be added by admin
+ Redfishtool Create User "UserT101" "TestPwd123" "Operator" true "UserT100" "TestPwd123"
+
+
+Verify Redfishtool ReadOnly User Privilege
+ [Documentation] Verify Redfishtool ReadOnly user privilege works.
+ [Tags] Verify_Redfishtool_ReadOnly_User_Privilege
+ [Teardown] Redfishtool Delete User "UserT100"
+
+ Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true
+ Redfishtool Access Resource /redfish/v1/Systems/ "UserT100" "TestPwd123"
+
+ Redfishtool Create User
+ ... "UserT101" "TestPwd123" "Operator" true "UserT100" "TestPwd123" ${HTTP_FORBIDDEN}
+
+
*** Keywords ***
+Redfishtool Access Resource
+ [Documentation] Access resource.
+ [Arguments] ${uri} ${login_user} ${login_pasword} ${expected_error}=""
+
+ # Description of argument(s):
+ # uri URI for resource access.
+ # login_user The login user name used other than default root user.
+ # login_pasword The login password.
+ # expected_error Expected error optionally provided in testcase (e.g. 401 /
+ # authentication error, etc. )
+
+ ${user_cmd_args}= Set Variable
+ ... redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always
+ Redfishtool Get ${uri} ${user_cmd_args} ${expected_error}
+
Is HTTP error Expected
[Documentation] Check if the HTTP error is expected.
@@ -91,7 +149,7 @@
Redfishtool Create User
[Documentation] Create new user.
- [Arguments] ${user_name} ${password} ${roleID} ${enable} ${expected_error}=""
+ [Arguments] ${user_name} ${password} ${roleID} ${enable} ${login_user}="" ${login_pasword}="" ${expected_error}=""
# Description of argument(s):
# user_name The user name (e.g. "test", "robert", etc.).
@@ -101,9 +159,13 @@
# expected_error Expected error optionally provided in testcase (e.g. 401 /
# authentication error, etc. )
+ ${user_cmd_args}= Set Variable redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always
${data}= Set Variable '{"UserName":${user_name},"Password":${password},"RoleId":${roleId},"Enabled":${enable}}'
- Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${root_cmd_args}
- ... ${expected_error}
+ Run Keyword If ${login_user} == ""
+ ... Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${root_cmd_args} ${expected_error}
+ ... ELSE
+ ... Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${user_cmd_args} ${expected_error}
+
Redfishtool Update User Role
[Documentation] Update user role.
@@ -118,8 +180,12 @@
# expected_error Expected error optionally provided in testcase (e.g. 401 /
# authentication error, etc. )
- Redfishtool Patch '{"RoleId":${newRole}}' /redfish/v1/AccountService/Accounts/${user_name}
- ... ${root_cmd_args} ${expected_error}
+ ${user_cmd_args}= Set Variable redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always
+ Run Keyword If ${login_user} == ""
+ ... Redfishtool Patch '{"RoleId":${newRole}}' /redfish/v1/AccountService/Accounts/${user_name} ${root_cmd_args} ${expected_error}
+ ... ELSE
+ ... Redfishtool Patch '{"RoleId":${newRole}}' /redfish/v1/AccountService/Accounts/${user_name} ${user_cmd_args} ${expected_error}
+
Redfishtool Delete User
[Documentation] Delete an user.