1*** Settings *** 2Documentation Test suite for OpenBMC IPMI user management. 3 4Resource ../lib/ipmi_client.robot 5Resource ../lib/openbmc_ffdc.robot 6Library ../lib/ipmi_utils.py 7 8Test Teardown Test Teardown Execution 9 10 11*** Variables *** 12 13${invalid_username} user% 14${invalid_password} abc123 15${root_userid} 1 16${operator_level_priv} 0x3 17${admin_level_priv} 4 18${valid_password} 0penBmc1 19${max_password_length} 20 20${ipmi_setaccess_cmd} channel setaccess 21${IPMI_EXT_CMD} ipmitool -I lanplus -C 3 22${PASSWORD_OPTION} -P 23${USER_OPTION} -U 24${SEL_INFO_CMD} sel info 25 26*** Test Cases *** 27 28Verify IPMI User Summary 29 [Documentation] Verify IPMI maximum supported IPMI user ID and 30 ... enabled user form user summary 31 [Tags] Verify_IPMI_User_Summary 32 33 # Delete all non-root IPMI (i.e. except userid 1) 34 Delete All Non Root IPMI User 35 36 # Create a valid user and enable it. 37 ${random_username}= Generate Random String 8 [LETTERS] 38 ${random_userid}= Evaluate random.randint(2, 15) modules=random 39 IPMI Create User ${random_userid} ${random_username} 40 Run IPMI Standard Command user enable ${random_userid} 41 42 # Verify maximum user count IPMI local user can have. Also verify 43 # currently enabled users. 44 ${resp}= Run IPMI Standard Command user summary 45 ${enabled_user_count}= 46 ... Get Lines Containing String ${resp} Enabled User Count 47 ${maximum_ids}= Get Lines Containing String ${resp} Maximum IDs 48 Should Contain ${enabled_user_count} 2 49 Should Contain ${maximum_ids} 15 50 51 52Verify IPMI User Creation With Valid Name And ID 53 [Documentation] Create user via IPMI and verify. 54 [Tags] Test_IPMI_User_Creation_With_Valid_Name_And_ID 55 56 ${random_username}= Generate Random String 8 [LETTERS] 57 ${random_userid}= Evaluate random.randint(2, 15) modules=random 58 IPMI Create User ${random_userid} ${random_username} 59 60 61Verify IPMI User Creation With Invalid Name 62 [Documentation] Verify error while creating IPMI user with invalid 63 ... name(e.g. user name with special characters). 64 [Tags] Verify_IPMI_User_Creation_With_Invalid_Name 65 66 ${random_userid}= Evaluate random.randint(2, 15) modules=random 67 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 68 ... user set name ${random_userid} ${invalid_username} 69 Should Contain ${msg} Invalid data 70 71 72Verify IPMI User Creation With Invalid ID 73 [Documentation] Verify error while creating IPMI user with invalid 74 ... ID(i.e. any number greater than 15 or 0). 75 [Tags] Verify_IPMI_User_Creation_With_Invalid_ID 76 77 @{id_list}= Create List 78 ${random_invalid_id}= Evaluate random.randint(16, 1000) modules=random 79 Append To List ${id_list} ${random_invalid_id} 80 Append To List ${id_list} 0 81 82 :FOR ${id} IN @{id_list} 83 \ ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 84 \ ... user set name ${id} newuser 85 \ Should Contain ${msg} User ID is limited to range 86 87 88Verify Setting IPMI User With Invalid Password 89 [Documentation] Verify error while setting IPMI user with invalid 90 ... password. 91 [Tags] Verify_Setting_IPMI_User_With_Invalid_Password 92 93 # Create IPMI user. 94 ${random_username}= Generate Random String 8 [LETTERS] 95 ${random_userid}= Evaluate random.randint(2, 15) modules=random 96 IPMI Create User ${random_userid} ${random_username} 97 98 # Set invalid password for newly created user. 99 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 100 ... user set password ${random_userid} ${invalid_password} 101 102 Should Contain ${msg} Invalid data field in request 103 104 105Verify Setting IPMI Root User With New Name 106 [Documentation] Verify error while setting IPMI root user with new 107 ... name. 108 [Tags] Verify_Setting_IPMI_Root_User_With_New_Name 109 110 # Set invalid password for newly created user. 111 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 112 ... user set name ${root_userid} abcd 113 114 Should Contain ${msg} Set User Name command failed 115 116 117Verify IPMI User Password Via Test Command 118 [Documentation] Verify IPMI user password using test command. 119 [Tags] Verify_IPMI_User_Password_Via_Test_Command 120 121 # Create IPMI user. 122 ${random_username}= Generate Random String 8 [LETTERS] 123 ${random_userid}= Evaluate random.randint(2, 15) modules=random 124 IPMI Create User ${random_userid} ${random_username} 125 126 # Set valid password for newly created user. 127 Run IPMI Standard Command 128 ... user set password ${random_userid} ${valid_password} 129 130 # Verify newly set password using test command. 131 ${msg}= Run IPMI Standard Command 132 ... user test ${random_userid} ${max_password_length} ${valid_password} 133 134 Should Contain ${msg} Success 135 136 137Verify Setting Valid Password For IPMI User 138 [Documentation] Set valid password for IPMI user and verify. 139 [Tags] Verify_Setting_Valid_Password_For_IPMI_User 140 141 # Create IPMI user. 142 ${random_username}= Generate Random String 8 [LETTERS] 143 ${random_userid}= Evaluate random.randint(2, 15) modules=random 144 IPMI Create User ${random_userid} ${random_username} 145 146 # Set valid password for newly created user. 147 Run IPMI Standard Command 148 ... user set password ${random_userid} ${valid_password} 149 150 # Enable IPMI user 151 Run IPMI Standard Command user enable ${random_userid} 152 153 # Set admin privilege and enable IPMI messaging for newly created user 154 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv} 155 156 Verify IPMI Username And Password ${random_username} ${valid_password} 157 158 159Verify IPMI User Creation With Same Name 160 [Documentation] Verify error while creating two IPMI user with same name. 161 [Tags] Verify_IPMI_User_Creation_With_Same_Name 162 163 ${random_username}= Generate Random String 8 [LETTERS] 164 IPMI Create User 2 ${random_username} 165 166 # Set same username for another IPMI user. 167 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 168 ... user set name 3 ${random_username} 169 Should Contain ${msg} Invalid data field in request 170 171 172Verify Setting IPMI User With Null Password 173 [Documentation] Verify error while setting IPMI user with null 174 ... password. 175 [Tags] Verify_Setting_IPMI_User_With_Null_Password 176 177 # Create IPMI user. 178 ${random_username}= Generate Random String 8 [LETTERS] 179 ${random_userid}= Evaluate random.randint(2, 15) modules=random 180 IPMI Create User ${random_userid} ${random_username} 181 182 # Set null password for newly created user. 183 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 184 ... user set password ${random_userid} "" 185 186 Should Contain ${msg} Invalid data field in request 187 188 189Verify IPMI User Deletion 190 [Documentation] Delete user via IPMI and verify. 191 [Tags] Verify_IPMI_User_Deletion 192 193 ${random_username}= Generate Random String 8 [LETTERS] 194 ${random_userid}= Evaluate random.randint(2, 15) modules=random 195 IPMI Create User ${random_userid} ${random_username} 196 197 # Delete IPMI User and verify 198 Run IPMI Standard Command user set name ${random_userid} "" 199 ${user_info}= Get User Info ${random_userid} 200 Should Be Equal ${user_info['user_name']} ${EMPTY} 201 202 203Enable IPMI User And Verify 204 [Documentation] Enable IPMI user and verify that the user is able 205 ... to run IPMI command. 206 [Tags] Enable_IPMI_User_And_Verify 207 208 # Create IPMI user and set valid password. 209 ${random_username}= Generate Random String 8 [LETTERS] 210 ${random_userid}= Evaluate random.randint(2, 15) modules=random 211 IPMI Create User ${random_userid} ${random_username} 212 Run IPMI Standard Command 213 ... user set password ${random_userid} ${valid_password} 214 215 # Set admin privilege and enable IPMI messaging for newly created user. 216 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv} 217 218 # Enable IPMI user and verify. 219 Run IPMI Standard Command user enable ${random_userid} 220 ${user_info}= Get User Info ${random_userid} 221 Should Be Equal ${user_info['enable_status']} enabled 222 223 # Verify that enabled IPMI user is able to run IPMI command. 224 Verify IPMI Username And Password ${random_username} ${valid_password} 225 226 227Disable IPMI User And Verify 228 [Documentation] Disable IPMI user and verify that that the user 229 ... is unable to run IPMI command. 230 [Tags] Disable_IPMI_User_And_Verify 231 232 # Create IPMI user and set valid password. 233 ${random_username}= Generate Random String 8 [LETTERS] 234 ${random_userid}= Evaluate random.randint(2, 15) modules=random 235 IPMI Create User ${random_userid} ${random_username} 236 Run IPMI Standard Command 237 ... user set password ${random_userid} ${valid_password} 238 239 # Set admin privilege and enable IPMI messaging for newly created user. 240 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv} 241 242 # Disable IPMI user and verify. 243 Run IPMI Standard Command user disable ${random_userid} 244 ${user_info}= Get User Info ${random_userid} 245 Should Be Equal ${user_info['enable_status']} disabled 246 247 # Verify that disabled IPMI user is unable to run IPMI command. 248 ${msg}= Run Keyword And Expect Error * Verify IPMI Username And Password 249 ... ${random_username} ${valid_password} 250 Should Contain ${msg} IPMI command fails 251 252 253*** Keywords *** 254 255IPMI Create User 256 [Documentation] Create IPMI user with given userid and username. 257 [Arguments] ${userid} ${username} 258 259 # Description of argument(s): 260 # userid The user ID (e.g. "1", "2", etc.). 261 # username The user name (e.g. "root", "robert", etc.). 262 263 ${ipmi_cmd}= Catenate user set name ${userid} ${username} 264 ${resp}= Run IPMI Standard Command ${ipmi_cmd} 265 ${user_info}= Get User Info ${userid} 266 Should Be Equal ${user_info['user_name']} ${username} 267 268 269Set Channel Access 270 [Documentation] Verify that user is able to run IPMI command 271 ... with given username and password. 272 [Arguments] ${userid} ${options} ${channel}=1 273 274 # Description of argument(s): 275 # userid The user ID (e.g. "1", "2", etc.). 276 # options Set channel command options (e.g. 277 # "link=on", "ipmi=on", etc.). 278 # channel_number The user's channel number (e.g. "1"). 279 280 ${ipmi_cmd}= Catenate SEPARATOR= 281 ... ${ipmi_setaccess_cmd}${SPACE}${channel}${SPACE}${userid} 282 ... ${SPACE}${options} 283 Run IPMI Standard Command ${ipmi_cmd} 284 285 286Verify IPMI Username And Password 287 [Documentation] Verify that user is able to run IPMI command 288 ... with given username and password. 289 [Arguments] ${username} ${password} 290 291 ${ipmi_cmd}= Catenate SEPARATOR= 292 ... ${IPMI_EXT_CMD}${SPACE}${USER_OPTION}${SPACE}${username} 293 ... ${SPACE}${PASSWORD_OPTION}${SPACE}${password} 294 ... ${SPACE}${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${SEL_INFO_CMD} 295 ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd} 296 Should Be Equal ${rc} ${0} msg=IPMI command fails 297 Should Contain ${output} SEL Information 298 299 300Delete All Non Root IPMI User 301 [Documentation] Delete all non-root IPMI user. 302 303 :FOR ${userid} IN RANGE 2 16 304 \ ${user_info}= Get User Info ${userid} 305 \ Run Keyword If "${user_info['user_name']}" != "" 306 ... Run IPMI Standard Command user set name ${userid} "" 307 308 309Test Teardown Execution 310 [Documentation] Do the test teardown execution. 311 312 FFDC On Test Case Fail 313 Delete All Non Root IPMI User 314 315