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 18 19*** Test Cases *** 20 21Verify IPMI User Creation With Valid Name And ID 22 [Documentation] Create user via IPMI and verify. 23 [Tags] Test_IPMI_User_Creation_With_Valid_Name_And_ID 24 25 ${random_username}= Generate Random String 8 [LETTERS] 26 ${random_userid}= Evaluate random.randint(1, 15) modules=random 27 IPMI Create User ${random_userid} ${random_username} 28 29 30Verify IPMI User Creation With Invalid Name 31 [Documentation] Verify error while creating IPMI user with invalid 32 ... name(e.g. user name with special characters). 33 [Tags] Verify_IPMI_User_Creation_With_Invalid_Name 34 35 ${random_userid}= Evaluate random.randint(1, 15) modules=random 36 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 37 ... user set name ${random_userid} ${invalid_username} 38 Should Contain ${msg} Invalid data 39 40 41Verify IPMI User Creation With Invalid ID 42 [Documentation] Verify error while creating IPMI user with invalid 43 ... ID(i.e. any number greater than 15 or 0). 44 [Tags] Verify_IPMI_User_Creation_With_Invalid_ID 45 46 @{id_list}= Create List 47 ${random_invalid_id}= Evaluate random.randint(16, 1000) modules=random 48 Append To List ${id_list} ${random_invalid_id} 49 Append To List ${id_list} 0 50 51 :FOR ${id} IN @{id_list} 52 \ ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 53 \ ... user set name ${id} newuser 54 \ Should Contain ${msg} User ID is limited to range 55 56 57Verify Setting IPMI User With Invalid Password 58 [Documentation] Verify error while setting IPMI user with invalid 59 ... password. 60 [Tags] Verify_Setting_IPMI_User_With_Invalid_Password 61 62 # Create IPMI user. 63 ${random_username}= Generate Random String 8 [LETTERS] 64 ${random_userid}= Evaluate random.randint(1, 15) modules=random 65 IPMI Create User ${random_userid} ${random_username} 66 67 # Set invalid password for newly created user. 68 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 69 ... user set password ${random_userid} ${invalid_password} 70 71 Should Contain ${msg} Invalid data field in request 72 73 74Verify Setting IPMI Root User With New Name 75 [Documentation] Verify error while setting IPMI root user with new 76 ... name. 77 [Tags] Verify_Setting_IPMI_Root_User_With_New_Name 78 79 # Set invalid password for newly created user. 80 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 81 ... user set name ${root_userid} abcd 82 83 Should Contain ${msg} Set User Name command failed 84 85 86Verify IPMI User Creation With Same Name 87 [Documentation] Verify error while creating two IPMI user with same name. 88 [Tags] Verify_IPMI_User_Creation_With_Same_Name 89 90 ${random_username}= Generate Random String 8 [LETTERS] 91 IPMI Create User 2 ${random_username} 92 93 # Set same username for another IPMI user. 94 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 95 ... user set name 3 ${random_username} 96 Should Contain ${msg} Invalid data field in request 97 98 99Verify Setting IPMI User With Null Password 100 [Documentation] Verify error while setting IPMI user with null 101 ... password. 102 [Tags] Verify_Setting_IPMI_User_With_Null_Password 103 104 # Create IPMI user. 105 ${random_username}= Generate Random String 8 [LETTERS] 106 ${random_userid}= Evaluate random.randint(1, 15) modules=random 107 IPMI Create User ${random_userid} ${random_username} 108 109 # Set null password for newly created user. 110 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command 111 ... user set password ${random_userid} "" 112 113 Should Contain ${msg} Invalid data field in request 114 115 116Verify IPMI User Deletion 117 [Documentation] Delete user via IPMI and verify. 118 [Tags] Verify_IPMI_User_Deletion 119 120 ${random_username}= Generate Random String 8 [LETTERS] 121 ${random_userid}= Evaluate random.randint(2, 15) modules=random 122 IPMI Create User ${random_userid} ${random_username} 123 124 # Delete IPMI User and verify 125 Run IPMI Standard Command user set name ${random_userid} "" 126 Should Be Equal ${user_info['user_name']} ${EMPTY} 127 128 129*** Keywords *** 130 131IPMI Create User 132 [Documentation] Create IPMI user with given userid and username. 133 [Arguments] ${userid} ${username} 134 135 # Description of argument(s): 136 # userid The user ID (e.g. "1", "2", etc.). 137 # username The user name (e.g. "root", "robert", etc.). 138 139 ${ipmi_cmd}= Catenate user set name ${userid} ${username} 140 ${resp}= Run IPMI Standard Command ${ipmi_cmd} 141 ${user_info}= Get User Info ${userid} 142 Should Be Equal ${user_info['user_name']} ${username} 143 144 145Delete All Non Root IPMI User 146 [Documentation] Delete all non-root IPMI user. 147 148 :FOR ${userid} IN RANGE 2 16 149 \ ${user_info}= Get User Info ${userid} 150 \ Run Keyword If "${user_info['user_name']}" != "" 151 ... Run IPMI Standard Command user set name ${userid} "" 152 153 154Test Teardown Execution 155 [Documentation] Do the test teardown execution. 156 157 FFDC On Test Case Fail 158 Delete All Non Root IPMI User 159 160