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