Added test to verify setting valid password for IPMI user

Change-Id: I122d39fd30412bc9a82b7400dbdb008ff761e1e5
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/ipmi/test_ipmi_user.robot b/ipmi/test_ipmi_user.robot
index 72590a0..be38bcc 100644
--- a/ipmi/test_ipmi_user.robot
+++ b/ipmi/test_ipmi_user.robot
@@ -14,9 +14,14 @@
 ${invalid_password}     abc123
 ${root_userid}          1
 ${operator_level_priv}  0x3
+${admin_level_priv}     4
 ${valid_password}       0penBmc1
 ${max_password_length}  20
-
+${ipmi_setaccess_cmd}   channel setaccess
+${IPMI_EXT_CMD}         ipmitool -I lanplus -C 3
+${PASSWORD_OPTION}      -P
+${USER_OPTION}          -U
+${SEL_INFO_CMD}         sel info
 
 *** Test Cases ***
 
@@ -105,6 +110,28 @@
     Should Contain  ${msg}  Success
 
 
+Verify Setting Valid Password For IPMI User
+    [Documentation]  Set valid password for IPMI user and verify.
+    [Tags]  Verify_Setting_Valid_Password_For_IPMI_User
+
+    # Create IPMI user.
+    ${random_username}=  Generate Random String  8  [LETTERS]
+    ${random_userid}=  Evaluate  random.randint(2, 15)  modules=random
+    IPMI Create User  ${random_userid}  ${random_username}
+
+    # Set valid password for newly created user.
+    Run IPMI Standard Command
+    ...  user set password ${random_userid} ${valid_password}
+
+    # Enable IPMI user
+    Run IPMI Standard Command  user enable ${random_userid}
+
+    # Set admin privilege and enable IPMI messaging for newly created user
+    Set Channel Access  ${random_userid}  ipmi=on privilege=${admin_level_priv}
+
+    Verify IPMI Username And Password  ${random_username}  ${valid_password}
+
+
 Verify IPMI User Creation With Same Name
     [Documentation]  Verify error while creating two IPMI user with same name.
     [Tags]  Verify_IPMI_User_Creation_With_Same_Name
@@ -165,6 +192,37 @@
     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}
+
+
+Verify IPMI Username And Password
+    [Documentation]  Verify that user is able to run IPMI command
+    ...  with given username and password.
+    [Arguments]  ${username}  ${password}
+
+    ${ipmi_cmd}=  Catenate  SEPARATOR=
+    ...  ${IPMI_EXT_CMD}${SPACE}${USER_OPTION}${SPACE}${username}
+    ...  ${SPACE}${PASSWORD_OPTION}${SPACE}${password}
+    ...  ${SPACE}${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${SEL_INFO_CMD}
+    ${rc}  ${output}=  Run and Return RC and Output  ${ipmi_cmd}
+    Should Be Equal  ${rc}  ${0}  msg=${output}
+    Should Contain  ${output}  SEL Information
+
+
 Delete All Non Root IPMI User
     [Documentation]  Delete all non-root IPMI user.