blob: f6bc373736fb5e3aee33228a19f2ea6a9d357b61 [file] [log] [blame]
manashsarma26d0e832020-05-26 05:46:55 -05001*** Settings ***
2
3
4Documentation Suite to test certificate via DMTF redfishtool.
5
6Library OperatingSystem
7Library String
8Library Collections
George Keishingfbd67002022-08-01 11:24:03 -05009Library JSONLibrary
manashsarma26d0e832020-05-26 05:46:55 -050010
11Resource ../../lib/resource.robot
12Resource ../../lib/bmc_redfish_resource.robot
13Resource ../../lib/openbmc_ffdc.robot
14Resource ../../lib/certificate_utils.robot
manashsarma579d8252020-05-28 08:10:51 -050015Resource ../../lib/dmtf_redfishtool_utils.robot
manashsarma26d0e832020-05-26 05:46:55 -050016
17Suite Setup Suite Setup Execution
18
19
20*** Variables ***
21
22${root_cmd_args} = SEPARATOR=
George Keishingd4ba2492022-01-10 08:27:34 -060023... redfishtool raw -r ${OPENBMC_HOST}:${HTTPS_PORT} -u ${OPENBMC_USERNAME} -p ${OPENBMC_PASSWORD} -S Always
manashsarmae12c8472020-07-24 07:15:47 -050024${invalid_value} abc
ganesanb8d31f152023-04-27 14:01:55 +000025${keybit_length} 2048
manashsarma26d0e832020-05-26 05:46:55 -050026
27*** Test Cases ***
28
29
30Verify Redfishtool Replace Server Certificate Valid CertKey
31 [Documentation] Verify replace server certificate.
32 [Tags] Verify_Redfishtool_Replace_Server_Certificate_Valid_CertKey
33
34 Verify Redfishtool Replace Certificate Server Valid Certificate Valid Privatekey ok
35
36
37Verify Redfishtool Replace Client Certificate Valid CertKey
38 [Documentation] Verify replace client certificate.
39 [Tags] Verify_Redfishtool_Replace_Client_Certificate_Valid_CertKey
40
41 Verify Redfishtool Replace Certificate Client Valid Certificate Valid Privatekey ok
42
43
44Verify Redfishtool Replace CA Certificate Valid Cert
45 [Documentation] Verify replace CA certificate.
46 [Tags] Verify_Redfishtool_Replace_CA_Certificate_Valid_Cert
47
48 Verify Redfishtool Replace Certificate CA Valid Certificate ok
49
50
51Verify Redfishtool Client Certificate Install Valid CertKey
52 [Documentation] Verify client certificate installation.
53 [Tags] Verify_Redfishtool_Client_Certificate_Install_Valid_CertKey
54
55 Verify Redfishtool Install Certificate Client Valid Certificate Valid Privatekey ok
56
57
58Verify Redfishtool CA Certificate Install Valid Cert
59 [Documentation] Verify CA Certificate installation.
60 [Tags] Verify_Redfishtool_CA_Certificate_Install_Valid_Cert
61
62 Verify Redfishtool Install Certificate CA Valid Certificate ok
63
64
65Verify Redfishtool Replace Server Certificate Errors
66 [Documentation] Verify error while replacing invalid server certificate.
67 [Tags] Verify_Redfishtool_Replace_Server_Certificate_Errors
68 [Template] Verify Redfishtool Replace Certificate
69
70 Server Empty Certificate Empty Privatekey error
71 Server Empty Certificate Valid Privatekey error
72 Server Valid Certificate Empty Privatekey error
73
74
75Verify Redfishtool Replace Client Certificate Errors
76 [Documentation] Verify error while replacing invalid client certificate.
77 [Tags] Verify_Redfishtool_Replace_Client_Certificate_Errors
78 [Template] Verify Redfishtool Replace Certificate
79
80 Client Empty Certificate Empty Privatekey error
81 Client Empty Certificate Valid Privatekey error
82 Client Valid Certificate Empty Privatekey error
83
84
85Verify Redfishtool Replace CA Certificate Errors
86 [Documentation] Verify error while replacing invalid CA certificate.
87 [Tags] Verify_Redfishtool_Replace_CA_Certificate_Errors
88 [Template] Verify Redfishtool Replace Certificate
89
90 CA Empty Certificate error
91
92
93Verify Redfishtool Client Certificate Install Errors
94 [Documentation] Verify error while installing invalid client certificate.
95 [Tags] Verify_Redfishtool_Client_Certificate_Install_Errors
96 [Template] Verify Redfishtool Install Certificate
97
98 Client Empty Certificate Empty Privatekey error
99 Client Empty Certificate Valid Privatekey error
100 Client Valid Certificate Empty Privatekey error
101
102
manashsarmac0efe582020-06-15 09:51:48 -0500103Verify Redfishtool CA Certificate Install Errors
104 [Documentation] Verify error while installing invalid CA certificate.
105 [Tags] Verify_Redfishtool_CA_Certificate_Install_Errors
106 [Template] Verify Redfishtool Install Certificate
107
108 # cert_type cert_format expected_status
109 CA Empty Certificate error
110
111
George Keishing16b3c7b2021-01-28 09:23:37 -0600112Verify Error While Uploading Same CA Certificate Via Redfishtool
manashsarmac0efe582020-06-15 09:51:48 -0500113 [Documentation] Verify error while uploading same CA certificate two times.
George Keishing16b3c7b2021-01-28 09:23:37 -0600114 [Tags] Verify_Error_While_Uploading_Same_CA_Certificate_Via_Redfishtool
manashsarmac0efe582020-06-15 09:51:48 -0500115
116 # Create certificate file for uploading.
117 ${cert_file_path}= Generate Certificate File Via Openssl Valid Certificate 365
118 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path}
119 ${file_data}= Decode Bytes To String ${bytes} UTF-8
120
121 # Install CA certificate.
122 Redfishtool Install Certificate File On BMC ${REDFISH_CA_CERTIFICATE_URI} ok data=${file_data}
123
124 # Adding delay after certificate installation.
125 Sleep 30s
126
127 # Check error while uploading same certificate.
128 Redfishtool Install Certificate File On BMC ${REDFISH_CA_CERTIFICATE_URI} error data=${file_data}
129
130
131Install Server Certificate Using Redfishtool And Verify Via OpenSSL
132 [Documentation] Install server certificate using Redfishtool and verify via OpenSSL.
George Keishing5236ec52022-01-31 12:07:58 -0600133 [Tags] Install_Server_Certificate_Using_Redfishtool_And_Verify_Via_OpenSSL
manashsarmac0efe582020-06-15 09:51:48 -0500134
135 ${cert_file_path}= Generate Certificate File Via Openssl Valid Certificate Valid Privatekey
136 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path}
137 ${file_data}= Decode Bytes To String ${bytes} UTF-8
138
139 ${certificate_dict}= Create Dictionary
ganesanb4d430282023-04-27 14:33:23 +0000140 ... @odata.id=/redfish/v1/Managers/${MANAGER_ID}/NetworkProtocol/HTTPS/Certificates/1
manashsarmac0efe582020-06-15 09:51:48 -0500141
142 ${dict_objects}= Create Dictionary CertificateString=${file_data}
143 ... CertificateType=PEM CertificateUri=${certificate_dict}
144
145 ${string}= Convert To String ${dict_objects}
146 ${string}= Replace String ${string} ' "
147 ${payload}= Set Variable '${string}'
148
149 ${response}= Redfishtool Post
150 ... ${payload} /redfish/v1/CertificateService/Actions/CertificateService.ReplaceCertificate
ganesanb85c22652023-04-22 16:08:30 +0000151 ... valid_status_codes=${HTTP_OK}, ${HTTP_NO_CONTENT}
manashsarmac0efe582020-06-15 09:51:48 -0500152
153 Wait Until Keyword Succeeds 2 mins 15 secs Verify Certificate Visible Via OpenSSL ${cert_file_path}
154
manashsarmae12c8472020-07-24 07:15:47 -0500155
Tony Lee2843e392020-10-05 16:17:50 +0800156Verify CSR Generation For Server Certificate Via Redfishtool
manashsarmae12c8472020-07-24 07:15:47 -0500157 [Documentation] Verify CSR generation for server certificate.
Tony Lee2843e392020-10-05 16:17:50 +0800158 [Tags] Verify_CSR_Generation_For_Server_Certificate_Via_Redfishtool
manashsarmae12c8472020-07-24 07:15:47 -0500159 [Template] Generate CSR Via Redfishtool
160
161 # csr_type key_pair_algorithm key_bit_length key_curv_id expected_status
ganesanb8d31f152023-04-27 14:01:55 +0000162 Server RSA ${keybit_length} ${EMPTY} ok
163 Server EC ${EMPTY} prime256v1 ok
164 Server EC ${EMPTY} secp521r1 ok
165 Server EC ${EMPTY} secp384r1 ok
manashsarmae12c8472020-07-24 07:15:47 -0500166
167
Tony Lee2843e392020-10-05 16:17:50 +0800168Verify CSR Generation For Client Certificate Via Redfishtool
manashsarmae12c8472020-07-24 07:15:47 -0500169 [Documentation] Verify CSR generation for client certificate.
Tony Lee2843e392020-10-05 16:17:50 +0800170 [Tags] Verify_CSR_Generation_For_Client_Certificate_Via_Redfishtool
manashsarmae12c8472020-07-24 07:15:47 -0500171 [Template] Generate CSR Via Redfishtool
172
173 # csr_type key_pair_algorithm key_bit_length key_curv_id expected_status
ganesanb8d31f152023-04-27 14:01:55 +0000174 Client RSA ${keybit_length} ${EMPTY} ok
175 Client EC ${EMPTY} prime256v1 ok
176 Client EC ${EMPTY} secp521r1 ok
177 Client EC ${EMPTY} secp384r1 ok
manashsarmae12c8472020-07-24 07:15:47 -0500178
179
Tony Lee2843e392020-10-05 16:17:50 +0800180Verify CSR Generation For Server Certificate With Invalid Value Via Redfishtool
manashsarmae12c8472020-07-24 07:15:47 -0500181 [Documentation] Verify error while generating CSR for server certificate with invalid value.
Tony Lee2843e392020-10-05 16:17:50 +0800182 [Tags] Verify_CSR_Generation_For_Server_Certificate_With_Invalid_Value_Via_Redfishtool
manashsarmae12c8472020-07-24 07:15:47 -0500183 [Template] Generate CSR Via Redfishtool
184
185 # csr_type key_pair_algorithm key_bit_length key_curv_id expected_status
ganesanb8d31f152023-04-27 14:01:55 +0000186 Server ${invalid_value} ${keybit_length} prime256v1 error
187 Server RAS ${invalid_value} ${EMPTY} error
manashsarmae12c8472020-07-24 07:15:47 -0500188
189
Tony Lee2843e392020-10-05 16:17:50 +0800190Verify CSR Generation For Client Certificate With Invalid Value Via Redfishtool
manashsarmae12c8472020-07-24 07:15:47 -0500191 [Documentation] Verify error while generating CSR for client certificate with invalid value.
Tony Lee2843e392020-10-05 16:17:50 +0800192 [Tags] Verify_CSR_Generation_For_Client_Certificate_With_Invalid_Value_Via_Redfishtool
manashsarmae12c8472020-07-24 07:15:47 -0500193 [Template] Generate CSR Via Redfishtool
194
ganesanb8d31f152023-04-27 14:01:55 +0000195 Client ${invalid_value} ${keybit_length} prime256v1 error
196 Client RSA ${invalid_value} ${EMPTY} error
manashsarmae12c8472020-07-24 07:15:47 -0500197
manashsarma26d0e832020-05-26 05:46:55 -0500198*** Keywords ***
199
200
manashsarmae12c8472020-07-24 07:15:47 -0500201Generate CSR Via Redfishtool
202 [Documentation] Generate CSR using Redfish.
203 [Arguments] ${cert_type} ${key_pair_algorithm} ${key_bit_length} ${key_curv_id} ${expected_status}
204
205 # Description of argument(s):
206 # cert_type Certificate type ("Server" or "Client").
207 # key_pair_algorithm CSR key pair algorithm ("EC" or "RSA").
208 # key_bit_length CSR key bit length ("2048").
209 # key_curv_id CSR key curv id ("prime256v1" or "secp521r1" or "secp384r1").
210 # expected_status Expected status of certificate replace Redfishtool request ("ok" or "error").
211
212 ${certificate_uri}= Set Variable If
213 ... '${cert_type}' == 'Server' ${REDFISH_HTTPS_CERTIFICATE_URI}/
214 ... '${cert_type}' == 'Client' ${REDFISH_LDAP_CERTIFICATE_URI}/
215
216 ${certificate_dict}= Create Dictionary @odata.id=${certificate_uri}
217
218 ${csr_dict}= Create Dictionary City=Austin CertificateCollection=${certificate_dict}
rramyasr-in8e6ebd22023-02-20 09:44:23 -0600219 ... CommonName=${OPENBMC_HOST} Country=US Organization=xyz
manashsarmae12c8472020-07-24 07:15:47 -0500220 ... OrganizationalUnit=ISL State=AU KeyBitLength=${key_bit_length}
221 ... KeyPairAlgorithm=${key_pair_algorithm} KeyCurveId=${key_curv_id}
222
223 # Remove not applicable field for CSR generation.
224 Run Keyword If '${key_pair_algorithm}' == 'EC' Remove From Dictionary ${csr_dict} KeyBitLength
225 ... ELSE IF '${key_pair_algorithm}' == 'RSA' Remove From Dictionary ${csr_dict} KeyCurveId
226
ganesanb85c22652023-04-22 16:08:30 +0000227 ${expected_resp}= Set Variable If
228 ... '${expected_status}' == 'ok' ${HTTP_OK}, ${HTTP_NO_CONTENT}
manashsarmae12c8472020-07-24 07:15:47 -0500229 ... '${expected_status}' == 'error' ${HTTP_BAD_REQUEST}
230
231 ${string}= Convert To String ${csr_dict}
232
233 ${string2}= Replace String ${string} ' "
234
235 ${payload}= Set Variable '${string2}'
236
237 ${response}= Redfishtool Post
238 ... ${payload} /redfish/v1/CertificateService/Actions/CertificateService.GenerateCSR
239 ... expected_error=${expected_resp}
240
241 # Delay added between two CSR generation request.
242 Sleep 5s
243
244
manashsarma26d0e832020-05-26 05:46:55 -0500245Verify Redfishtool Install Certificate
246 [Documentation] Install and verify certificate using Redfishtool.
247 [Arguments] ${cert_type} ${cert_format} ${expected_status} ${delete_cert}=${True}
ganesanb85c22652023-04-22 16:08:30 +0000248 ... ${install_type}=install
manashsarma26d0e832020-05-26 05:46:55 -0500249
250 # Description of argument(s):
251 # cert_type Certificate type (e.g. "Client" or "CA").
252 # cert_format Certificate file format
253 # expected_status Expected status of certificate install Redfishtool
254 # request (i.e. "ok" or "error").
255 # delete_cert Certificate will be deleted before installing if this True.
256
ganesanb85c22652023-04-22 16:08:30 +0000257 Run Keyword If '${cert_type}' == 'CA'
258 ... Delete All CA Certificate Via Redfishtool ${delete_cert}
259 ... ELSE IF '${cert_type}' == 'Client'
260 ... Redfishtool Delete Certificate Via BMC CLI ${cert_type} ${delete_cert}
261
262 Return From Keyword If "${install_type}" != "install" and "${file_status}" != "Not Found"
manashsarma26d0e832020-05-26 05:46:55 -0500263
264 ${cert_file_path}= Generate Certificate File Via Openssl ${cert_format}
265 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path}
266 ${file_data}= Decode Bytes To String ${bytes} UTF-8
267
268 ${certificate_uri}= Set Variable If
269 ... '${cert_type}' == 'Client' ${REDFISH_LDAP_CERTIFICATE_URI}
270 ... '${cert_type}' == 'CA' ${REDFISH_CA_CERTIFICATE_URI}
271
272 ${cert_id}= Redfishtool Install Certificate File On BMC
273 ... ${certificate_uri} ${expected_status} data=${file_data}
274 Logging Installed certificate id: ${cert_id}
275
276 # Adding delay after certificate installation.
277 Sleep 30s
278
279 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
280
281 ${bmc_cert_content}= Run Keyword If '${expected_status}' == 'ok'
282 ... Redfishtool GetAttribute ${certificate_uri}/${cert_id} CertificateString
283
284 Run Keyword If '${expected_status}' == 'ok' Should Contain ${cert_file_content} ${bmc_cert_content}
285
manashsarma26d0e832020-05-26 05:46:55 -0500286
ganesanb85c22652023-04-22 16:08:30 +0000287Delete All CA Certificate Via Redfishtool
manashsarma26d0e832020-05-26 05:46:55 -0500288 [Documentation] Delete all CA certificate via Redfish.
ganesanb85c22652023-04-22 16:08:30 +0000289 [Arguments] ${delete_cert}=${True}
manashsarma26d0e832020-05-26 05:46:55 -0500290
ganesanb4d430282023-04-27 14:33:23 +0000291 ${cmd_output}= Redfishtool Get /redfish/v1/Managers/${MANAGER_ID}/Truststore/Certificates
George Keishingfbd67002022-08-01 11:24:03 -0500292 ${cmd_output}= Convert String to JSON ${cmd_output}
293 ${cert_list}= Set Variable ${cmd_output["Members"]}
ganesanb85c22652023-04-22 16:08:30 +0000294 ${uri_length}= Get Length ${cert_list}
295 ${file_status}= Set Variable If
296 ... "${uri_length}" == "0" Not Found
297 ... "${uri_length}" != "0" Found
298 ${cert_id}= Set Variable If
299 ... "${uri_length}" != "0" ${cert_list[-1]["@odata.id"].split("/")[-1].strip()}
300 ... "${uri_length}" == "0" None
301 Set Test Variable ${cert_id}
302 Set Test Variable ${file_status}
303 Return From Keyword If "${file_status}" != "Found" or "${delete_cert}" != "${True}"
manashsarma26d0e832020-05-26 05:46:55 -0500304 FOR ${cert} IN @{cert_list}
manashsarma579d8252020-05-28 08:10:51 -0500305 Redfishtool Delete ${cert["@odata.id"]} ${root_cmd_args}
manashsarma26d0e832020-05-26 05:46:55 -0500306 END
307
308
309Redfishtool Delete Certificate Via BMC CLI
310 [Documentation] Delete certificate via BMC CLI.
ganesanb85c22652023-04-22 16:08:30 +0000311 [Arguments] ${cert_type} ${delete_cert}=${True}
manashsarma26d0e832020-05-26 05:46:55 -0500312
313 # Description of argument(s):
314 # cert_type Certificate type (e.g. "Client" or "CA").
315
316 ${certificate_file_path} ${certificate_service} ${certificate_uri}=
317 ... Run Keyword If '${cert_type}' == 'Client'
318 ... Set Variable /etc/nslcd/certs/cert.pem phosphor-certificate-manager@nslcd.service
319 ... ${REDFISH_LDAP_CERTIFICATE_URI}
320 ... ELSE IF '${cert_type}' == 'CA'
321 ... Set Variable ${ROOT_CA_FILE_PATH} phosphor-certificate-manager@authority.service
322 ... ${REDFISH_CA_CERTIFICATE_URI}
323
324 ${file_status} ${stderr} ${rc}= BMC Execute Command
325 ... [ -f ${certificate_file_path} ] && echo "Found" || echo "Not Found"
326
ganesanb85c22652023-04-22 16:08:30 +0000327 Set Test Variable ${file_status}
328 Return From Keyword If "${file_status}" != "Found" or '${delete_cert}' != "${True}"
manashsarma26d0e832020-05-26 05:46:55 -0500329 BMC Execute Command rm ${certificate_file_path}
330 BMC Execute Command systemctl restart ${certificate_service}
331 BMC Execute Command systemctl daemon-reload
332
333
334Redfishtool Install Certificate File On BMC
335 [Documentation] Install certificate file in BMC using POST operation.
336 [Arguments] ${uri} ${status}=ok &{kwargs}
337
338 # Description of argument(s):
339 # uri URI for installing certificate file via Redfishtool.
340 # e.g. "/redfish/v1/AccountService/LDAP/Certificates".
341 # status Expected status of certificate installation via Redfishtool.
342 # e.g. error, ok.
343 # kwargs A dictionary of keys/values to be passed directly to
344 # POST Request.
345
346 Initialize OpenBMC 20 ${quiet}=${1} ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
347
348 ${headers}= Create Dictionary Content-Type=application/octet-stream
349 ... X-Auth-Token=${XAUTH_TOKEN}
350 Set To Dictionary ${kwargs} headers ${headers}
351
George Keishing7ffc3a52022-08-18 04:10:24 -0500352 ${resp}= POST On Session openbmc ${uri} &{kwargs} expected_status=any
ganesanb85c22652023-04-22 16:08:30 +0000353 ${cert_id}= Set Variable If
354 ... '${resp.status_code}' == '${HTTP_OK}' ${resp.json()["Id"]}
355 ... '${resp.status_code}' == '${HTTP_NO_CONTENT}' ${resp.json()["Id"]} -1
manashsarma26d0e832020-05-26 05:46:55 -0500356
357 Run Keyword If '${status}' == 'ok'
ganesanb85c22652023-04-22 16:08:30 +0000358 ... Should Contain Any "${resp.status_code}" ${HTTP_OK} ${HTTP_NO_CONTENT}
manashsarma26d0e832020-05-26 05:46:55 -0500359 ... ELSE IF '${status}' == 'error'
George Keishingfbd67002022-08-01 11:24:03 -0500360 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_INTERNAL_SERVER_ERROR}
manashsarma26d0e832020-05-26 05:46:55 -0500361
362 Delete All Sessions
363
364 [Return] ${cert_id}
365
366
367Verify Redfishtool Replace Certificate
368 [Documentation] Verify replace server certificate.
369 [Arguments] ${cert_type} ${cert_format} ${expected_status}
370
371 # Description of argument(s):
372 # cert_type Certificate type (e.g. "Client", "Server" or "CA").
373 # cert_format Certificate file format
374 # (e.g. "Valid_Certificate_Valid_Privatekey").
375 # expected_status Expected status of certificate replace Redfishtool
376 # request (i.e. "ok" or "error").
377
378 # Install certificate before replacing client or CA certificate.
ganesanb85c22652023-04-22 16:08:30 +0000379 Run Keyword If '${cert_type}' == 'Client'
380 ... Verify Redfishtool Install Certificate ${cert_type} ${cert_format} ${expected_status}
381 ... ${False} replace
manashsarma26d0e832020-05-26 05:46:55 -0500382 ... ELSE IF '${cert_type}' == 'CA'
ganesanb85c22652023-04-22 16:08:30 +0000383 ... Verify Redfishtool Install Certificate ${cert_type} ${cert_format} ${expected_status}
384 ... ${False} replace
manashsarma26d0e832020-05-26 05:46:55 -0500385
386 ${cert_file_path}= Generate Certificate File Via Openssl ${cert_format}
387 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path}
388 ${file_data}= Decode Bytes To String ${bytes} UTF-8
389
390 ${certificate_uri}= Set Variable If
391 ... '${cert_type}' == 'Server' ${REDFISH_HTTPS_CERTIFICATE_URI}/1
392 ... '${cert_type}' == 'Client' ${REDFISH_LDAP_CERTIFICATE_URI}/1
393 ... '${cert_type}' == 'CA' ${REDFISH_CA_CERTIFICATE_URI}/${cert_id}
394
395 ${certificate_dict}= Create Dictionary @odata.id=${certificate_uri}
396 ${dict_objects}= Create Dictionary CertificateString=${file_data}
397 ... CertificateType=PEM CertificateUri=${certificate_dict}
398 ${string}= Convert To String ${dict_objects}
399 ${string}= Replace String ${string} ' "
400 ${payload}= Set Variable '${string}'
401
ganesanb85c22652023-04-22 16:08:30 +0000402 ${expected_resp}= Set Variable If
403 ... '${expected_status}' == 'ok' ${HTTP_OK}, ${HTTP_NO_CONTENT}
404 ... '${expected_status}' == 'error' ${HTTP_BAD_REQUEST}
manashsarma26d0e832020-05-26 05:46:55 -0500405
406 ${response}= Redfishtool Post
Anusha Dathatrif5103462020-06-18 05:40:43 -0500407 ... ${payload} /redfish/v1/CertificateService/Actions/CertificateService.ReplaceCertificate
408 ... expected_error=${expected_resp}
manashsarma26d0e832020-05-26 05:46:55 -0500409
410 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
manashsarma03fcac12023-04-05 01:01:27 -0500411 Sleep 5s
manashsarma26d0e832020-05-26 05:46:55 -0500412 ${bmc_cert_content}= Redfishtool GetAttribute ${certificate_uri} CertificateString
413
414 Run Keyword If '${expected_status}' == 'ok'
415 ... Should Contain ${cert_file_content} ${bmc_cert_content}
416 ... ELSE
417 ... Should Not Contain ${cert_file_content} ${bmc_cert_content}
418
419
manashsarma26d0e832020-05-26 05:46:55 -0500420Redfishtool GetAttribute
421 [Documentation] Execute redfishtool for GET operation.
422 [Arguments] ${uri} ${Attribute} ${cmd_args}=${root_cmd_args} ${expected_error}=""
423
424 # Description of argument(s):
425 # uri URI for GET operation (e.g. /redfish/v1/AccountService/Accounts/).
426 # Attribute The specific attribute to be retrieved with the URI.
427 # cmd_args Commandline arguments.
428 # expected_error Expected error optionally provided in testcase (e.g. 401 /
429 # authentication error, etc. ).
430
431 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} GET ${uri}
432 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
manashsarma26d0e832020-05-26 05:46:55 -0500433
George Keishingfbd67002022-08-01 11:24:03 -0500434 ${cmd_output}= Convert String to JSON ${cmd_output}
435
436 [Return] ${cmd_output["CertificateString"]}
manashsarma26d0e832020-05-26 05:46:55 -0500437
438
manashsarma26d0e832020-05-26 05:46:55 -0500439Suite Setup Execution
440 [Documentation] Do suite setup execution.
441
442 ${tool_exist}= Run which redfishtool
443 Should Not Be Empty ${tool_exist}
444
445 # Create certificate sub-directory in current working directory.
446 Create Directory certificate_dir