blob: 43f2d7a856a546f739bdda07d6572e1b42ec4411 [file] [log] [blame]
manashsarma8b5d6802020-03-09 04:09:15 -05001*** Settings ***
manashsarma91abf372020-03-17 20:34:02 -05002
3
manashsarma8b5d6802020-03-09 04:09:15 -05004Documentation Verify Redfish tool functionality.
5
manashsarma91abf372020-03-17 20:34:02 -05006Library OperatingSystem
7Library String
8Library Collections
manashsarma8b5d6802020-03-09 04:09:15 -05009
manashsarma91abf372020-03-17 20:34:02 -050010Resource ../../lib/resource.robot
11Resource ../../lib/bmc_redfish_resource.robot
12Resource ../../lib/openbmc_ffdc.robot
manashsarma8b5d6802020-03-09 04:09:15 -050013
manashsarma91abf372020-03-17 20:34:02 -050014
15Suite Setup Suite Setup Execution
16
manashsarma8b5d6802020-03-09 04:09:15 -050017
18*** Variables ***
19
manashsarma91abf372020-03-17 20:34:02 -050020
21${root_cmd_args} redfishtool raw -r ${OPENBMC_HOST} -u ${OPENBMC_USERNAME} -p ${OPENBMC_PASSWORD} -S Always
22${min_number_sensors} ${15}
manashsarmaea14dae2020-03-26 11:00:27 -050023${min_number_roles} ${4}
24${min_number_users} ${1}
manashsarma8b5d6802020-03-09 04:09:15 -050025
26*** Test Cases ***
27
manashsarma91abf372020-03-17 20:34:02 -050028
manashsarma8b5d6802020-03-09 04:09:15 -050029Verify Redfishtool Sensor Commands
30 [Documentation] Verify redfishtool's sensor commands.
31 [Tags] Verify_Redfishtool_Sensor_Commands
32
33 ${sensor_status}= Redfishtool Get /redfish/v1/Chassis/chassis/Sensors
34 ${json_object}= Evaluate json.loads('''${sensor_status}''') json
35 Should Be True ${json_object["Members@odata.count"]} > ${min_number_sensors}
36 ... msg=There should be at least ${min_number_sensors} sensors.
37
manashsarma91abf372020-03-17 20:34:02 -050038
manashsarma8b5d6802020-03-09 04:09:15 -050039Verify Redfishtool Health Check Commands
40 [Documentation] Verify redfishtool's health check command.
41 [Tags] Verify_Redfishtool_Health_Check_Commands
42
43 ${chassis_data}= Redfishtool Get /redfish/v1/Chassis/chassis/
44 ${json_object}= Evaluate json.loads('''${chassis_data}''') json
45 ${status}= Set Variable ${json_object["Status"]}
46 Should Be Equal OK ${status["Health"]}
47 ... msg=Health status should be OK.
48
manashsarma91abf372020-03-17 20:34:02 -050049
50Verify Redfishtool Create Users
51 [Documentation] Create user via Redfishtool and verify.
52 [Tags] Verify_Redfishtool_Create_Users
53 [Teardown] Redfishtool Delete User "UserT100"
54
55 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
56 Redfishtool Verify User "UserT100" "Operator"
57
58
59Verify Redfishtool Modify Users
60 [Documentation] Modify user via Redfishtool and verify.
61 [Tags] Verify_Redfishtool_Modify_Users
62 [Teardown] Redfishtool Delete User "UserT100"
63
64 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
65 Redfishtool Update User Role "UserT100" "Administrator"
66 Redfishtool Verify User "UserT100" "Administrator"
67
68
69Verify Redfishtool Delete Users
70 [Documentation] Delete user via Redfishtool and verify.
71 [Tags] Verify_Redfishtool_Delete_Users
72
73 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
74 Redfishtool Delete User "UserT100"
75 ${status}= Redfishtool Verify User Name Exists "UserT100"
76 Should Be True ${status} == False
77
78
manashsarmaea14dae2020-03-26 11:00:27 -050079Verify Redfishtool Login With Deleted Redfish Users
80 [Documentation] Verify login with deleted user via Redfishtool.
81 [Tags] Verify_Redfishtool_Login_With_Deleted_Redfish_Users
82
83 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
84 Redfishtool Delete User "UserT100"
85 Redfishtool Access Resource /redfish/v1/AccountService/Accounts "UserT100" "TestPwd123" ${HTTP_UNAUTHORIZED}
86
87Verify Redfishtool Error Upon Creating Same Users With Different Privileges
88 [Documentation] Verify error upon creating same users with different previleges.
89 [Tags] Verify_Redfishtool_Error_Upon_Creating_Same_Users_With_Different_Privileges
90 [Teardown] Redfishtool Delete User "UserT100"
91
92 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
93 Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true expected_error=${HTTP_BAD_REQUEST}
94
95
96Verify Redfishtool Admin User Privilege
97 [Documentation] Verify previlege of admin user.
98 [Tags] Verify_Redfishtool_Admin_User_Privilege
99 [Teardown] Run Keywords Redfishtool Delete User "UserT100" AND
100 ... Redfishtool Delete User "UserT101"
101
102 Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true
103
104 # Verify if an user can be added by admin
105 Redfishtool Create User "UserT101" "TestPwd123" "Operator" true "UserT100" "TestPwd123"
106
107
108Verify Redfishtool ReadOnly User Privilege
109 [Documentation] Verify Redfishtool ReadOnly user privilege works.
110 [Tags] Verify_Redfishtool_ReadOnly_User_Privilege
111 [Teardown] Redfishtool Delete User "UserT100"
112
113 Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true
114 Redfishtool Access Resource /redfish/v1/Systems/ "UserT100" "TestPwd123"
115
116 Redfishtool Create User
117 ... "UserT101" "TestPwd123" "Operator" true "UserT100" "TestPwd123" ${HTTP_FORBIDDEN}
118
119
manashsarma8b5d6802020-03-09 04:09:15 -0500120*** Keywords ***
121
manashsarmaea14dae2020-03-26 11:00:27 -0500122Redfishtool Access Resource
123 [Documentation] Access resource.
124 [Arguments] ${uri} ${login_user} ${login_pasword} ${expected_error}=""
125
126 # Description of argument(s):
127 # uri URI for resource access.
128 # login_user The login user name used other than default root user.
129 # login_pasword The login password.
130 # expected_error Expected error optionally provided in testcase (e.g. 401 /
131 # authentication error, etc. )
132
133 ${user_cmd_args}= Set Variable
134 ... redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always
135 Redfishtool Get ${uri} ${user_cmd_args} ${expected_error}
136
manashsarma91abf372020-03-17 20:34:02 -0500137
138Is HTTP error Expected
139 [Documentation] Check if the HTTP error is expected.
140 [Arguments] ${cmd_output} ${error_expected}
manashsarma8b5d6802020-03-09 04:09:15 -0500141
142 # Description of argument(s):
manashsarma91abf372020-03-17 20:34:02 -0500143 # cmd_output Output of an HTTP operation.
144 # error_expected Expected error.
manashsarma8b5d6802020-03-09 04:09:15 -0500145
manashsarma91abf372020-03-17 20:34:02 -0500146 ${error_expected}= Evaluate "${error_expected}" in """${cmd_output}"""
147 Should Be True ${error_expected} == True
148
149
150Redfishtool Create User
151 [Documentation] Create new user.
manashsarmaea14dae2020-03-26 11:00:27 -0500152 [Arguments] ${user_name} ${password} ${roleID} ${enable} ${login_user}="" ${login_pasword}="" ${expected_error}=""
manashsarma91abf372020-03-17 20:34:02 -0500153
154 # Description of argument(s):
155 # user_name The user name (e.g. "test", "robert", etc.).
156 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
157 # roleID The role of user (e.g. "Administrator", "Operator", etc.).
158 # enable Enabled attribute of (e.g. true or false).
159 # expected_error Expected error optionally provided in testcase (e.g. 401 /
160 # authentication error, etc. )
161
manashsarmaea14dae2020-03-26 11:00:27 -0500162 ${user_cmd_args}= Set Variable redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always
manashsarma91abf372020-03-17 20:34:02 -0500163 ${data}= Set Variable '{"UserName":${user_name},"Password":${password},"RoleId":${roleId},"Enabled":${enable}}'
manashsarmaea14dae2020-03-26 11:00:27 -0500164 Run Keyword If ${login_user} == ""
165 ... Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${root_cmd_args} ${expected_error}
166 ... ELSE
167 ... Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${user_cmd_args} ${expected_error}
168
manashsarma91abf372020-03-17 20:34:02 -0500169
170Redfishtool Update User Role
171 [Documentation] Update user role.
172 [Arguments] ${user_name} ${newRole} ${login_user}="" ${login_pasword}=""
173 ... ${expected_error}=""
174
175 # Description of argument(s):
176 # user_name The user name (e.g. "test", "robert", etc.).
177 # newRole The new role of user (e.g. "Administrator", "Operator", etc.).
178 # login_user The login user name used other than default root user.
179 # login_pasword The login password.
180 # expected_error Expected error optionally provided in testcase (e.g. 401 /
181 # authentication error, etc. )
182
manashsarmaea14dae2020-03-26 11:00:27 -0500183 ${user_cmd_args}= Set Variable redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always
184 Run Keyword If ${login_user} == ""
185 ... Redfishtool Patch '{"RoleId":${newRole}}' /redfish/v1/AccountService/Accounts/${user_name} ${root_cmd_args} ${expected_error}
186 ... ELSE
187 ... Redfishtool Patch '{"RoleId":${newRole}}' /redfish/v1/AccountService/Accounts/${user_name} ${user_cmd_args} ${expected_error}
188
manashsarma91abf372020-03-17 20:34:02 -0500189
190Redfishtool Delete User
191 [Documentation] Delete an user.
192 [Arguments] ${user_name} ${expected_error}=""
193
194 # Description of argument(s):
195 # user_name The user name (e.g. "test", "robert", etc.).
196 # expected_error Expected error optionally provided in testcase (e.g. 401 /
197 # authentication error, etc. ).
198
199 Redfishtool Delete /redfish/v1/AccountService/Accounts/${user_name}
200 ... ${root_cmd_args} ${expected_error}
201
202
203Redfishtool Verify User
204 [Documentation] Verify role of the user.
205 [Arguments] ${user_name} ${role}
206
207 # Description of argument(s):
208 # user_name The user name (e.g. "test", "robert", etc.).
209 # role The new role of user (e.g. "Administrator", "Operator", etc.).
210
211 ${user_account}= Redfishtool Get /redfish/v1/AccountService/Accounts/${user_name}
212 ${json_obj}= Evaluate json.loads('''${user_account}''') json
213 Should Be equal "${json_obj["RoleId"]}" ${role}
214
215
216Redfishtool Verify User Name Exists
217 [Documentation] Verify user name exists.
218 [Arguments] ${user_name}
219
220 # Description of argument(s):
221 # user_name The user name (e.g. "test", "robert", etc.).
222
223 ${status}= Run Keyword And Return Status redfishtool Get
224 ... /redfish/v1/AccountService/Accounts/${user_name}
225 [return] ${status}
226
227
228Redfishtool Get
229 [Documentation] Execute redfishtool for GET operation.
230 [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
231
232 # Description of argument(s):
233 # uri URI for GET operation (e.g. /redfish/v1/AccountService/Accounts/).
234 # cmd_args Commandline arguments.
235 # expected_error Expected error optionally provided in testcase (e.g. 401 /
236 # authentication error, etc. ).
237
238 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} GET ${uri}
239 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
manashsarma8b5d6802020-03-09 04:09:15 -0500240 [Return] ${cmd_output}
241
manashsarma91abf372020-03-17 20:34:02 -0500242
243Redfishtool Post
244 [Documentation] Execute redfishtool for Post operation.
245 [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
246
247 # Description of argument(s):
248 # payload Payload with POST operation (e.g. data for user name, password, role,
249 # enabled attribute)
250 # uri URI for POST operation (e.g. /redfish/v1/AccountService/Accounts/).
251 # cmd_args Commandline arguments.
252 # expected_error Expected error optionally provided in testcase (e.g. 401 /
253 # authentication error, etc. ).
254
255 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} POST ${uri} --data=${payload}
256 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
257 [Return] ${cmd_output}
258
259
260Redfishtool Patch
261 [Documentation] Execute redfishtool for Patch operation.
262 [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
263
264 # Description of argument(s):
265 # payload Payload with POST operation (e.g. data for user name, role, etc. ).
266 # uri URI for PATCH operation (e.g. /redfish/v1/AccountService/Accounts/ ).
267 # cmd_args Commandline arguments.
268 # expected_error Expected error optionally provided in testcase (e.g. 401 /
269 # authentication error, etc. ).
270
271 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} PATCH ${uri} --data=${payload}
272 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
273 [Return] ${cmd_output}
274
275
276Redfishtool Delete
277 [Documentation] Execute redfishtool for Post operation.
278 [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
279
280 # Description of argument(s):
281 # uri URI for DELETE operation.
282 # cmd_args Commandline arguments.
283 # expected_error Expected error optionally provided in testcase (e.g. 401 /
284 # authentication error, etc. ).
285
286 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} DELETE ${uri}
287 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
288 [Return] ${cmd_output}
289
290
manashsarma8b5d6802020-03-09 04:09:15 -0500291Suite Setup Execution
292 [Documentation] Do suite setup execution.
293
294 ${tool_exist}= Run which redfishtool
295 Should Not Be Empty ${tool_exist}