blob: 25f2a986349f38c972a7d1fbe5208247dc097192 [file] [log] [blame]
manashsarma8b5d6802020-03-09 04:09:15 -05001*** Settings ***
manashsarma91abf372020-03-17 20:34:02 -05002
3
manashsarma40b85d12020-04-04 21:18:59 -05004Documentation Verify Redfish tool functionality.
manashsarma8b5d6802020-03-09 04:09:15 -05005
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
manashsarma40b85d12020-04-04 21:18:59 -050013Resource ../../lib/certificate_utils.robot
manashsarma8b5d6802020-03-09 04:09:15 -050014
manashsarma91abf372020-03-17 20:34:02 -050015
16Suite Setup Suite Setup Execution
17
manashsarma8b5d6802020-03-09 04:09:15 -050018
19*** Variables ***
20
manashsarma91abf372020-03-17 20:34:02 -050021
manashsarma40b85d12020-04-04 21:18:59 -050022${root_cmd_args} = SEPARATOR=
23... redfishtool raw -r ${OPENBMC_HOST} -u ${OPENBMC_USERNAME} -p ${OPENBMC_PASSWORD} -S Always
manashsarma91abf372020-03-17 20:34:02 -050024${min_number_sensors} ${15}
manashsarmaea14dae2020-03-26 11:00:27 -050025${min_number_roles} ${4}
26${min_number_users} ${1}
manashsarma8b5d6802020-03-09 04:09:15 -050027
manashsarma0b4b9e52020-05-19 12:13:38 -050028
manashsarma8b5d6802020-03-09 04:09:15 -050029*** Test Cases ***
30
manashsarma91abf372020-03-17 20:34:02 -050031
manashsarma8b5d6802020-03-09 04:09:15 -050032Verify Redfishtool Sensor Commands
33 [Documentation] Verify redfishtool's sensor commands.
34 [Tags] Verify_Redfishtool_Sensor_Commands
35
36 ${sensor_status}= Redfishtool Get /redfish/v1/Chassis/chassis/Sensors
37 ${json_object}= Evaluate json.loads('''${sensor_status}''') json
38 Should Be True ${json_object["Members@odata.count"]} > ${min_number_sensors}
39 ... msg=There should be at least ${min_number_sensors} sensors.
40
manashsarma91abf372020-03-17 20:34:02 -050041
manashsarma8b5d6802020-03-09 04:09:15 -050042Verify Redfishtool Health Check Commands
43 [Documentation] Verify redfishtool's health check command.
44 [Tags] Verify_Redfishtool_Health_Check_Commands
45
46 ${chassis_data}= Redfishtool Get /redfish/v1/Chassis/chassis/
47 ${json_object}= Evaluate json.loads('''${chassis_data}''') json
48 ${status}= Set Variable ${json_object["Status"]}
49 Should Be Equal OK ${status["Health"]}
50 ... msg=Health status should be OK.
51
manashsarma91abf372020-03-17 20:34:02 -050052
53Verify Redfishtool Create Users
54 [Documentation] Create user via Redfishtool and verify.
55 [Tags] Verify_Redfishtool_Create_Users
56 [Teardown] Redfishtool Delete User "UserT100"
57
58 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
59 Redfishtool Verify User "UserT100" "Operator"
60
61
62Verify Redfishtool Modify Users
63 [Documentation] Modify user via Redfishtool and verify.
64 [Tags] Verify_Redfishtool_Modify_Users
65 [Teardown] Redfishtool Delete User "UserT100"
66
67 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
68 Redfishtool Update User Role "UserT100" "Administrator"
69 Redfishtool Verify User "UserT100" "Administrator"
70
71
72Verify Redfishtool Delete Users
73 [Documentation] Delete user via Redfishtool and verify.
74 [Tags] Verify_Redfishtool_Delete_Users
75
76 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
77 Redfishtool Delete User "UserT100"
78 ${status}= Redfishtool Verify User Name Exists "UserT100"
79 Should Be True ${status} == False
80
81
manashsarmaea14dae2020-03-26 11:00:27 -050082Verify Redfishtool Login With Deleted Redfish Users
83 [Documentation] Verify login with deleted user via Redfishtool.
84 [Tags] Verify_Redfishtool_Login_With_Deleted_Redfish_Users
85
86 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
87 Redfishtool Delete User "UserT100"
manashsarma40b85d12020-04-04 21:18:59 -050088 Redfishtool Access Resource /redfish/v1/AccountService/Accounts "UserT100" "TestPwd123"
89 ... ${HTTP_UNAUTHORIZED}
90
manashsarmaea14dae2020-03-26 11:00:27 -050091
92Verify Redfishtool Error Upon Creating Same Users With Different Privileges
George Keishinge20f82c2020-05-13 10:51:02 -050093 [Documentation] Verify error upon creating same users with different privileges.
manashsarmaea14dae2020-03-26 11:00:27 -050094 [Tags] Verify_Redfishtool_Error_Upon_Creating_Same_Users_With_Different_Privileges
95 [Teardown] Redfishtool Delete User "UserT100"
96
97 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
manashsarma40b85d12020-04-04 21:18:59 -050098 Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true
99 ... expected_error=${HTTP_BAD_REQUEST}
manashsarmaea14dae2020-03-26 11:00:27 -0500100
101
102Verify Redfishtool Admin User Privilege
George Keishinge20f82c2020-05-13 10:51:02 -0500103 [Documentation] Verify privilege of admin user.
manashsarmaea14dae2020-03-26 11:00:27 -0500104 [Tags] Verify_Redfishtool_Admin_User_Privilege
105 [Teardown] Run Keywords Redfishtool Delete User "UserT100" AND
106 ... Redfishtool Delete User "UserT101"
107
108 Redfishtool Create User "UserT100" "TestPwd123" "Administrator" true
109
110 # Verify if an user can be added by admin
111 Redfishtool Create User "UserT101" "TestPwd123" "Operator" true "UserT100" "TestPwd123"
112
113
114Verify Redfishtool ReadOnly User Privilege
115 [Documentation] Verify Redfishtool ReadOnly user privilege works.
116 [Tags] Verify_Redfishtool_ReadOnly_User_Privilege
117 [Teardown] Redfishtool Delete User "UserT100"
118
119 Redfishtool Create User "UserT100" "TestPwd123" "ReadOnly" true
120 Redfishtool Access Resource /redfish/v1/Systems/ "UserT100" "TestPwd123"
121
122 Redfishtool Create User
123 ... "UserT101" "TestPwd123" "Operator" true "UserT100" "TestPwd123" ${HTTP_FORBIDDEN}
124
125
manashsarma40b85d12020-04-04 21:18:59 -0500126Verify Redfishtool Replace Server Certificate Valid CertKey
127 [Documentation] Verify replace server certificate.
128 [Tags] Verify_Redfishtool_Replace_Server_Certificate_Valid_CertKey
129
130 Verify Redfishtool Replace Certificate Server Valid Certificate Valid Privatekey ok
131
132
133Verify Redfishtool Replace Client Certificate Valid CertKey
134 [Documentation] Verify replace client certificate.
135 [Tags] Verify_Redfishtool_Replace_Client_Certificate_Valid_CertKey
136
137 Verify Redfishtool Replace Certificate Client Valid Certificate Valid Privatekey ok
138
139
140Verify Redfishtool Replace CA Certificate Valid Cert
141 [Documentation] Verify replace CA certificate.
142 [Tags] Verify_Redfishtool_Replace_CA_Certificate_Valid_Cert
143
144 Verify Redfishtool Replace Certificate CA Valid Certificate ok
145
146
147Verify Redfishtool Client Certificate Install Valid CertKey
148 [Documentation] Verify client certificate installation.
149 [Tags] Verify_Redfishtool_Client_Certificate_Install_Valid_CertKey
150
151 Verify Redfishtool Install Certificate Client Valid Certificate Valid Privatekey ok
152
153
154Verify Redfishtool CA Certificate Install Valid Cert
155 [Documentation] Verify CA Certificate installation.
156 [Tags] Verify_Redfishtool_CA_Certificate_Install_Valid_Cert
157
158 Verify Redfishtool Install Certificate CA Valid Certificate ok
159
160
manashsarma0b4b9e52020-05-19 12:13:38 -0500161Verify Redfishtool Replace Server Certificate Errors
162 [Documentation] Verify error while replacing invalid server certificate.
163 [Tags] Verify_Redfishtool_Replace_Server_Certificate_Errors
164 [Template] Verify Redfishtool Replace Certificate
165
166 Server Empty Certificate Empty Privatekey error
167 Server Empty Certificate Valid Privatekey error
168 Server Valid Certificate Empty Privatekey error
169
170
171Verify Redfishtool Replace Client Certificate Errors
172 [Documentation] Verify error while replacing invalid client certificate.
173 [Tags] Verify_Redfishtool_Replace_Client_Certificate_Errors
174 [Template] Verify Redfishtool Replace Certificate
175
176 Client Empty Certificate Empty Privatekey error
177 Client Empty Certificate Valid Privatekey error
178 Client Valid Certificate Empty Privatekey error
179
180Verify Redfishtool Replace CA Certificate Errors
181 [Documentation] Verify error while replacing invalid CA certificate.
182 [Tags] Verify_Redfishtool_Replace_CA_Certificate_Errors
183 [Template] Verify Redfishtool Replace Certificate
184
185 CA Empty Certificate error
186
187Verify Redfishtool Client Certificate Install Errors
188 [Documentation] Verify error while installing invalid client certificate.
189 [Tags] Verify_Redfishtool_Client_Certificate_Install_Errors
190 [Template] Verify Redfishtool Install Certificate
191
192 Client Empty Certificate Empty Privatekey error
193 Client Empty Certificate Valid Privatekey error
194 Client Valid Certificate Empty Privatekey error
195
196
manashsarma8b5d6802020-03-09 04:09:15 -0500197*** Keywords ***
198
manashsarma0b4b9e52020-05-19 12:13:38 -0500199
manashsarmaea14dae2020-03-26 11:00:27 -0500200Redfishtool Access Resource
201 [Documentation] Access resource.
202 [Arguments] ${uri} ${login_user} ${login_pasword} ${expected_error}=""
203
204 # Description of argument(s):
205 # uri URI for resource access.
206 # login_user The login user name used other than default root user.
207 # login_pasword The login password.
208 # expected_error Expected error optionally provided in testcase (e.g. 401 /
209 # authentication error, etc. )
210
211 ${user_cmd_args}= Set Variable
212 ... redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always
213 Redfishtool Get ${uri} ${user_cmd_args} ${expected_error}
214
manashsarma91abf372020-03-17 20:34:02 -0500215
216Is HTTP error Expected
217 [Documentation] Check if the HTTP error is expected.
218 [Arguments] ${cmd_output} ${error_expected}
manashsarma8b5d6802020-03-09 04:09:15 -0500219
220 # Description of argument(s):
manashsarma91abf372020-03-17 20:34:02 -0500221 # cmd_output Output of an HTTP operation.
222 # error_expected Expected error.
manashsarma8b5d6802020-03-09 04:09:15 -0500223
manashsarma0b4b9e52020-05-19 12:13:38 -0500224 @{words} = Split String ${error_expected} ,
225 @{errorString}= Split String ${cmd_output} ${SPACE}
226 Should Contain Any ${errorString} @{words}
manashsarma91abf372020-03-17 20:34:02 -0500227
228
229Redfishtool Create User
230 [Documentation] Create new user.
manashsarma40b85d12020-04-04 21:18:59 -0500231 [Arguments] ${user_name} ${password} ${roleID} ${enable} ${login_user}="" ${login_pasword}=""
232 ... ${expected_error}=""
manashsarma91abf372020-03-17 20:34:02 -0500233
234 # Description of argument(s):
235 # user_name The user name (e.g. "test", "robert", etc.).
236 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
237 # roleID The role of user (e.g. "Administrator", "Operator", etc.).
238 # enable Enabled attribute of (e.g. true or false).
239 # expected_error Expected error optionally provided in testcase (e.g. 401 /
240 # authentication error, etc. )
241
manashsarma40b85d12020-04-04 21:18:59 -0500242 ${user_cmd_args}= Set Variable
243 ... redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always
244 ${data}= Set Variable
245 ... '{"UserName":${user_name},"Password":${password},"RoleId":${roleId},"Enabled":${enable}}'
manashsarmaea14dae2020-03-26 11:00:27 -0500246 Run Keyword If ${login_user} == ""
247 ... Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${root_cmd_args} ${expected_error}
248 ... ELSE
249 ... Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${user_cmd_args} ${expected_error}
250
manashsarma91abf372020-03-17 20:34:02 -0500251
252Redfishtool Update User Role
253 [Documentation] Update user role.
254 [Arguments] ${user_name} ${newRole} ${login_user}="" ${login_pasword}=""
255 ... ${expected_error}=""
256
257 # Description of argument(s):
258 # user_name The user name (e.g. "test", "robert", etc.).
259 # newRole The new role of user (e.g. "Administrator", "Operator", etc.).
260 # login_user The login user name used other than default root user.
261 # login_pasword The login password.
262 # expected_error Expected error optionally provided in testcase (e.g. 401 /
263 # authentication error, etc. )
264
manashsarma40b85d12020-04-04 21:18:59 -0500265 ${user_cmd_args}= Set Variable
266 ... redfishtool raw -r ${OPENBMC_HOST} -u ${login_user} -p ${login_pasword} -S Always
manashsarmaea14dae2020-03-26 11:00:27 -0500267 Run Keyword If ${login_user} == ""
manashsarma40b85d12020-04-04 21:18:59 -0500268 ... Redfishtool Patch '{"RoleId":${newRole}}'
269 ... /redfish/v1/AccountService/Accounts/${user_name} ${root_cmd_args} ${expected_error}
manashsarmaea14dae2020-03-26 11:00:27 -0500270 ... ELSE
manashsarma40b85d12020-04-04 21:18:59 -0500271 ... Redfishtool Patch '{"RoleId":${newRole}}'
272 ... /redfish/v1/AccountService/Accounts/${user_name} ${user_cmd_args} ${expected_error}
manashsarmaea14dae2020-03-26 11:00:27 -0500273
manashsarma91abf372020-03-17 20:34:02 -0500274
275Redfishtool Delete User
276 [Documentation] Delete an user.
277 [Arguments] ${user_name} ${expected_error}=""
278
279 # Description of argument(s):
280 # user_name The user name (e.g. "test", "robert", etc.).
281 # expected_error Expected error optionally provided in testcase (e.g. 401 /
282 # authentication error, etc. ).
283
284 Redfishtool Delete /redfish/v1/AccountService/Accounts/${user_name}
285 ... ${root_cmd_args} ${expected_error}
286
287
288Redfishtool Verify User
289 [Documentation] Verify role of the user.
290 [Arguments] ${user_name} ${role}
291
292 # Description of argument(s):
293 # user_name The user name (e.g. "test", "robert", etc.).
294 # role The new role of user (e.g. "Administrator", "Operator", etc.).
295
296 ${user_account}= Redfishtool Get /redfish/v1/AccountService/Accounts/${user_name}
297 ${json_obj}= Evaluate json.loads('''${user_account}''') json
298 Should Be equal "${json_obj["RoleId"]}" ${role}
299
300
301Redfishtool Verify User Name Exists
302 [Documentation] Verify user name exists.
303 [Arguments] ${user_name}
304
305 # Description of argument(s):
306 # user_name The user name (e.g. "test", "robert", etc.).
307
308 ${status}= Run Keyword And Return Status redfishtool Get
309 ... /redfish/v1/AccountService/Accounts/${user_name}
manashsarma40b85d12020-04-04 21:18:59 -0500310
manashsarma91abf372020-03-17 20:34:02 -0500311 [return] ${status}
312
313
manashsarma40b85d12020-04-04 21:18:59 -0500314Verify Redfishtool Install Certificate
315 [Documentation] Install and verify certificate using Redfishtool.
316 [Arguments] ${cert_type} ${cert_format} ${expected_status} ${delete_cert}=${True}
317
318 # Description of argument(s):
319 # cert_type Certificate type (e.g. "Client" or "CA").
320 # cert_format Certificate file format
321 # expected_status Expected status of certificate install Redfishtool
322 # request (i.e. "ok" or "error").
323 # delete_cert Certificate will be deleted before installing if this True.
324
325 Run Keyword If '${cert_type}' == 'CA' and '${delete_cert}' == '${True}'
326 ... Delete All CA Certificate Via Redfisthtool
327 ... ELSE IF '${cert_type}' == 'Client' and '${delete_cert}' == '${True}'
328 ... Redfishtool Delete Certificate Via BMC CLI ${cert_type}
329
330 ${cert_file_path}= Generate Certificate File Via Openssl ${cert_format}
331 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path}
332 ${file_data}= Decode Bytes To String ${bytes} UTF-8
333
334 ${certificate_uri}= Set Variable If
335 ... '${cert_type}' == 'Client' ${REDFISH_LDAP_CERTIFICATE_URI}
336 ... '${cert_type}' == 'CA' ${REDFISH_CA_CERTIFICATE_URI}
337
manashsarma0b4b9e52020-05-19 12:13:38 -0500338 ${cert_id}= Redfishtool Install Certificate File On BMC
339 ... ${certificate_uri} ${expected_status} data=${file_data}
manashsarma40b85d12020-04-04 21:18:59 -0500340 Logging Installed certificate id: ${cert_id}
341
342 # Adding delay after certificate installation.
343 Sleep 30s
344
345 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
346
manashsarma0b4b9e52020-05-19 12:13:38 -0500347 ${bmc_cert_content}= Run Keyword If '${expected_status}' == 'ok'
348 ... Redfishtool GetAttribute ${certificate_uri}/${cert_id} CertificateString
manashsarma40b85d12020-04-04 21:18:59 -0500349
350 Run Keyword If '${expected_status}' == 'ok' Should Contain ${cert_file_content} ${bmc_cert_content}
351
352 [Return] ${cert_id}
353
354
355Delete All CA Certificate Via Redfisthtool
356 [Documentation] Delete all CA certificate via Redfish.
357
358 ${cmd_output}= Redfishtool Get /redfish/v1/Managers/bmc/Truststore/Certificates
359 ${json_object}= To JSON ${cmd_output}
360 ${cert_list}= Set Variable ${json_object["Members"]}
361 FOR ${cert} IN @{cert_list}
362 Redfishtool Delete ${cert["@odata.id"]} ${root_cmd_args} ${HTTP_NO_CONTENT}
363 END
364
365
366Redfishtool Delete Certificate Via BMC CLI
367 [Documentation] Delete certificate via BMC CLI.
368 [Arguments] ${cert_type}
369
370 # Description of argument(s):
371 # cert_type Certificate type (e.g. "Client" or "CA").
372
373 ${certificate_file_path} ${certificate_service} ${certificate_uri}=
374 ... Run Keyword If '${cert_type}' == 'Client'
375 ... Set Variable /etc/nslcd/certs/cert.pem phosphor-certificate-manager@nslcd.service
376 ... ${REDFISH_LDAP_CERTIFICATE_URI}
377 ... ELSE IF '${cert_type}' == 'CA'
378 ... Set Variable ${ROOT_CA_FILE_PATH} phosphor-certificate-manager@authority.service
379 ... ${REDFISH_CA_CERTIFICATE_URI}
380
381 ${file_status} ${stderr} ${rc}= BMC Execute Command
382 ... [ -f ${certificate_file_path} ] && echo "Found" || echo "Not Found"
383
384 Return From Keyword If "${file_status}" != "Found"
385 BMC Execute Command rm ${certificate_file_path}
386 BMC Execute Command systemctl restart ${certificate_service}
387 BMC Execute Command systemctl daemon-reload
388
389
390Redfishtool Install Certificate File On BMC
391 [Documentation] Install certificate file in BMC using POST operation.
392 [Arguments] ${uri} ${status}=ok &{kwargs}
393
394 # Description of argument(s):
395 # uri URI for installing certificate file via Redfishtool.
396 # e.g. "/redfish/v1/AccountService/LDAP/Certificates".
397 # status Expected status of certificate installation via Redfishtool.
398 # e.g. error, ok.
399 # kwargs A dictionary of keys/values to be passed directly to
400 # POST Request.
401
402 Initialize OpenBMC 20 ${quiet}=${1} ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
403
404 ${headers}= Create Dictionary Content-Type=application/octet-stream
405 ... X-Auth-Token=${XAUTH_TOKEN}
406 Set To Dictionary ${kwargs} headers ${headers}
407
408 ${ret}= Post Request openbmc ${uri} &{kwargs}
409 ${content_json}= To JSON ${ret.content}
410 ${cert_id}= Set Variable If '${ret.status_code}' == '${HTTP_OK}' ${content_json["Id"]} -1
411
412 Run Keyword If '${status}' == 'ok'
413 ... Should Be Equal As Strings ${ret.status_code} ${HTTP_OK}
414 ... ELSE IF '${status}' == 'error'
415 ... Should Be Equal As Strings ${ret.status_code} ${HTTP_INTERNAL_SERVER_ERROR}
416
417 Delete All Sessions
418
419 [Return] ${cert_id}
420
421
422Verify Redfishtool Replace Certificate
423 [Documentation] Verify replace server certificate.
424 [Arguments] ${cert_type} ${cert_format} ${expected_status}
425
426 # Description of argument(s):
427 # cert_type Certificate type (e.g. "Client", "Server" or "CA").
428 # cert_format Certificate file format
429 # (e.g. "Valid_Certificate_Valid_Privatekey").
430 # expected_status Expected status of certificate replace Redfishtool
431 # request (i.e. "ok" or "error").
432
manashsarma40b85d12020-04-04 21:18:59 -0500433 # Install certificate before replacing client or CA certificate.
434 ${cert_id}= Run Keyword If '${cert_type}' == 'Client'
435 ... Verify Redfishtool Install Certificate ${cert_type} Valid Certificate Valid Privatekey ok
436 ... ELSE IF '${cert_type}' == 'CA'
437 ... Verify Redfishtool Install Certificate ${cert_type} Valid Certificate ok
438
439 ${cert_file_path}= Generate Certificate File Via Openssl ${cert_format}
440 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path}
441 ${file_data}= Decode Bytes To String ${bytes} UTF-8
442
443 ${certificate_uri}= Set Variable If
444 ... '${cert_type}' == 'Server' ${REDFISH_HTTPS_CERTIFICATE_URI}/1
445 ... '${cert_type}' == 'Client' ${REDFISH_LDAP_CERTIFICATE_URI}/1
446 ... '${cert_type}' == 'CA' ${REDFISH_CA_CERTIFICATE_URI}/${cert_id}
447
448 ${certificate_dict}= Create Dictionary @odata.id=${certificate_uri}
449 ${dict_objects}= Create Dictionary CertificateString=${file_data}
450 ... CertificateType=PEM CertificateUri=${certificate_dict}
451 ${string}= Convert To String ${dict_objects}
452 ${string}= Replace String ${string} ' "
453 ${payload}= Set Variable '${string}'
manashsarma0b4b9e52020-05-19 12:13:38 -0500454
455 ${expected_resp}= Set Variable If '${expected_status}' == 'ok' ${HTTP_OK}
456 ... '${expected_status}' == 'error' ${HTTP_NOT_FOUND}
457
manashsarma40b85d12020-04-04 21:18:59 -0500458 ${response}= Redfishtool Post
manashsarma0b4b9e52020-05-19 12:13:38 -0500459 ... ${payload} /redfish/v1/CertificateService/Actions/CertificateService.ReplaceCertificate expected_error=${expected_resp}
manashsarma40b85d12020-04-04 21:18:59 -0500460
461 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
462 ${bmc_cert_content}= Redfishtool GetAttribute ${certificate_uri} CertificateString
463
464 Run Keyword If '${expected_status}' == 'ok'
465 ... Should Contain ${cert_file_content} ${bmc_cert_content}
466 ... ELSE
467 ... Should Not Contain ${cert_file_content} ${bmc_cert_content}
468
469
manashsarma0b4b9e52020-05-19 12:13:38 -0500470Redfishtool Get
471 [Documentation] Execute redfishtool for GET operation.
472 [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
473
474 # Description of argument(s):
475 # uri URI for GET operation (e.g. /redfish/v1/AccountService/Accounts/).
476 # cmd_args Commandline arguments.
477 # expected_error Expected error optionally provided in testcase (e.g. 401 /
478 # authentication error, etc. ).
479
480 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} GET ${uri}
481 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
482
483 [Return] ${cmd_output}
484
485
manashsarma40b85d12020-04-04 21:18:59 -0500486Redfishtool GetAttribute
487 [Documentation] Execute redfishtool for GET operation.
488 [Arguments] ${uri} ${Attribute} ${cmd_args}=${root_cmd_args} ${expected_error}=""
489
490 # Description of argument(s):
491 # uri URI for GET operation (e.g. /redfish/v1/AccountService/Accounts/).
492 # Attribute The specific attribute to be retrieved with the URI.
493 # cmd_args Commandline arguments.
494 # expected_error Expected error optionally provided in testcase (e.g. 401 /
495 # authentication error, etc. ).
496
497 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} GET ${uri}
498 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
499 ${json_object}= To JSON ${cmd_output}
500
501 [Return] ${json_object["CertificateString"]}
502
503
manashsarma91abf372020-03-17 20:34:02 -0500504Redfishtool Post
505 [Documentation] Execute redfishtool for Post operation.
506 [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
507
508 # Description of argument(s):
509 # payload Payload with POST operation (e.g. data for user name, password, role,
510 # enabled attribute)
511 # uri URI for POST operation (e.g. /redfish/v1/AccountService/Accounts/).
512 # cmd_args Commandline arguments.
513 # expected_error Expected error optionally provided in testcase (e.g. 401 /
514 # authentication error, etc. ).
515
516 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} POST ${uri} --data=${payload}
517 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
manashsarma40b85d12020-04-04 21:18:59 -0500518
manashsarma91abf372020-03-17 20:34:02 -0500519 [Return] ${cmd_output}
520
521
522Redfishtool Patch
523 [Documentation] Execute redfishtool for Patch operation.
524 [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
525
526 # Description of argument(s):
527 # payload Payload with POST operation (e.g. data for user name, role, etc. ).
528 # uri URI for PATCH operation (e.g. /redfish/v1/AccountService/Accounts/ ).
529 # cmd_args Commandline arguments.
530 # expected_error Expected error optionally provided in testcase (e.g. 401 /
531 # authentication error, etc. ).
532
533 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} PATCH ${uri} --data=${payload}
534 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
manashsarma40b85d12020-04-04 21:18:59 -0500535
manashsarma91abf372020-03-17 20:34:02 -0500536 [Return] ${cmd_output}
537
538
539Redfishtool Delete
540 [Documentation] Execute redfishtool for Post operation.
541 [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
542
543 # Description of argument(s):
544 # uri URI for DELETE operation.
545 # cmd_args Commandline arguments.
546 # expected_error Expected error optionally provided in testcase (e.g. 401 /
547 # authentication error, etc. ).
548
549 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} DELETE ${uri}
550 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
manashsarma40b85d12020-04-04 21:18:59 -0500551
manashsarma91abf372020-03-17 20:34:02 -0500552 [Return] ${cmd_output}
553
554
manashsarma8b5d6802020-03-09 04:09:15 -0500555Suite Setup Execution
556 [Documentation] Do suite setup execution.
557
558 ${tool_exist}= Run which redfishtool
559 Should Not Be Empty ${tool_exist}
manashsarma0b4b9e52020-05-19 12:13:38 -0500560
561 # Create certificate sub-directory in current working directory.
562 Create Directory certificate_dir