blob: 05de1d248255821a8ed79a26c96ae7b0645a7ec9 [file] [log] [blame]
manashsarmab7af8172020-07-16 05:05:44 -05001*** Settings ***
2
3Documentation VMI certificate exchange tests.
4
shrsuman1235fc20cb2021-02-02 04:55:47 -06005Library ../../lib/jobs_processing.py
manashsarmab7af8172020-07-16 05:05:44 -05006Resource ../../lib/resource.robot
7Resource ../../lib/bmc_redfish_resource.robot
8Resource ../../lib/openbmc_ffdc.robot
9Resource ../../lib/bmc_redfish_utils.robot
10Resource ../../lib/utils.robot
11
12Suite Setup Suite Setup Execution
13Test Teardown FFDC On Test Case Fail
George Keishing4e0978d2022-07-27 10:21:18 -050014Suite Teardown Run Keyword And Ignore Error Suite Teardown Execution
manashsarmab7af8172020-07-16 05:05:44 -050015
George Keishing3da6d5f2023-09-07 22:15:20 +053016Force Tags Vmicert_Management
George Keishing725e0662022-07-20 22:18:14 -050017
manashsarmab7af8172020-07-16 05:05:44 -050018
19*** Variables ***
20
21# users User Name password
22@{ADMIN} admin_user TestPwd123
23@{OPERATOR} operator_user TestPwd123
Prashanth Katti7ee28252020-09-17 01:55:17 -050024@{ReadOnly} readonly_user TestPwd123
25@{NoAccess} noaccess_user TestPwd123
Prashanth Katti7c0f9d42022-07-08 05:21:40 -050026# Removing Operator, need to add it back once support is given.
27&{USERS} Administrator=${ADMIN} ReadOnly=${ReadOnly}
manashsarmab7af8172020-07-16 05:05:44 -050028${VMI_BASE_URI} /ibm/v1/
shrsuman1235fc20cb2021-02-02 04:55:47 -060029
manashsarmab7af8172020-07-16 05:05:44 -050030
31*** Test Cases ***
32
33Get CSR Request Signed By VMI And Verify
34 [Documentation] Get CSR request signed by VMI using different user roles and verify.
35 [Tags] Get_CSR_Request_Signed_By_VMI_And_Verify
36 [Template] Get Certificate Signed By VMI
37
38 # username password force_create valid_csr valid_status_code
39 ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
Prashanth Katti7ee28252020-09-17 01:55:17 -050040
41 # Send CSR request from operator user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -050042 # operator_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
manashsarmab7af8172020-07-16 05:05:44 -050043
Prashanth Katti7ee28252020-09-17 01:55:17 -050044 # Send CSR request from ReadOnly user.
45 readonly_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
46
47 # Send CSR request from NoAccess user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -050048 # noaccess_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
Prashanth Katti7ee28252020-09-17 01:55:17 -050049
manashsarmab7af8172020-07-16 05:05:44 -050050
George Keishing4203fad2022-01-31 12:22:33 -060051Get Root Certificate Using Different Privilege Users Role
manashsarmab7af8172020-07-16 05:05:44 -050052 [Documentation] Get root certificate using different users.
George Keishing4203fad2022-01-31 12:22:33 -060053 [Tags] Get_Root_Certificate_Using_Different_Privilege_Users_Role
manashsarmab7af8172020-07-16 05:05:44 -050054 [Template] Get Root Certificate
55
56 # username password force_create valid_csr valid_status_code
Prashanth Katti7ee28252020-09-17 01:55:17 -050057 # Request root certificate from admin user.
manashsarmab7af8172020-07-16 05:05:44 -050058 admin_user TestPwd123 ${True} ${True} ${HTTP_OK}
Prashanth Katti7ee28252020-09-17 01:55:17 -050059
60 # Request root certificate from operator user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -050061 # operator_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
manashsarmab7af8172020-07-16 05:05:44 -050062
Prashanth Katti7ee28252020-09-17 01:55:17 -050063 # Request root certificate from ReadOnly user.
64 readonly_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
65
66 # Request root certificate from NoAccess user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -050067 # noaccess_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
Prashanth Katti7ee28252020-09-17 01:55:17 -050068
69
70Send CSR Request When VMI Is Off And Verify
71 [Documentation] Send CSR signing request to VMI when it is off and expect an error.
George Keishing4203fad2022-01-31 12:22:33 -060072 [Tags] Send_CSR_Request_When_VMI_Is_Off_And_Verify
Prashanth Katti7ee28252020-09-17 01:55:17 -050073 [Setup] Redfish Power Off
Megha G N5d880772024-05-10 05:47:03 -050074 [Teardown] Run Keywords Redfish Power On stack_mode=skip AND
75 ... Wait For Host Boot Progress To Reach Required State
Prashanth Katti7ee28252020-09-17 01:55:17 -050076 [Template] Get Certificate Signed By VMI
77
shrsuman123932759b2021-10-19 07:23:22 -050078 # username password force_create valid_csr valid_status_code read_timeout
79 ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_SERVICE_UNAVAILABLE} 60
Prashanth Katti7ee28252020-09-17 01:55:17 -050080
81 # Send CSR request from operator user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -050082 # operator_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
Prashanth Katti7ee28252020-09-17 01:55:17 -050083
84 # Send CSR request from ReadOnly user.
shrsuman1233f70a6a2021-04-08 04:48:07 -050085 readonly_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
Prashanth Katti7ee28252020-09-17 01:55:17 -050086
87 # Send CSR request from NoAccess user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -050088 # noaccess_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
89
Prashanth Katti7ee28252020-09-17 01:55:17 -050090
shrsuman1231b1c2a42020-11-02 23:02:30 -060091Get Corrupted CSR Request Signed By VMI And Verify
92 [Documentation] Send corrupted CSR for signing and expect an error.
93 [Tags] Get_Corrupted_CSR_Request_Signed_By_VMI_And_Verify
shrsuman1231b1c2a42020-11-02 23:02:30 -060094 [Template] Get Certificate Signed By VMI
95
Prashanth Katti7c0f9d42022-07-08 05:21:40 -050096 # username password force_create valid_csr valid_status_code read_timeout
97 ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST} 60
shrsuman1231b1c2a42020-11-02 23:02:30 -060098
99 # Send CSR request from operator user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500100 # operator_user TestPwd123 ${False} ${False} ${HTTP_FORBIDDEN}
shrsuman1231b1c2a42020-11-02 23:02:30 -0600101
102 # Send CSR request from ReadOnly user.
103 readonly_user TestPwd123 ${False} ${False} ${HTTP_FORBIDDEN}
104
105 # Send CSR request from NoAccess user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500106 # noaccess_user TestPwd123 ${False} ${False} ${HTTP_FORBIDDEN}
107
shrsuman1231b1c2a42020-11-02 23:02:30 -0600108
shrsuman12368bdcae2021-01-18 00:38:25 -0600109Get Root Certificate When VMI Is Off And Verify
110 [Documentation] Get root certificate when vmi is off and verify.
111 [Tags] Get_Root_Certificate_When_VMI_Is_Off_And_Verify
112 [Setup] Redfish Power Off
Megha G N5d880772024-05-10 05:47:03 -0500113 [Teardown] Run Keywords Redfish Power On stack_mode=skip AND
114 ... Wait For Host Boot Progress To Reach Required State
shrsuman12368bdcae2021-01-18 00:38:25 -0600115 [Template] Get Root Certificate
shrsuman1231b1c2a42020-11-02 23:02:30 -0600116
shrsuman12368bdcae2021-01-18 00:38:25 -0600117 # username password force_create valid_csr valid_status_code
118 ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
119
120 # Request root certificate from operator user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500121 # operator_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
shrsuman12368bdcae2021-01-18 00:38:25 -0600122
123 # Request root certificate from ReadOnly user.
124 readonly_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
125
126 # Request root certificate from NoAccess user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500127 # noaccess_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
shrsuman12368bdcae2021-01-18 00:38:25 -0600128
129
130Get Root Certificate After BMC Reboot And Verify
131 [Documentation] Get root certificate after bmc reboot and verify.
132 [Tags] Get_Root_Certificate_After_BMC_Reboot_And_Verify
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500133 [Setup] Run Keywords OBMC Reboot (off) stack_mode=skip AND Redfish Power On
shrsuman12368bdcae2021-01-18 00:38:25 -0600134 [Template] Get Root Certificate
135
136 # username password force_create valid_csr valid_status_code
137 ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
138
139 # Request root certificate from operator user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500140 # operator_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
shrsuman12368bdcae2021-01-18 00:38:25 -0600141
142 # Request root certificate from ReadOnly user.
143 readonly_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
144
145 # Request root certificate from NoAccess user.
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500146 # noaccess_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
147
manashsarmab7af8172020-07-16 05:05:44 -0500148
shrsuman1235fc20cb2021-02-02 04:55:47 -0600149Get Concurrent Root Certificate Requests From Multiple Admin Users
150 [Documentation] Get multiple concurrent root certificate requests from multiple admins
151 ... and verify no errors.
152 [Tags] Get_Concurrent_Root_Certificate_Requests_From_Multiple_Admin_Users
153
154 FOR ${i} IN RANGE ${5}
155 ${dict}= Execute Process Multi Keyword ${5}
156 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
157 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
158 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
159 Dictionary Should Not Contain Value ${dict} False
160 ... msg=One or more operations has failed.
161 END
162
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500163
shrsuman1235fc20cb2021-02-02 04:55:47 -0600164Get Concurrent CSR Requests From Multiple Admin Users
165 [Documentation] Get multiple concurrent csr requests from multiple admins and verify no errors.
166 [Tags] Get_Concurrent_CSR_Requests_From_Multiple_Admin_Users
167
168 FOR ${i} IN RANGE ${5}
169 ${dict}= Execute Process Multi Keyword ${5}
170 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
171 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
172 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
173 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
174 Dictionary Should Not Contain Value ${dict} False
175 ... msg=One or more operations has failed.
176 END
177
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500178
shrsuman1235fc20cb2021-02-02 04:55:47 -0600179Get Concurrent Corrupted CSR Requests From Multiple Admin Users
180 [Documentation] Get multiple concurrent corrupted csr requests from multiple admins and verify no errors.
181 [Tags] Get_Concurrent_Corrupted_CSR_Requests_From_Multiple_Admin_Users
182
183 FOR ${i} IN RANGE ${5}
184 ${dict}= Execute Process Multi Keyword ${5}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500185 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
186 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
187 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman1235fc20cb2021-02-02 04:55:47 -0600188 Dictionary Should Not Contain Value ${dict} False
189 ... msg=One or more operations has failed.
190 END
191
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500192
193*** Comment ***
194
shrsuman12382a9a312021-03-26 05:34:32 -0500195Get Concurrent Root Certificate Request From Operator Users
196 [Documentation] Get multiple concurrent root certificate from non admin users and verify no errors.
197 [Tags] Get_Concurrent_Root_Certificate_Request_From_Operator_Users
198
199 FOR ${i} IN RANGE ${5}
200 ${dict}= Execute Process Multi Keyword ${5}
201 ... Get Root Certificate operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
202 ... Get Root Certificate operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
203 ... Get Root Certificate operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
204 Dictionary Should Not Contain Value ${dict} False
205 ... msg=One or more operations has failed.
206 END
207
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500208
209*** Test Cases ***
210
shrsuman12382a9a312021-03-26 05:34:32 -0500211Get Concurrent Root Certificate Request From Admin And Non Admin Users
212 [Documentation] Get multiple concurrent root certificate from admin and non admin users
213 ... and verify no errors.
214 [Tags] Get_Concurrent_Root_Certificate_Request_From_Admin_And_Non_Admin_Users
215
216 FOR ${i} IN RANGE ${5}
217 ${dict}= Execute Process Multi Keyword ${5}
218 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
shrsuman12382a9a312021-03-26 05:34:32 -0500219 ... Get Root Certificate readonly_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
220 Dictionary Should Not Contain Value ${dict} False
221 ... msg=One or more operations has failed.
222 END
223
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500224
225*** Comment ***
226
shrsuman12382a9a312021-03-26 05:34:32 -0500227Get Concurrent Root Certificate Request From Different Non Admin Users
228 [Documentation] Get multiple concurrent root certificate from different non admin users
229 ... and verify no errors.
230 [Tags] Get_Concurrent_Root_Certificate_Request_From_Different_Non_Admin_Users
231
232 FOR ${i} IN RANGE ${5}
233 ${dict}= Execute Process Multi Keyword ${5}
234 ... Get Root Certificate operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
235 ... Get Root Certificate readonly_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
236 ... Get Root Certificate noaccess_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
237 Dictionary Should Not Contain Value ${dict} False
238 ... msg=One or more operations has failed.
239 END
240
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500241
shrsuman12382a9a312021-03-26 05:34:32 -0500242Get Concurrent CSR Request From Operator Users
243 [Documentation] Get multiple concurrent csr request from non admin users and verify no errors.
244 [Tags] Get_Concurrent_CSR_Request_From_Operator_Users
245
246 FOR ${i} IN RANGE ${5}
247 ${dict}= Execute Process Multi Keyword ${5}
248 ... Get Certificate Signed By VMI operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
249 ... Get Certificate Signed By VMI operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
250 ... Get Certificate Signed By VMI operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
251 Dictionary Should Not Contain Value ${dict} False
252 ... msg=One or more operations has failed.
253 END
254
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500255
256*** Test Cases ***
257
shrsuman12394b36572021-03-10 03:15:53 -0600258Get Root Certificate And Send CSR Request Concurrently And Verify
259 [Documentation] Get root certificate and send csr request concurrently and
260 ... verify gets root and signed certificate.
261 [Tags] Get_Root_Certificate_And_Send_CSR_Request_Concurrently_And_Verify
262
263 FOR ${i} IN RANGE ${5}
264 ${dict}= Execute Process Multi Keyword ${5}
265 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
266 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
267 Dictionary Should Not Contain Value ${dict} False
268 ... msg=One or more operations has failed.
269 END
270
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500271
shrsuman12394b36572021-03-10 03:15:53 -0600272Get Concurrent Root Certificate And Send CSR Request And Verify
273 [Documentation] Get concurrent root certificate and send csr request
274 ... and verify gets root certificate and signed certificate.
275 [Tags] Get_Concurrent_Root_Certificate_And_Send_CSR_Request_And_Verify
276
277 FOR ${i} IN RANGE ${5}
278 ${dict}= Execute Process Multi Keyword ${5}
279 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
280 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
281 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
282 Dictionary Should Not Contain Value ${dict} False
283 ... msg=One or more operations has failed.
284 END
285
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500286
shrsuman12394b36572021-03-10 03:15:53 -0600287Get Root Certificate And Send Multiple CSR Requests Concurrently And Verify
288 [Documentation] Get root certificate and send multiple csr requests concurrently and
289 ... verify gets root certificate and signed certificates.
290 [Tags] Get_Root_Certificate_And_Send_Multiple_CSR_Requests_Concurrently_And_Verify
291
292 FOR ${i} IN RANGE ${5}
293 ${dict}= Execute Process Multi Keyword ${5}
294 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
295 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
296 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
297 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
298 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
299 Dictionary Should Not Contain Value ${dict} False
300 ... msg=One or more operations has failed.
301 END
302
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500303
shrsuman12394b36572021-03-10 03:15:53 -0600304Get Root Certificate And Send Multiple Corrupted CSR Requests Concurrently And Verify
305 [Documentation] Get root certificate and send multiple corrupted csr requests concurrently and
306 ... verify gets root certificate and error for corrupted csr requests.
307 [Tags] Get_Root_Certificate_And_Send_Multiple_Corrupted_CSR_Requests_Concurrently_And_Verify
308
309 FOR ${i} IN RANGE ${5}
310 ${dict}= Execute Process Multi Keyword ${5}
311 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500312 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
313 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
314 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman12394b36572021-03-10 03:15:53 -0600315 Dictionary Should Not Contain Value ${dict} False
316 ... msg=One or more operations has failed.
317 END
318
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500319
shrsuman123b63aa5e2021-04-12 06:20:18 -0500320Send Concurrent CSR Request And Corrupted CSR Request And Verify
321 [Documentation] Send concurrent csr request and corrupted csr request
322 ... and verify gets certificate for valid csr and error for corrupted csr.
323 [Tags] Send_Concurrent_CSR_Request_And_Corrupted_CSR_Request_And_Verify
324
325 FOR ${i} IN RANGE ${5}
326 ${dict}= Execute Process Multi Keyword ${5}
327 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
328 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500329 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
330 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman123b63aa5e2021-04-12 06:20:18 -0500331 Dictionary Should Not Contain Value ${dict} False
332 ... msg=One or more operations has failed.
333 END
334
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500335
shrsuman123b63aa5e2021-04-12 06:20:18 -0500336Get Root Certificate Send CSR And Corrupted CSR Request Concurrently And Verify
337 [Documentation] Get root certificate send csr and corrupted csr requests concurrently and
338 ... verify gets root certificate and certificate for valid csr and error for corrupted csr.
339 [Tags] Get_Root_Certificate_Send_CSR_And_Corrupted_CSR_Request_Concurrently_And_Verify
340
341 FOR ${i} IN RANGE ${5}
342 ${dict}= Execute Process Multi Keyword ${5}
343 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
344 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500345 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
346 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman123b63aa5e2021-04-12 06:20:18 -0500347 Dictionary Should Not Contain Value ${dict} False
348 ... msg=One or more operations has failed.
349 END
350
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500351
shrsuman123b63aa5e2021-04-12 06:20:18 -0500352Send Concurrent CSR Request From Admin And Non Admin Users And Verify
353 [Documentation] Send concurrent csr requests from admin and non-admin users and verify
354 ... admin gets certificate and non-admin gets error.
355 [Tags] Send_Concurrent_CSR_Request_From_Admin_And_Non_Admin_Users_And_Verify
356
357 FOR ${i} IN RANGE ${5}
358 ${dict}= Execute Process Multi Keyword ${5}
359 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
shrsuman123b63aa5e2021-04-12 06:20:18 -0500360 ... Get Certificate Signed By VMI readonly_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
361 Dictionary Should Not Contain Value ${dict} False
362 ... msg=One or more operations has failed.
363 END
364
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500365
366*** Comment ***
367
shrsuman123b63aa5e2021-04-12 06:20:18 -0500368Send Concurrent CSR Request From Non Admin Users And Verify
369 [Documentation] Send concurrent csr request from non admin users
370 ... and verify gets error.
371 [Tags] Send_Concurrent_CSR_Request_From_Non_Admin_Users_And_Verify
372
373 FOR ${i} IN RANGE ${5}
374 ${dict}= Execute Process Multi Keyword ${5}
375 ... Get Certificate Signed By VMI operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
376 ... Get Certificate Signed By VMI readonly_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
377 ... Get Certificate Signed By VMI noaccess_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
378 Dictionary Should Not Contain Value ${dict} False
379 ... msg=One or more operations has failed.
380 END
381
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500382
shrsuman123a968ad52021-06-08 06:30:01 -0500383Get Root Certificate And Send Corrupted CSR From Admin CSR Request From Operator Concurrently
384 [Documentation] Get root certificate and send corrupted csr request from admin and
George Keishing7bc01e92021-06-15 11:07:14 -0500385 ... csr from operator concurrently and verify gets root certificate and errors for corrupted
shrsuman123a968ad52021-06-08 06:30:01 -0500386 ... and for operator.
387 [Tags] Get_Root_Certificate_And_Send_Corrupted_CSR_From_Admin_CSR_Request_From_Operator_Concurrently
388
389 FOR ${i} IN RANGE ${5}
390 ${dict}= Execute Process Multi Keyword ${5}
391 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500392 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
393 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman123a968ad52021-06-08 06:30:01 -0500394 ... Get Certificate Signed By VMI operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
395 Dictionary Should Not Contain Value ${dict} False
396 ... msg=One or more operations has failed.
397 END
398
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500399
shrsuman123a968ad52021-06-08 06:30:01 -0500400Get Root Certificate From Operator And Send Corrupted CSR Request And CSR Request From Admin Concurrently
401 [Documentation] Get root certificate from operator and send corrupted csr request
402 ... and csr from admin and verify errors for operator and corrupted csr and signed certificate
403 ... for valid csr.
404 [Tags] Get_Root_Certificate_From_Operator_And_Send_Corrupted_CSR_Request_And_CSR_Request_From_Admin_Concurrently
405
406 FOR ${i} IN RANGE ${5}
407 ${dict}= Execute Process Multi Keyword ${5}
408 ... Get Root Certificate operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500409 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
410 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman123a968ad52021-06-08 06:30:01 -0500411 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
412 Dictionary Should Not Contain Value ${dict} False
413 ... msg=One or more operations has failed.
414 END
415
416
417Get Root Certificate From Operator And Admin Send CSR Request From Admin Concurrently
418 [Documentation] Get root certificate from operator and admin and
419 ... and send csr request from admin concurrently and verify error for operator
420 ... and admin gets root and signed certificate.
421 [Tags] Get_Root_Certificate_From_Operator_And_Admin_Send_CSR_Request_From_Admin_Concurrently
422
423 FOR ${i} IN RANGE ${5}
424 ${dict}= Execute Process Multi Keyword ${5}
425 ... Get Root Certificate operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
426 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
427 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
428 Dictionary Should Not Contain Value ${dict} False
429 ... msg=One or more operations has failed.
430 END
431
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500432
shrsuman1235e80c022021-05-25 01:28:39 -0500433Send CSR Request From Admin And Operator And Corrupted CSR From Admin Concurrently And Verify
434 [Documentation] Send csr request from admin and operator and corrupted
435 ... csr request from admin and verify gets signed certificate for valid csr for admin
436 ... gets error for operator and error for corrupted csr.
437 [Tags] Send_CSR_Request_From_Admin_And_Operator_And_Corrupted_CSR_From_Admin_Concurrently_And_Verify
438
439 FOR ${i} IN RANGE ${5}
440 ${dict}= Execute Process Multi Keyword ${5}
441 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
442 ... Get Certificate Signed By VMI operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500443 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman1235e80c022021-05-25 01:28:39 -0500444 Dictionary Should Not Contain Value ${dict} False
445 ... msg=One or more operations has failed.
446 END
447
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500448
shrsuman1235e80c022021-05-25 01:28:39 -0500449Send Corrupted CSR Requests From Admin And Operator And CSR Request From Admin Concurrently And Verify
450 [Documentation] Send corrupted csr request from admin and operator and csr request
451 ... from admin concurrently and verify errors for corrupted csr and gets signed certificate
452 ... for valid csr from admin.
453 [Tags] Send_Corrupted_CSR_Requests_From_Admin_And_Operator_And_CSR_Request_From_Admin_Concurrently_And_Verify
454
455 FOR ${i} IN RANGE ${5}
456 ${dict}= Execute Process Multi Keyword ${5}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500457 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman1235e80c022021-05-25 01:28:39 -0500458 ... Get Certificate Signed By VMI operator_user TestPwd123 ${True} ${False} ${HTTP_FORBIDDEN}
459 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
460 Dictionary Should Not Contain Value ${dict} False
461 ... msg=One or more operations has failed.
462 END
463
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500464
shrsuman1235e80c022021-05-25 01:28:39 -0500465Send Corrupted CSR Requests From Admin And Operator User Concurrently And Verify
466 [Documentation] Send corrupted csr requests from admin and operator and
467 ... verify gets error.
468 [Tags] Send_Corrupted_CSR_Requests_From_Admin_And_Operator_User_Concurrently_And_Verify
469
470 FOR ${i} IN RANGE ${5}
471 ${dict}= Execute Process Multi Keyword ${5}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500472 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
473 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman1235e80c022021-05-25 01:28:39 -0500474 ... Get Certificate Signed By VMI operator_user TestPwd123 ${True} ${False} ${HTTP_FORBIDDEN}
475 Dictionary Should Not Contain Value ${dict} False
476 ... msg=One or more operations has failed.
477 END
478
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500479
480*** Test Cases ***
481
shrsuman123e05f7bc2021-04-23 04:42:05 -0500482Get Root Certificate From Admin And Send CSR Requests From Non Admin Concurrently And Verify
483 [Documentation] Get root certificate from admin and csr requests from
484 ... non admin users concurrently and verify gets root certificate for admin and
485 ... errors for non-admins.
486 [Tags] Get_Root_Certificate_From_Admin_And_Send_CSR_Requests_From_Non_Admin_Concurrently_And_Verify
487
488 FOR ${i} IN RANGE ${5}
489 ${dict}= Execute Process Multi Keyword ${5}
490 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
shrsuman123e05f7bc2021-04-23 04:42:05 -0500491 ... Get Certificate Signed By VMI readonly_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
492 Dictionary Should Not Contain Value ${dict} False
493 ... msg=One or more operations has failed.
494 END
495
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500496
shrsuman123e05f7bc2021-04-23 04:42:05 -0500497Get Root Certificate And Send CSR Requests From Non Admin Users Concurrently And Verify
498 [Documentation] Get root certificate and send csr requests from non admin
499 ... users and verify gets errors.
500 [Tags] Get_Root_Certificate_And_Send_CSR_Requests_From_Non_Admin_Users_Concurrently_And_Verify
501
502 FOR ${i} IN RANGE ${5}
503 ${dict}= Execute Process Multi Keyword ${5}
shrsuman123e05f7bc2021-04-23 04:42:05 -0500504 ... Get Root Certificate readonly_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
505 ... Get Certificate Signed By VMI readonly_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
shrsuman123e05f7bc2021-04-23 04:42:05 -0500506 Dictionary Should Not Contain Value ${dict} False
507 ... msg=One or more operations has failed.
508 END
509
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500510
shrsuman123e05f7bc2021-04-23 04:42:05 -0500511Send Corrupted CSR Request From Admin And CSR Requests From Non Admin Concurrently And Verify
512 [Documentation] Send corrupted csr request from admin and csr request from non admin
513 ... users concurrently and verify gets errors.
514 [Tags] Send_Corrupted_CSR_Request_From_Admin_And_CSR_Requests_From_Non_Admin_Concurrently_And_Verify
515
516 FOR ${i} IN RANGE ${5}
517 ${dict}= Execute Process Multi Keyword ${5}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500518 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman123e05f7bc2021-04-23 04:42:05 -0500519 ... Get Certificate Signed By VMI readonly_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
520 Dictionary Should Not Contain Value ${dict} False
521 ... msg=One or more operations has failed.
522 END
523
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500524
shrsuman123e05f7bc2021-04-23 04:42:05 -0500525Send CSR Request And Corrupted CSR Requests From Non Admin Users Concurrently And Verify
526 [Documentation] Send csr and corrupted csr request from non admin users
527 ... and verify gets errors.
528 [Tags] Send_CSR_Request_And_Corrupted_CSR_Requests_From_Non_Admin_Users_Concurrently_And_Verify
529
530 FOR ${i} IN RANGE ${5}
531 ${dict}= Execute Process Multi Keyword ${5}
shrsuman123e05f7bc2021-04-23 04:42:05 -0500532 ... Get Certificate Signed By VMI readonly_user TestPwd123 ${True} ${False} ${HTTP_FORBIDDEN}
shrsuman123e05f7bc2021-04-23 04:42:05 -0500533 ... Get Certificate Signed By VMI readonly_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
534 Dictionary Should Not Contain Value ${dict} False
535 ... msg=One or more operations has failed.
536 END
537
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500538
539*** Comment ***
540
shrsuman123421e6102021-06-23 05:25:57 -0500541Get Root Certificate And Send CSR Requests From Admin And Operator Concurrently And Verify
542 [Documentation] Get root certificate from admin and send csr requests
543 ... from admin and operator concurrently and verify gets root certificate
544 ... and signed certificate and gets error for operator.
545 [Tags] Get_Root_Certificate_And_Send_CSR_Requests_From_Admin_And_Operator_Concurrently_And_Verify
546
547 FOR ${i} IN RANGE ${5}
548 ${dict}= Execute Process Multi Keyword ${5}
549 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
550 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
551 ... Get Certificate Signed By VMI operator_user TestPwd123 ${True} ${True} ${HTTP_FORBIDDEN}
552 Dictionary Should Not Contain Value ${dict} False
553 ... msg=One or more operations has failed.
554 END
555
556
557Get Root Certificate And Send Corrupted CSR Requests From Admin And Operator Concurrently And Verify
558 [Documentation] Get root certificate from admin and send corrupted csr requests
559 ... from admin and operator concurrently and verify gets root certificate and errors
560 ... for corrupted csr.
561 [Tags] Get_Root_Certificate_And_Send_Corrupted_CSR_Requests_From_Admin_And_Operator_Concurrently_And_Verify
562
563 FOR ${i} IN RANGE ${5}
564 ${dict}= Execute Process Multi Keyword ${5}
565 ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500566 ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_BAD_REQUEST}
shrsuman123421e6102021-06-23 05:25:57 -0500567 ... Get Certificate Signed By VMI operator_user TestPwd123 ${True} ${False} ${HTTP_FORBIDDEN}
568 Dictionary Should Not Contain Value ${dict} False
569 ... msg=One or more operations has failed.
570 END
571
Prashanth Katti7c0f9d42022-07-08 05:21:40 -0500572
manashsarmab7af8172020-07-16 05:05:44 -0500573*** Keywords ***
574
575Generate CSR String
576 [Documentation] Generate a csr string.
577
578 # Note: Generates and returns csr string.
shrsuman1235fc20cb2021-02-02 04:55:47 -0600579 ${csr_gen_time} = Get Current Date Time
580 ${CSR_FILE}= Catenate SEPARATOR=_ ${csr_gen_time} csr_server.csr
581 ${CSR_KEY}= Catenate SEPARATOR=_ ${csr_gen_time} csr_server.key
582 Set Test Variable ${CSR_FILE}
583 Set Test Variable ${CSR_KEY}
manashsarmab7af8172020-07-16 05:05:44 -0500584 ${ssl_cmd}= Set Variable openssl req -new -newkey rsa:2048 -nodes -keyout ${CSR_KEY} -out ${CSR_FILE}
585 ${ssl_sub}= Set Variable
586 ... -subj "/C=XY/ST=Abcd/L=Efgh/O=ABC/OU=Systems/CN=abc.com/emailAddress=xyz@xx.ABC.com"
587
588 # Run openssl command to create a new private key and use that to generate a CSR string
589 # in server.csr file.
590 ${output}= Run ${ssl_cmd} ${ssl_sub}
Prashanth Katti7ee28252020-09-17 01:55:17 -0500591 ${csr}= OperatingSystem.Get File ${CSR_FILE}
manashsarmab7af8172020-07-16 05:05:44 -0500592
593 [Return] ${csr}
594
595
596Send CSR To VMI And Get Signed
George Keishingf9248952021-05-28 07:52:37 -0500597 [Documentation] Upload CSR to VMI and get signed.
shrsuman123932759b2021-10-19 07:23:22 -0500598 [Arguments] ${csr} ${force_create} ${username} ${password} ${read_timeout}
manashsarmab7af8172020-07-16 05:05:44 -0500599
600 # Description of argument(s):
601 # csr Certificate request from client to VMI.
602 # force_create Create a new REST session if True.
603 # username Username to create a REST session.
604 # password Password to create a REST session.
605
606 Run Keyword If "${XAUTH_TOKEN}" != "${EMPTY}" or ${force_create} == ${True}
607 ... Initialize OpenBMC rest_username=${username} rest_password=${password}
608
609 ${data}= Create Dictionary
610 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN}
611 ... Content-Type=application/json
612
613 ${cert_uri}= Set Variable ${VMI_BASE_URI}Host/Actions/SignCSR
614
615 # For SignCSR request, we need to pass CSR string generated by openssl command.
616 ${csr_data}= Create Dictionary CsrString ${csr}
manashsarmab7af8172020-07-16 05:05:44 -0500617
George Keishing753169e2022-08-18 09:57:48 -0500618 ${resp}= POST On Session openbmc ${cert_uri} json=${csr_data} headers=${headers}
George Keishingfbd67002022-08-01 11:24:03 -0500619 ... timeout=${read_timeout} expected_status=any
shrsuman1235fc20cb2021-02-02 04:55:47 -0600620 Log to console ${resp.content}
manashsarmab7af8172020-07-16 05:05:44 -0500621
622 [Return] ${resp}
623
624
625Get Root Certificate
626 [Documentation] Get root certificate from VMI.
627 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD}
628 ... ${force_create}=${False} ${valid_csr}=${True} ${valid_status_code}=${HTTP_OK}
629
630 # Description of argument(s):
631 # cert_type Type of the certificate requesting. eg. root or SignCSR.
632 # username Username to create a REST session.
633 # password Password to create a REST session.
634 # force_create Create a new REST session if True.
635 # valid_csr Uses valid CSR string in the REST request if True.
636 # This is not applicable for root certificate.
637 # valid_status_code Expected status code from REST request.
638
639 Run Keyword If "${XAUTH_TOKEN}" != "${EMPTY}" or ${force_create} == ${True}
640 ... Initialize OpenBMC rest_username=${username} rest_password=${password}
641
642 ${data}= Create Dictionary
643 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN}
644 ... Content-Type=application/json
645
646 ${cert_uri}= Set Variable ${VMI_BASE_URI}Host/Certificate/root
647
George Keishingfbd67002022-08-01 11:24:03 -0500648 ${resp}= GET On Session openbmc ${cert_uri} &{data} headers=${headers}
649 ... expected_status=any
manashsarmab7af8172020-07-16 05:05:44 -0500650
651 Should Be Equal As Strings ${resp.status_code} ${valid_status_code}
652 Return From Keyword If ${resp.status_code} != ${HTTP_OK}
653
654 ${cert}= Evaluate json.loads('''${resp.text}''', strict=False) json
655 Should Contain ${cert["Certificate"]} BEGIN CERTIFICATE
656 Should Contain ${cert["Certificate"]} END CERTIFICATE
657
658
659Get Subject
660 [Documentation] Generate a csr string.
661 [Arguments] ${file_name} ${is_csr_file}
662
663 # Description of argument(s):
664 # file_name Name of CSR or signed CERT file.
665 # is_csr_file A True value means a CSR while a False is for signed CERT file.
666
George Keishing538f1742022-03-14 05:00:55 -0500667 ${subject}= Run Keyword If ${is_csr_file}
668 ... Run openssl req -in ${file_name} -text -noout | grep Subject:
669 ... ELSE
670 ... Run openssl x509 -in ${file_name} -text -noout | grep Subject:
manashsarmab7af8172020-07-16 05:05:44 -0500671
672 [Return] ${subject}
673
674
675Get Public Key
676 [Documentation] Generate a csr string.
677 [Arguments] ${file_name} ${is_csr_file}
678
679 # Description of argument(s):
680 # file_name Name of CSR or CERT file.
681 # is_csr_file A True value means a CSR while a False is for signed CERT file.
682
683 ${PublicKey}= Run Keyword If ${is_csr_file} Run openssl req -in ${file_name} -noout -pubkey
684 ... ELSE Run openssl x509 -in ${file_name} -noout -pubkey
685
686 [Return] ${PublicKey}
687
688
689Get Certificate Signed By VMI
690 [Documentation] Get signed certificate from VMI.
691 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD}
692 ... ${force_create}=${False} ${valid_csr}=${True} ${valid_status_code}=${HTTP_OK}
shrsuman123932759b2021-10-19 07:23:22 -0500693 ... ${read_timeout}=20
manashsarmab7af8172020-07-16 05:05:44 -0500694
695 # Description of argument(s):
696 # cert_type Type of the certificate requesting. eg. root or SignCSR.
697 # username Username to create a REST session.
698 # password Password to create a REST session.
699 # force_create Create a new REST session if True.
700 # valid_csr Uses valid CSR string in the REST request if True.
701 # This is not applicable for root certificate.
702 # valid_status_code Expected status code from REST request.
703
704 Set Test Variable ${CSR} CSR
705 Set Test Variable ${CORRUPTED_CSR} CORRUPTED_CSR
706
707 ${CSR}= Generate CSR String
shrsuman1231b1c2a42020-11-02 23:02:30 -0600708 ${csr_left} ${csr_right}= Split String From Right ${CSR} == 1
709 ${CORRUPTED_CSR}= Catenate SEPARATOR= ${csr_left} \N ${csr_right}
manashsarmab7af8172020-07-16 05:05:44 -0500710
711 # For SignCSR request, we need to pass CSR string generated by openssl command
712 ${csr_str}= Set Variable If ${valid_csr} == ${True} ${CSR} ${CORRUPTED_CSR}
713
714 ${resp}= Send CSR To VMI And Get Signed ${csr_str} ${force_create} ${username} ${password}
shrsuman123932759b2021-10-19 07:23:22 -0500715 ... ${read_timeout}
manashsarmab7af8172020-07-16 05:05:44 -0500716
717 Should Be Equal As Strings ${resp.status_code} ${valid_status_code}
718 Return From Keyword If ${resp.status_code} != ${HTTP_OK}
719
720 ${cert}= Evaluate json.loads('''${resp.text}''', strict=False) json
721 Should Contain ${cert["Certificate"]} BEGIN CERTIFICATE
722 Should Contain ${cert["Certificate"]} END CERTIFICATE
723
724 # Now do subject and public key verification
725 ${subject_csr}= Get Subject ${CSR_FILE} True
726 ${pubKey_csr}= Get Public Key ${CSR_FILE} True
727
728 # create a crt file with certificate string
729 ${signed_cert}= Set Variable ${cert["Certificate"]}
shrsuman1235fc20cb2021-02-02 04:55:47 -0600730 ${testcert_gen_time} = Get Current Date Time
731 ${test_cert_file}= Catenate SEPARATOR=_ ${testcert_gen_time} test_certificate.cert
manashsarmab7af8172020-07-16 05:05:44 -0500732
shrsuman1235fc20cb2021-02-02 04:55:47 -0600733 Create File ${test_cert_file} ${signed_cert}
734 ${subject_signed_csr}= Get Subject ${test_cert_file} False
735 ${pubKey_signed_csr}= Get Public Key ${test_cert_file} False
manashsarmab7af8172020-07-16 05:05:44 -0500736
737 Should be equal as strings ${subject_signed_csr} ${subject_csr}
738 Should be equal as strings ${pubKey_signed_csr} ${pubKey_csr}
739
740
741Suite Setup Execution
742 [Documentation] Suite setup execution.
743
shrsuman1235fc20cb2021-02-02 04:55:47 -0600744 Remove Files *.csr *.key *.cert
manashsarmab7af8172020-07-16 05:05:44 -0500745 # Create different user accounts.
746 Redfish.Login
Megha G Nd0b4da92024-02-08 15:04:24 -0600747
748 Redfish Power Off
749 Set BIOS Attribute pvm_hmc_managed Enabled
750
shrsuman1235fc20cb2021-02-02 04:55:47 -0600751 Redfish Power On
Megha G N88e5c9b2024-05-08 02:06:36 -0500752 Wait For Host Boot Progress To Reach Required State
manashsarmab7af8172020-07-16 05:05:44 -0500753 Create Users With Different Roles users=${USERS} force=${True}
754
755
756Suite Teardown Execution
757 [Documentation] Suite teardown execution.
758
shrsuman1235fc20cb2021-02-02 04:55:47 -0600759 Remove Files *.csr *.key *.cert
manashsarmab7af8172020-07-16 05:05:44 -0500760 Delete BMC Users Via Redfish users=${USERS}
761 Delete All Sessions
762 Redfish.Logout