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 7Test Setup Printn 8 9Test Teardown Test Teardown Execution 10 11*** Variables *** 12 13${invalid_username} user% 14${invalid_password} abc123 15${root_userid} 1 16${operator_level_priv} 0x3 17${user_priv} 2 18${operator_priv} 3 19${admin_level_priv} 4 20${no_access_priv} 15 21${valid_password} 0penBmc1 22${max_password_length} 20 23${ipmi_setaccess_cmd} channel setaccess 24&{password_values} 16=0penBmc10penBmc2 17=0penBmc10penBmc2B 25 ... 20=0penBmc10penBmc2Bmc3 21=0penBmc10penBmc2Bmc34 26 27 28*** Test Cases *** 29 30Verify IPMI User Summary 31 [Documentation] Verify IPMI maximum supported IPMI user ID and 32 ... enabled user form user summary 33 [Tags] Verify_IPMI_User_Summary 34 [Teardown] Run Keywords FFDC On Test Case Fail AND 35 ... Delete Created User ${random_userid} 36 # Delete all non-root IPMI (i.e. except userid 1) 37 Delete All Non Root IPMI User 38 39 ${random_userid} ${random_username}= Create Random IPMI User 40 Set Test Variable ${random_userid} 41 Run IPMI Standard Command user enable ${random_userid} 42 43 # Verify maximum user count IPMI local user can have. Also verify 44 # currently enabled users. 45 ${resp}= Wait Until Keyword Succeeds 15 sec 5 sec Run IPMI Standard Command user summary 46 ${enabled_user_count}= 47 ... Get Lines Containing String ${resp} Enabled User Count 48 ${maximum_ids}= Get Lines Containing String ${resp} Maximum IDs 49 Should Contain ${enabled_user_count} 2 50 Should Contain ${maximum_ids} 15 51 52 53Verify IPMI User Creation With Valid Name And ID 54 [Documentation] Create user via IPMI and verify. 55 [Tags] Test_IPMI_User_Creation_With_Valid_Name_And_ID 56 [Teardown] Run Keywords FFDC On Test Case Fail AND 57 ... Delete Created User ${random_userid} 58 59 ${random_userid} ${random_username}= Create Random IPMI User 60 Set Test Variable ${random_userid} 61 62 63Verify IPMI User Creation With Invalid Name 64 [Documentation] Verify error while creating IPMI user with invalid 65 ... name(e.g. user name with special characters). 66 [Tags] Verify_IPMI_User_Creation_With_Invalid_Name 67 68 ${random_userid}= Evaluate random.randint(2, 15) modules=random 69 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 70 ... user set name ${random_userid} ${invalid_username} 71 Should Contain ${msg} Invalid data 72 73 74Verify IPMI User Creation With Invalid ID 75 [Documentation] Verify error while creating IPMI user with invalid 76 ... ID(i.e. any number greater than 15 or 0). 77 [Tags] Verify_IPMI_User_Creation_With_Invalid_ID 78 79 @{id_list}= Create List 80 ${random_invalid_id}= Evaluate random.randint(16, 1000) modules=random 81 Append To List ${id_list} ${random_invalid_id} 82 Append To List ${id_list} 0 83 84 FOR ${id} IN @{id_list} 85 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 86 ... user set name ${id} newuser 87 Should Contain Any ${msg} User ID is limited to range Parameter out of range 88 END 89 90Verify Setting IPMI User With Invalid Password 91 [Documentation] Verify error while setting IPMI user with invalid 92 ... password. 93 [Tags] Verify_Setting_IPMI_User_With_Invalid_Password 94 [Teardown] Run Keywords FFDC On Test Case Fail AND 95 ... Delete Created User ${random_userid} 96 97 ${random_userid} ${random_username}= Create Random IPMI User 98 Set Test Variable ${random_userid} 99 100 # Set invalid password for newly created user. 101 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 102 ... user set password ${random_userid} ${invalid_password} 103 104 Should Contain ${msg} Set User Password command failed 105 106Verify Setting IPMI Root User With New Name 107 [Documentation] Verify error while setting IPMI root user with new 108 ... name. 109 [Tags] Verify_Setting_IPMI_Root_User_With_New_Name 110 111 # Set invalid password for newly created user. 112 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 113 ... user set name ${root_userid} abcd 114 115 Should Contain ${msg} Set User Name command failed 116 117 118Verify IPMI User Password Via Test Command 119 [Documentation] Verify IPMI user password using test command. 120 [Tags] Verify_IPMI_User_Password_Via_Test_Command 121 [Teardown] Run Keywords FFDC On Test Case Fail AND 122 ... Delete Created User ${random_userid} 123 124 ${random_userid} ${random_username}= Create Random IPMI User 125 Set Test Variable ${random_userid} 126 127 # Set valid password for newly created user. 128 Run IPMI Standard Command 129 ... user set password ${random_userid} ${valid_password} 130 131 # Verify newly set password using test command. 132 ${msg}= Run IPMI Standard Command 133 ... user test ${random_userid} ${max_password_length} ${valid_password} 134 135 Should Contain ${msg} Success 136 137 138Verify Setting Valid Password For IPMI User 139 [Documentation] Set valid password for IPMI user and verify. 140 [Tags] Verify_Setting_Valid_Password_For_IPMI_User 141 [Teardown] Run Keywords FFDC On Test Case Fail AND 142 ... Delete Created User ${random_userid} 143 144 ${random_userid} ${random_username}= Create Random IPMI User 145 Set Test Variable ${random_userid} 146 147 # Set valid password for newly created user. 148 Run IPMI Standard Command 149 ... user set password ${random_userid} ${valid_password} 150 151 Run IPMI Standard Command user enable ${random_userid} 152 153 # Delay added for IPMI user to get enable 154 Sleep 5s 155 156 # Set admin privilege and enable IPMI messaging for newly created user 157 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv} 158 159 Verify IPMI Username And Password ${random_username} ${valid_password} 160 161 162Verify IPMI User Creation With Same Name 163 [Documentation] Verify error while creating two IPMI user with same name. 164 [Tags] Verify_IPMI_User_Creation_With_Same_Name 165 [Teardown] Run Keywords FFDC On Test Case Fail AND 166 ... Delete Created User 2 167 168 ${random_username}= Generate Random String 8 [LETTERS] 169 IPMI Create User 2 ${random_username} 170 171 # Set same username for another IPMI user. 172 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 173 ... user set name 3 ${random_username} 174 Should Contain ${msg} Invalid data field in request 175 176 177Verify Setting IPMI User With Null Password 178 [Documentation] Verify error while setting IPMI user with null 179 ... password. 180 [Tags] Verify_Setting_IPMI_User_With_Null_Password 181 [Teardown] Run Keywords FFDC On Test Case Fail AND 182 ... Delete Created User ${random_userid} 183 184 ${random_userid} ${random_username}= Create Random IPMI User 185 Set Test Variable ${random_userid} 186 187 # Set null password for newly created user. 188 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 189 ... user set password ${random_userid} "" 190 191 Should Contain ${msg} Invalid data field in request 192 193 194Verify IPMI User Deletion 195 [Documentation] Delete user via IPMI and verify. 196 [Tags] Verify_IPMI_User_Deletion 197 [Teardown] Run Keywords FFDC On Test Case Fail AND 198 ... Delete Created User ${random_userid} 199 200 ${random_userid} ${random_username}= Create Random IPMI User 201 Set Test Variable ${random_userid} 202 # Delete IPMI User and verify 203 Run IPMI Standard Command user set name ${random_userid} "" 204 ${user_info}= Get User Info ${random_userid} 205 Should Be Equal ${user_info['user_name']} ${EMPTY} 206 207 208Test IPMI User Privilege Level 209 [Documentation] Verify IPMI user with user privilege can only run user level commands. 210 [Tags] Test_IPMI_User_Privilege_Level 211 [Template] Test IPMI User Privilege 212 [Teardown] Run Keywords FFDC On Test Case Fail AND 213 ... Delete Created User ${random_userid} 214 215 #Privilege level User Cmd Status Operator Cmd Status Admin Cmd Status 216 ${user_priv} Passed Failed Failed 217 218 219Test IPMI Operator Privilege Level 220 [Documentation] Verify IPMI user with operator privilege can only run user and operator levels commands. 221 ... level is set to operator. 222 [Tags] Test_IPMI_Operator_Privilege_Level 223 [Template] Test IPMI User Privilege 224 [Teardown] Run Keywords FFDC On Test Case Fail AND 225 ... Delete Created User ${random_userid} 226 227 #Privilege level User Cmd Status Operator Cmd Status Admin Cmd Status 228 ${operator_priv} Passed Passed Failed 229 230 231Test IPMI Administrator Privilege Level 232 [Documentation] Verify IPMI user with admin privilege can run all levels command. 233 [Tags] Test_IPMI_Administrator_Privilege_Level 234 [Template] Test IPMI User Privilege 235 [Teardown] Run Keywords FFDC On Test Case Fail AND 236 ... Delete Created User ${random_userid} 237 238 #Privilege level User Cmd Status Operator Cmd Status Admin Cmd Status 239 ${admin_level_priv} Passed Passed Passed 240 241 242Test IPMI No Access Privilege Level 243 [Documentation] Verify IPMI user with no access privilege can not run only any level command. 244 [Tags] Test_IPMI_No_Access_Privilege_Level 245 [Template] Test IPMI User Privilege 246 [Teardown] Run Keywords FFDC On Test Case Fail AND 247 ... Delete Created User ${random_userid} 248 249 #Privilege level User Cmd Status Operator Cmd Status Admin Cmd Status 250 ${no_access_priv} Failed Failed Failed 251 252 253Enable IPMI User And Verify 254 [Documentation] Enable IPMI user and verify that the user is able 255 ... to run IPMI command. 256 [Tags] Enable_IPMI_User_And_Verify 257 [Teardown] Run Keywords FFDC On Test Case Fail AND 258 ... Delete Created User ${random_userid} 259 260 ${random_userid} ${random_username}= Create Random IPMI User 261 Set Test Variable ${random_userid} 262 Run IPMI Standard Command 263 ... user set password ${random_userid} ${valid_password} 264 265 # Set admin privilege and enable IPMI messaging for newly created user. 266 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv} 267 268 # Delay added for user privilege to get set. 269 Sleep 5s 270 271 Enable IPMI User And Verify ${random_userid} 272 273 # Verify that enabled IPMI user is able to run IPMI command. 274 Verify IPMI Username And Password ${random_username} ${valid_password} 275 276 277Disable IPMI User And Verify 278 [Documentation] Disable IPMI user and verify that that the user 279 ... is unable to run IPMI command. 280 [Tags] Disable_IPMI_User_And_Verify 281 [Teardown] Run Keywords FFDC On Test Case Fail AND 282 ... Delete Created User ${random_userid} 283 284 ${random_userid} ${random_username}= Create Random IPMI User 285 Set Test Variable ${random_userid} 286 Run IPMI Standard Command 287 ... user set password ${random_userid} ${valid_password} 288 289 # Set admin privilege and enable IPMI messaging for newly created user. 290 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv} 291 292 # Disable IPMI user and verify. 293 Run IPMI Standard Command user disable ${random_userid} 294 ${user_info}= Get User Info ${random_userid} 295 Should Be Equal ${user_info['enable_status']} disabled 296 297 # Verify that disabled IPMI user is unable to run IPMI command. 298 ${msg}= Run Keyword And Expect Error * Verify IPMI Username And Password 299 ... ${random_username} ${valid_password} 300 Should Contain ${msg} Unable to establish IPMI 301 302 303Verify IPMI Root User Password Change 304 [Documentation] Change IPMI root user password and verify that 305 ... root user is able to run IPMI command. 306 [Tags] Verify_IPMI_Root_User_Password_Change 307 [Teardown] Run Keywords FFDC On Test Case Fail AND 308 ... Wait Until Keyword Succeeds 15 sec 5 sec 309 ... Set Default Password For IPMI Root User 310 311 # Set new password for root user. 312 Run IPMI Standard Command 313 ... user set password ${root_userid} ${valid_password} 314 315 # Verify that root user is able to run IPMI command using new password. 316 Wait Until Keyword Succeeds 15 sec 5 sec Verify IPMI Username And Password 317 ... root ${valid_password} 318 319 320Verify Administrator And No Access Privilege For Different Channels 321 [Documentation] Set administrator and no access privilege for different channels and verify. 322 [Tags] Verify_Administrator_And_No_Access_Privilege_For_Different_Channels 323 [Teardown] Run Keywords FFDC On Test Case Fail AND 324 ... Delete Created User ${random_userid} 325 326 ${random_userid} ${random_username}= Create Random IPMI User 327 Set Test Variable ${random_userid} 328 Run IPMI Standard Command 329 ... user set password ${random_userid} ${valid_password} 330 331 # Set admin privilege for newly created user with channel 1. 332 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv} 1 333 334 # Set no access privilege for newly created user with channel 2. 335 Set Channel Access ${random_userid} ipmi=on privilege=${no_access_priv} 2 336 337 Enable IPMI User And Verify ${random_userid} 338 339 # Verify that user is able to run administrator level IPMI command with channel 1. 340 Verify IPMI Command ${random_username} ${valid_password} Administrator 1 341 342 # Verify that user is unable to run IPMI command with channel 2. 343 Run IPMI Standard Command sel info 2 expected_rc=${1} U=${random_username} P=${valid_password} 344 345 346Verify Operator And User Privilege For Different Channels 347 [Documentation] Set operator and user privilege for different channels and verify. 348 [Tags] Verify_Operator_And_User_Privilege_For_Different_Channels 349 [Teardown] Run Keywords FFDC On Test Case Fail AND 350 ... Delete Created User ${random_userid} 351 352 ${random_userid} ${random_username}= Create Random IPMI User 353 Set Test Variable ${random_userid} 354 Run IPMI Standard Command 355 ... user set password ${random_userid} ${valid_password} 356 357 # Set operator privilege for newly created user with channel 1. 358 Set Channel Access ${random_userid} ipmi=on privilege=${operator_priv} 1 359 360 # Set user privilege for newly created user with channel 2. 361 Set Channel Access ${random_userid} ipmi=on privilege=${user_priv} 2 362 363 Enable IPMI User And Verify ${random_userid} 364 365 # Verify that user is able to run operator level IPMI command with channel 1. 366 Verify IPMI Command ${random_username} ${valid_password} Operator 1 367 368 # Verify that user is able to run user level IPMI command with channel 2. 369 Verify IPMI Command ${random_username} ${valid_password} User 2 370 371 372Verify Setting IPMI User With Max Password Length 373 [Documentation] Verify IPMI user creation with password length of 20 characters. 374 [Tags] Verify_Setting_IPMI_User_With_Max_Password_Length 375 [Template] Set User Password And Verify 376 377 # password_length password_option expected_status 378 20 20 ${True} 379 380 381Verify Setting IPMI User With Invalid Password Length 382 [Documentation] Verify that IPMI user cannot be set with 21 character password using 16 char 383 ... or 20 char password option. 384 [Tags] Verify_Setting_IPMI_User_With_Invalid_Password_Length 385 [Template] Set User Password And Verify 386 387 # password_length password_option expected_status 388 21 16 ${False} 389 21 20 ${False} 390 391 392Verify Setting IPMI User With 16 Character Password 393 [Documentation] Verify that IPMI user can create a 16 character password using 16 char or 20 394 ... char password option. 395 [Tags] Verify_Setting_IPMI_User_With_16_Character_Password 396 [Template] Set User Password And Verify 397 398 # password_length password_option expected_status 399 16 16 ${True} 400 16 20 ${True} 401 402 403Verify Default Selection Of 16 Character Password For IPMI User 404 [Documentation] Verify that ipmitool by default opts for the 16 character option when given a 405 ... password whose length is in between 17 and 20. 406 [Tags] Verify_Default_Selection_Of_16_Character_Password_For_IPMI_User 407 [Template] Set User Password And Verify 408 409 # password_length password_option expected_status 410 17 16 ${True} 411 20 16 ${True} 412 413 414*** Keywords *** 415 416Create Random IPMI User 417 [Documentation] Create IPMI user with random username and userid and return those fields. 418 419 ${random_username}= Generate Random String 8 [LETTERS] 420 ${random_userid}= Evaluate random.randint(2, 15) modules=random 421 IPMI Create User ${random_userid} ${random_username} 422 [Return] ${random_userid} ${random_username} 423 424 425Enable IPMI User And Verify 426 [Documentation] Enable the userid and verify that it has been enabled. 427 [Arguments] ${userid} 428 429 # Description of argument(s): 430 # userid A numeric userid (e.g. "4"). 431 432 Run IPMI Standard Command user enable ${userid} 433 ${user_info}= Get User Info ${userid} 434 Valid Value user_info['enable_status'] ['enabled'] 435 436 437Set Default Password For IPMI Root User 438 [Documentation] Set default password for IPMI root user (i.e. 0penBmc). 439 # Set default password for root user. 440 ${result}= Run External IPMI Standard Command 441 ... user set password ${root_userid} ${OPENBMC_PASSWORD} 442 ... P=${valid_password} 443 Should Contain ${result} Set User Password command successful 444 445 # Verify that root user is able to run IPMI command using default password. 446 Verify IPMI Username And Password root ${OPENBMC_PASSWORD} 447 448 449Test IPMI User Privilege 450 [Documentation] Test IPMI user privilege by executing IPMI command with different privileges. 451 [Arguments] ${privilege_level} ${user_cmd_status} ${operator_cmd_status} ${admin_cmd_status} 452 453 # Description of argument(s): 454 # privilege_level Privilege level of IPMI user (e.g. 4, 3). 455 # user_cmd_status Expected status of IPMI command run with the "User" 456 # privilege (i.e. "Passed" or "Failed"). 457 # operator_cmd_status Expected status of IPMI command run with the "Operator" 458 # privilege (i.e. "Passed" or "Failed"). 459 # admin_cmd_status Expected status of IPMI command run with the "Administrator" 460 # privilege (i.e. "Passed" or "Failed"). 461 462 # Create IPMI user and set valid password. 463 ${random_username}= Generate Random String 8 [LETTERS] 464 ${random_userid}= Evaluate random.randint(2, 15) modules=random 465 IPMI Create User ${random_userid} ${random_username} 466 Set Test Variable ${random_userid} 467 Run IPMI Standard Command 468 ... user set password ${random_userid} ${valid_password} 469 470 # Set privilege and enable IPMI messaging for newly created user. 471 Set Channel Access ${random_userid} ipmi=on privilege=${privilege_level} 472 473 # Delay added for user privilege to get set. 474 Sleep 5s 475 476 Enable IPMI User And Verify ${random_userid} 477 478 Verify IPMI Command ${random_username} ${valid_password} User 479 ... expected_status=${user_cmd_status} 480 Verify IPMI Command ${random_username} ${valid_password} Operator 481 ... expected_status=${operator_cmd_status} 482 Verify IPMI Command ${random_username} ${valid_password} Administrator 483 ... expected_status=${admin_cmd_status} 484 485 486Verify IPMI Command 487 [Documentation] Verify IPMI command execution with given username, 488 ... password, privilege and expected status. 489 [Arguments] ${username} ${password} ${privilege} ${channel}=${1} ${expected_status}=Passed 490 # Description of argument(s): 491 # username The user name (e.g. "root", "robert", etc.). 492 # password The user password (e.g. "0penBmc", "0penBmc1", etc.). 493 # privilege The session privilege for IPMI command (e.g. "User", "Operator", etc.). 494 # channel The user channel number (e.g. "1" or "2"). 495 # expected_status Expected status of IPMI command run with the user 496 # of above password and privilege (i.e. "Passed" or "Failed"). 497 498 ${expected_rc}= Set Variable If '${expected_status}' == 'Passed' ${0} ${1} 499 Wait Until Keyword Succeeds 15 sec 5 sec Run IPMI Standard Command 500 ... sel info ${channel} expected_rc=${expected_rc} U=${username} P=${password} 501 ... L=${privilege} 502 503 504Set User Password And Verify 505 [Documentation] Create a user and set its password with given length and option. 506 [Arguments] ${password_length} ${password_option} ${expected_result} 507 [Teardown] Run Keyword Delete Created User ${random_userid} 508 # Description of argument(s): 509 # password_length Length of password to be generated and used (e.g. "16"). 510 # password_option Password length option to be given in IPMI command (e.g. "16", "20"). 511 # expected_result Expected result for setting the user's password (e.g. "True", "False"). 512 513 Rprint Vars password_length password_option expected_result 514 ${random_userid} ${random_username}= Create Random IPMI User 515 Set Test Variable ${random_userid} 516 ${password}= Get From Dictionary ${password_values} ${password_length} 517 Rprint Vars random_userid password 518 519 # Set password for newly created user. 520 ${status}= Run Keyword And Return Status Run IPMI Standard Command 521 ... user set password ${random_userid} ${password} ${password_option} 522 Rprint Vars status 523 Valid Value status [${expected_result}] 524 Return From Keyword If '${expected_result}' == '${False}' 525 526 # Set admin privilege and enable IPMI messaging for newly created user. 527 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv} 528 529 # Delay added for user privilege to get set. 530 Sleep 5s 531 532 Enable IPMI User And Verify ${random_userid} 533 534 # For password_option 16, passwords with length between 17 and 20 will be truncated. 535 # For all other cases, passwords will be retained as it is to verify. 536 ${truncated_password}= Set Variable ${password[:${password_option}]} 537 Rprint Vars truncated_password 538 ${status}= Run Keyword And Return Status Verify IPMI Username And Password ${random_username} 539 ... ${truncated_password} 540 Rprint Vars status 541 Valid Value status [${expected_result}] 542 543 544Test Teardown Execution 545 [Documentation] Do the test teardown execution. 546 547 FFDC On Test Case Fail 548 549 550Delete Created User 551 [Documentation] Delete created IPMI user. 552 [Arguments] ${userid} 553 # Description of argument(s): 554 # userid The user ID (e.g. "1", "2", etc.). 555 556 Run IPMI Standard Command user set name ${userid} "" 557 Sleep 5s