Added test cases to verify IPMI user via Redfish
Test cases added:
- Create IPMI user and verify login via Redfish.
- Update user password via IPMI and verify using Redfish.
- Update user privilege via IPMI and verify using Redfish.
- Delete user via IPMI And verify using Redfish.
Change-Id: I29202ee4b66071f0eab0d6bd093fc7e3f38b73de
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
Change-Id: Ie0c222cbdaf093070d307258bc1c5d7f5856a16f
diff --git a/ipmi/test_ipmi_user.robot b/ipmi/test_ipmi_user.robot
index a669b26..d25cd50 100644
--- a/ipmi/test_ipmi_user.robot
+++ b/ipmi/test_ipmi_user.robot
@@ -264,39 +264,8 @@
*** Keywords ***
-IPMI Create User
- [Documentation] Create IPMI user with given userid and username.
- [Arguments] ${userid} ${username}
-
- # Description of argument(s):
- # userid The user ID (e.g. "1", "2", etc.).
- # username The user name (e.g. "root", "robert", etc.).
-
- ${ipmi_cmd}= Catenate user set name ${userid} ${username}
- ${resp}= Run IPMI Standard Command ${ipmi_cmd}
- ${user_info}= Get User Info ${userid}
- Should Be Equal ${user_info['user_name']} ${username}
-
-
-Set Channel Access
- [Documentation] Verify that user is able to run IPMI command
- ... with given username and password.
- [Arguments] ${userid} ${options} ${channel}=1
-
- # Description of argument(s):
- # userid The user ID (e.g. "1", "2", etc.).
- # options Set channel command options (e.g.
- # "link=on", "ipmi=on", etc.).
- # channel_number The user's channel number (e.g. "1").
-
- ${ipmi_cmd}= Catenate SEPARATOR=
- ... ${ipmi_setaccess_cmd}${SPACE}${channel}${SPACE}${userid}
- ... ${SPACE}${options}
- Run IPMI Standard Command ${ipmi_cmd}
-
Set Default Password For IPMI Root User
[Documentation] Set default password for IPMI root user (i.e. 0penBmc).
-
# Set default password for root user.
${result}= Run External IPMI Standard Command
... user set password ${root_userid} ${OPENBMC_PASSWORD}
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index 24ef24c..1033a04 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -373,3 +373,34 @@
${output}= Run External IPMI Standard Command
... sel info U=${username} P=${password}
Should Contain ${output} SEL Information msg=SEL information not present
+
+
+IPMI Create User
+ [Documentation] Create IPMI user with given userid and username.
+ [Arguments] ${userid} ${username}
+
+ # Description of argument(s):
+ # userid The user ID (e.g. "1", "2", etc.).
+ # username The user name (e.g. "root", "robert", etc.).
+
+ ${ipmi_cmd}= Catenate user set name ${userid} ${username}
+ ${resp}= Run IPMI Standard Command ${ipmi_cmd}
+ ${user_info}= Get User Info ${userid}
+ Should Be Equal ${user_info['user_name']} ${username}
+
+
+Set Channel Access
+ [Documentation] Verify that user is able to run IPMI command
+ ... with given username and password.
+ [Arguments] ${userid} ${options} ${channel}=1
+
+ # Description of argument(s):
+ # userid The user ID (e.g. "1", "2", etc.).
+ # options Set channel command options (e.g.
+ # "link=on", "ipmi=on", etc.).
+ # channel_number The user's channel number (e.g. "1").
+
+ ${ipmi_cmd}= Catenate SEPARATOR=
+ ... channel setaccess${SPACE}${channel}${SPACE}${userid}
+ ... ${SPACE}${options}
+ Run IPMI Standard Command ${ipmi_cmd}
diff --git a/redfish/account_service/test_ipmi_redfish_user.robot b/redfish/account_service/test_ipmi_redfish_user.robot
index 12756ae..cdb160c 100644
--- a/redfish/account_service/test_ipmi_redfish_user.robot
+++ b/redfish/account_service/test_ipmi_redfish_user.robot
@@ -5,6 +5,7 @@
Resource ../../lib/bmc_redfish_resource.robot
Resource ../../lib/openbmc_ffdc.robot
Resource ../../lib/ipmi_client.robot
+Library ../lib/ipmi_utils.py
Test Setup Test Setup Execution
Test Teardown Test Teardown Execution
@@ -14,6 +15,8 @@
${valid_password} 0penBmc1
${valid_password2} 0penBmc2
+${admin_level_priv} 4
+${operator_level_priv} 3
** Test Cases **
@@ -80,8 +83,98 @@
... Verify IPMI Username And Password ${random_username} ${valid_password}
+Create IPMI User And Verify Login Via Redfish
+ [Documentation] Create user using IPMI and verify user login via Redfish.
+ [Tags] Create_IPMI_User_And_Verify_Login_Via_Redfish
+
+ ${username} ${userid}= IPMI Create Random User Plus Password And Privilege
+ ... ${valid_password} ${admin_level_priv}
+
+ # Verify user login using Redfish.
+ Redfish.Login ${username} ${valid_password}
+
+
+Update User Password Via IPMI And Verify Using Redfish
+ [Documentation] Update user password using IPMI and verify user
+ ... login via Redfish.
+ [Tags] Update_User_Password_Via_IPMI_And_Verify_Using_Redfish
+
+ ${username} ${userid}= IPMI Create Random User Plus Password And Privilege
+ ... ${valid_password} ${admin_level_priv}
+
+ # Update user password using IPMI.
+ Run IPMI Standard Command
+ ... user set password ${userid} ${valid_password2}
+
+ # Verify that user login works with new password using Redfish.
+ Redfish.Login ${username} ${valid_password2}
+
+
+Update User Privilege Via IPMI And Verify Using Redfish
+ [Documentation] Update user privilege via IPMI and verify using Redfish.
+ [Tags] Update_User_Privilege_Via_IPMI_And_Verify_Using_Redfish
+
+ # Create user using IPMI with admin privilege.
+ ${username} ${userid}= IPMI Create Random User Plus Password And Privilege
+ ... ${valid_password} ${admin_level_priv}
+
+ # Change user privilege to opetrator using IPMI.
+ Run IPMI Standard Command
+ ... user priv ${userid} ${operator_level_priv}
+
+ # Verify new user privilege level via Redfish.
+ ${privilege}= Redfish_Utils.Get Attribute
+ ... /redfish/v1/AccountService/Accounts/${username} RoleId
+ Should Be Equal ${privilege} Operator
+
+
+Delete User Via IPMI And Verify Using Redfish
+ [Documentation] Delete user using IPMI and verify error while doing
+ ... user login with deleted user via Redfish.
+ [Tags] Delete_User_Via_IPMI_And_Verify_Using_Redfish
+
+ ${username} ${userid}= IPMI Create Random User Plus Password And Privilege
+ ... ${valid_password} ${admin_level_priv}
+
+ # Delete IPMI User.
+ Run IPMI Standard Command user set name ${userid} ""
+
+ # Verify that Redfish login fails with deleted user.
+ Run Keyword And Expect Error *InvalidCredentialsError*
+ ... Redfish.Login ${username} ${valid_password}
+
+
*** Keywords ***
+IPMI Create Random User Plus Password And Privilege
+ [Documentation] Create random IPMI user with given password and privilege
+ ... level.
+ [Arguments] ${password} ${privilege}
+
+ # Description of argument(s):
+ # password Password to be assigned for the user.
+ # privilege Privilege level for the user (e.g. "1", "2", "3", etc.).
+
+ # Create IPMI user.
+ ${random_username}= Generate Random String 8 [LETTERS]
+ Set Suite Variable ${random_username}
+
+ ${random_userid}= Evaluate random.randint(2, 15) modules=random
+ IPMI Create User ${random_userid} ${random_username}
+
+ # Set given password for newly created user.
+ Run IPMI Standard Command
+ ... user set password ${random_userid} ${password}
+
+ # Enable IPMI user.
+ Run IPMI Standard Command user enable ${random_userid}
+
+ # Set given privilege and enable IPMI messaging for newly created user.
+ Set Channel Access ${random_userid} ipmi=on privilege=${privilege}
+
+ [Return] ${random_username} ${random_userid}
+
+
Test Setup Execution
[Documentation] Do test case setup tasks.