blob: be38bcccf9f0e3cf0b63fc76f3b2ab739ae3de27 [file] [log] [blame]
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -06001*** 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
Rahul Maheshwarif646baa2019-02-20 12:29:35 -06008Test Teardown Test Teardown Execution
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -06009
10
11*** Variables ***
12
13${invalid_username} user%
14${invalid_password} abc123
15${root_userid} 1
16${operator_level_priv} 0x3
Rahul Maheshwarief0a7352019-02-20 11:07:48 -060017${admin_level_priv} 4
Rahul Maheshwaric19f8382019-02-20 08:19:22 -060018${valid_password} 0penBmc1
19${max_password_length} 20
Rahul Maheshwarief0a7352019-02-20 11:07:48 -060020${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
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060025
26*** Test Cases ***
27
28Verify IPMI User Creation With Valid Name And ID
29 [Documentation] Create user via IPMI and verify.
30 [Tags] Test_IPMI_User_Creation_With_Valid_Name_And_ID
31
32 ${random_username}= Generate Random String 8 [LETTERS]
Rahul Maheshwari976a1702019-02-21 01:47:58 -060033 ${random_userid}= Evaluate random.randint(2, 15) modules=random
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060034 IPMI Create User ${random_userid} ${random_username}
35
36
37Verify IPMI User Creation With Invalid Name
38 [Documentation] Verify error while creating IPMI user with invalid
George Keishingc2a6f092019-02-20 12:26:54 -060039 ... name(e.g. user name with special characters).
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060040 [Tags] Verify_IPMI_User_Creation_With_Invalid_Name
41
Rahul Maheshwari976a1702019-02-21 01:47:58 -060042 ${random_userid}= Evaluate random.randint(2, 15) modules=random
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060043 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
44 ... user set name ${random_userid} ${invalid_username}
45 Should Contain ${msg} Invalid data
46
47
48Verify IPMI User Creation With Invalid ID
49 [Documentation] Verify error while creating IPMI user with invalid
50 ... ID(i.e. any number greater than 15 or 0).
51 [Tags] Verify_IPMI_User_Creation_With_Invalid_ID
52
53 @{id_list}= Create List
54 ${random_invalid_id}= Evaluate random.randint(16, 1000) modules=random
55 Append To List ${id_list} ${random_invalid_id}
56 Append To List ${id_list} 0
57
58 :FOR ${id} IN @{id_list}
59 \ ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
60 \ ... user set name ${id} newuser
61 \ Should Contain ${msg} User ID is limited to range
62
63
64Verify Setting IPMI User With Invalid Password
65 [Documentation] Verify error while setting IPMI user with invalid
66 ... password.
67 [Tags] Verify_Setting_IPMI_User_With_Invalid_Password
68
69 # Create IPMI user.
70 ${random_username}= Generate Random String 8 [LETTERS]
Rahul Maheshwari976a1702019-02-21 01:47:58 -060071 ${random_userid}= Evaluate random.randint(2, 15) modules=random
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -060072 IPMI Create User ${random_userid} ${random_username}
73
74 # Set invalid password for newly created user.
75 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
76 ... user set password ${random_userid} ${invalid_password}
77
78 Should Contain ${msg} Invalid data field in request
79
80
81Verify Setting IPMI Root User With New Name
82 [Documentation] Verify error while setting IPMI root user with new
83 ... name.
84 [Tags] Verify_Setting_IPMI_Root_User_With_New_Name
85
86 # Set invalid password for newly created user.
87 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
88 ... user set name ${root_userid} abcd
89
90 Should Contain ${msg} Set User Name command failed
91
92
Rahul Maheshwaric19f8382019-02-20 08:19:22 -060093Verify IPMI User Password Via Test Command
94 [Documentation] Verify IPMI user password using test command.
95 [Tags] Verify_IPMI_User_Password_Via_Test_Command
96
97 # Create IPMI user.
98 ${random_username}= Generate Random String 8 [LETTERS]
99 ${random_userid}= Evaluate random.randint(2, 15) modules=random
100 IPMI Create User ${random_userid} ${random_username}
101
102 # Set valid password for newly created user.
103 Run IPMI Standard Command
104 ... user set password ${random_userid} ${valid_password}
105
106 # Verify newly set password using test command.
107 ${msg}= Run IPMI Standard Command
108 ... user test ${random_userid} ${max_password_length} ${valid_password}
109
110 Should Contain ${msg} Success
111
112
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600113Verify Setting Valid Password For IPMI User
114 [Documentation] Set valid password for IPMI user and verify.
115 [Tags] Verify_Setting_Valid_Password_For_IPMI_User
116
117 # Create IPMI user.
118 ${random_username}= Generate Random String 8 [LETTERS]
119 ${random_userid}= Evaluate random.randint(2, 15) modules=random
120 IPMI Create User ${random_userid} ${random_username}
121
122 # Set valid password for newly created user.
123 Run IPMI Standard Command
124 ... user set password ${random_userid} ${valid_password}
125
126 # Enable IPMI user
127 Run IPMI Standard Command user enable ${random_userid}
128
129 # Set admin privilege and enable IPMI messaging for newly created user
130 Set Channel Access ${random_userid} ipmi=on privilege=${admin_level_priv}
131
132 Verify IPMI Username And Password ${random_username} ${valid_password}
133
134
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600135Verify IPMI User Creation With Same Name
136 [Documentation] Verify error while creating two IPMI user with same name.
137 [Tags] Verify_IPMI_User_Creation_With_Same_Name
138
139 ${random_username}= Generate Random String 8 [LETTERS]
140 IPMI Create User 2 ${random_username}
141
142 # Set same username for another IPMI user.
143 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
144 ... user set name 3 ${random_username}
145 Should Contain ${msg} Invalid data field in request
146
147
148Verify Setting IPMI User With Null Password
149 [Documentation] Verify error while setting IPMI user with null
150 ... password.
151 [Tags] Verify_Setting_IPMI_User_With_Null_Password
152
153 # Create IPMI user.
154 ${random_username}= Generate Random String 8 [LETTERS]
Rahul Maheshwari976a1702019-02-21 01:47:58 -0600155 ${random_userid}= Evaluate random.randint(2, 15) modules=random
Rahul Maheshwari404da0d2019-02-18 23:24:17 -0600156 IPMI Create User ${random_userid} ${random_username}
157
158 # Set null password for newly created user.
159 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
160 ... user set password ${random_userid} ""
161
162 Should Contain ${msg} Invalid data field in request
163
164
Rahul Maheshwari645a1132019-02-18 03:29:27 -0600165Verify IPMI User Deletion
166 [Documentation] Delete user via IPMI and verify.
167 [Tags] Verify_IPMI_User_Deletion
168
169 ${random_username}= Generate Random String 8 [LETTERS]
170 ${random_userid}= Evaluate random.randint(2, 15) modules=random
171 IPMI Create User ${random_userid} ${random_username}
172
173 # Delete IPMI User and verify
174 Run IPMI Standard Command user set name ${random_userid} ""
175 Should Be Equal ${user_info['user_name']} ${EMPTY}
176
177
Rahul Maheshwaric19f8382019-02-20 08:19:22 -0600178
Rahul Maheshwariddfc0cb2019-02-07 23:43:19 -0600179*** Keywords ***
180
181IPMI Create User
182 [Documentation] Create IPMI user with given userid and username.
183 [Arguments] ${userid} ${username}
184
185 # Description of argument(s):
186 # userid The user ID (e.g. "1", "2", etc.).
187 # username The user name (e.g. "root", "robert", etc.).
188
189 ${ipmi_cmd}= Catenate user set name ${userid} ${username}
190 ${resp}= Run IPMI Standard Command ${ipmi_cmd}
191 ${user_info}= Get User Info ${userid}
192 Should Be Equal ${user_info['user_name']} ${username}
193
Rahul Maheshwarif646baa2019-02-20 12:29:35 -0600194
Rahul Maheshwarief0a7352019-02-20 11:07:48 -0600195Set Channel Access
196 [Documentation] Verify that user is able to run IPMI command
197 ... with given username and password.
198 [Arguments] ${userid} ${options} ${channel}=1
199
200 # Description of argument(s):
201 # userid The user ID (e.g. "1", "2", etc.).
202 # options Set channel command options (e.g.
203 # "link=on", "ipmi=on", etc.).
204 # channel_number The user's channel number (e.g. "1").
205
206 ${ipmi_cmd}= Catenate SEPARATOR=
207 ... ${ipmi_setaccess_cmd}${SPACE}${channel}${SPACE}${userid}
208 ... ${SPACE}${options}
209 Run IPMI Standard Command ${ipmi_cmd}
210
211
212Verify IPMI Username And Password
213 [Documentation] Verify that user is able to run IPMI command
214 ... with given username and password.
215 [Arguments] ${username} ${password}
216
217 ${ipmi_cmd}= Catenate SEPARATOR=
218 ... ${IPMI_EXT_CMD}${SPACE}${USER_OPTION}${SPACE}${username}
219 ... ${SPACE}${PASSWORD_OPTION}${SPACE}${password}
220 ... ${SPACE}${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${SEL_INFO_CMD}
221 ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd}
222 Should Be Equal ${rc} ${0} msg=${output}
223 Should Contain ${output} SEL Information
224
225
Rahul Maheshwarif646baa2019-02-20 12:29:35 -0600226Delete All Non Root IPMI User
227 [Documentation] Delete all non-root IPMI user.
228
229 :FOR ${userid} IN RANGE 2 16
230 \ ${user_info}= Get User Info ${userid}
231 \ Run Keyword If "${user_info['user_name']}" != ""
232 ... Run IPMI Standard Command user set name ${userid} ""
233
234
235Test Teardown Execution
236 [Documentation] Do the test teardown execution.
237
238 FFDC On Test Case Fail
239 Delete All Non Root IPMI User
240