blob: 7ade544539da62c56f6f572d27d37c61db8fa40e [file] [log] [blame]
Rahul Maheshwari984791c2018-09-21 00:49:37 -05001*** Settings ***
2
3Documentation Test certificate in OpenBMC.
4
5Resource ../lib/rest_client.robot
6Resource ../lib/resource.txt
7Resource ../lib/openbmc_ffdc.robot
8Resource ../lib/certificate_utils.robot
9
Rahul Maheshwari665bc612018-10-24 04:57:53 -050010Suite Setup Suite Setup Execution
11Test Teardown Test Teardown Execution
12
13Force Tags Certificate_Test
Rahul Maheshwari984791c2018-09-21 00:49:37 -050014
15
16*** Test Cases ***
17
18Test Server Certificate Install With Valid Certificate And Valid Private Key
19 [Documentation] Test server certificate install with valid certificate
20 ... and valid private key.
21 [Tags] Test_Server_Certificate_Install_With_Valid_Certificate_And_Valid_Private_Key
22 [Template] Certificate Install Via REST
23 # Certificate type Certificate file format Expected Status
24 Server Valid Certificate Valid Privatekey ok
25
26
27Test Server Certificate Install With Empty Certificate And Valid Private Key
28 [Documentation] Test server certificate install with empty certificate
29 ... and valid private key.
30 [Tags] Test_Server_Certificate_Install_With_Empty_Certificate_And_Valid_Private_Key
31 [Template] Certificate Install Via REST
32
33 # Certificate type Certificate file format Expected Status
34 Server Empty Certificate Valid Privatekey error
35
36
37Test Server Certificate Install With Valid Certificate And Empty Private Key
38 [Documentation] Test server certificate install with valid certificate
39 ... and empty private key.
40 [Tags] Test_Server_Certificate_Install_With_Valid_Certificate_And_Empty_Private_Key
41 [Template] Certificate Install Via REST
42
43 # Certificate type Certificate file format Expected Status
44 Server Valid Certificate Empty Privatekey error
45
46
47Test Server Certificate Install With Empty Certificate And Empty Private Key
48 [Documentation] Test server certificate install with empty certificate
49 ... and empty private key.
50 [Tags] Test_Server_Certificate_Install_With_Empty_Certificate_And_Empty_Private_Key
51 [Template] Certificate Install Via REST
52
53 # Certificate type Certificate file format Expected Status
54 Server Empty Certificate Empty Privatekey error
55
56
57Test Server Certificate Install With Expired Certificate
58 [Documentation] Test server certificate install with expired certificate.
59 [Tags] Test_Server_Certificate_Install_With_Expired_Certificate
60 [Template] Certificate Install Via REST
61 # Certificate type Certificate file format Expected Status
62 Server Expired Certificate error
63
64
65Test Client Certificate Install With Valid Certificate And Valid Private Key
66 [Documentation] Test client certificate install with valid certificate
67 ... and valid private key.
68 [Tags] Test_Client_Certificate_Install_With_Valid_Certificate_And_Valid_Private_Key
69 [Template] Certificate Install Via REST
70 # Certificate type Certificate file format Expected Status
71 Client Valid Certificate Valid Privatekey ok
72
73
74Test Client Certificate Install With Empty Certificate And Valid Private Key
75 [Documentation] Test client certificate install with empty certificate
76 ... and valid private key.
77 [Tags] Test_Client_Certificate_Install_With_Empty_Certificate_And_Valid_Private_Key
78 [Template] Certificate Install Via REST
79
80 # Certificate type Certificate file format Expected Status
81 Client Empty Certificate Valid Privatekey error
82
83
84Test Client Certificate Install With Valid Certificate And Empty Private Key
85 [Documentation] Test client certificate install with valid certificate
86 ... and empty private key.
87 [Tags] Test_Client_Certificate_Install_With_Valid_Certificate_And_Empty_Private_Key
88 [Template] Certificate Install Via REST
89
90 # Certificate type Certificate file format Expected Status
91 Client Valid Certificate Empty Privatekey error
92
93
94Test Client Certificate Install With Empty Certificate And Empty Private Key
95 [Documentation] Test client certificate install with empty certificate
96 ... and empty private key.
97 [Tags] Test_Client_Certificate_Install_With_Empty_Certificate_And_Empty_Private_Key
98 [Template] Certificate Install Via REST
99
100 # Certificate type Certificate file format Expected Status
101 Client Empty Certificate Empty Privatekey error
102
103
104Test Client Certificate Install With Expired Certificate
105 [Documentation] Test client certificate install with expired certificate.
106 [Tags] Test_Client_Certificate_Install_With_Expired_Certificate
107 [Template] Certificate Install Via REST
108 # Certificate type Certificate file format Expected Status
109 Client Expired Certificate error
110
111
Rahul Maheshwari081eadb2018-10-26 03:11:10 -0500112Test CA Certificate Install With Valid Certificate
113 [Documentation] Test CA certificate install with valid certificate.
114 [Tags] Test_CA_Certificate_Install_With_Valid_Certificate
115 [Template] Certificate Install Via REST
116
117 # Certificate type Certificate file format Expected Status
118 CA Valid Certificate ok
119
120
121Test CA Certificate Install With Empty Certificate
122 [Documentation] Test CA certificate install with empty certificate.
123 [Tags] Test_CA_Certificate_Install_With_Empty_Certificate
124 [Template] Certificate Install Via REST
125
126 # Certificate type Certificate file format Expected Status
127 CA Empty Certificate error
128
129
Rahul Maheshwari984791c2018-09-21 00:49:37 -0500130Test Delete Server Certificate
131 [Documentation] Delete server certificate and verify.
132 [Tags] Test_Delete_Server_Certificate
133
134 ${cert_file_path}= Generate Certificate File Via Openssl
135 ... Valid Certificate Valid Privatekey
136 ${file_data}= OperatingSystem.Get Binary File ${cert_file_path}
137 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
138
139 Install Certificate File On BMC ${SERVER_CERTIFICATE_URI}
140 ... data=${file_data}
141
142 OpenBMC Delete Request ${SERVER_CERTIFICATE_URI}
143 # Adding delay after certificate deletion
Rahul Maheshwari665bc612018-10-24 04:57:53 -0500144 Sleep 30s
Rahul Maheshwari984791c2018-09-21 00:49:37 -0500145
146 ${bmc_cert_content}= Get Certificate Content From BMC Via Openssl
147 Should Not Contain ${cert_file_content} ${bmc_cert_content}
148
149
150Test Delete Client Certificate
151 [Documentation] Delete client certificate and verify.
152 [Tags] Test_Delete_Client_Certificate
153
154 ${cert_file_path}= Generate Certificate File Via Openssl
155 ... Valid Certificate Valid Privatekey
156 ${file_data}= OperatingSystem.Get Binary File ${cert_file_path}
157 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
158
159 Install Certificate File On BMC ${CLIENT_CERTIFICATE_URI}
160 ... data=${file_data}
161
162 OpenBMC Delete Request ${CLIENT_CERTIFICATE_URI}
163 # Adding delay after certificate deletion
164 Sleep 30s
165
Rahul Maheshwaricaa12a42018-10-24 03:44:23 -0500166 ${msg}= Run Keyword And Expect Error *
Rahul Maheshwari081eadb2018-10-26 03:11:10 -0500167 ... Get Certificate File Content From BMC Client
Rahul Maheshwari984791c2018-09-21 00:49:37 -0500168
Rahul Maheshwaricaa12a42018-10-24 03:44:23 -0500169 Should Contain ${msg} No such file or directory ignore_case=True
Rahul Maheshwari984791c2018-09-21 00:49:37 -0500170
171
Rahul Maheshwari081eadb2018-10-26 03:11:10 -0500172Test Delete CA Certificate
173 [Documentation] Delete CA certificate and verify.
174 [Tags] Test_Delete_CA_Certificate
175
176 ${cert_file_path}= Generate Certificate File Via Openssl
177 ... Valid Certificate
178 ${file_data}= OperatingSystem.Get Binary File ${cert_file_path}
179 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
180
181 Install Certificate File On BMC ${CA_CERTIFICATE_URI}
182 ... data=${file_data}
183
184 OpenBMC Delete Request ${CA_CERTIFICATE_URI}
185 # Adding delay after certificate deletion.
186 Sleep 30s
187
188 ${msg}= Run Keyword And Expect Error *
189 ... Get Certificate File Content From BMC CA
190
191 Should Contain ${msg} No such file or directory ignore_case=True
192
193
194
Rahul Maheshwari984791c2018-09-21 00:49:37 -0500195Test Continuous Server Certificate Install
196 [Documentation] Stress server certificate installtion.
197 [Tags] Test_Continuous_Server_Certificate_Install
198
Rahul Maheshwari665bc612018-10-24 04:57:53 -0500199 Repeat Keyword 3 times Certificate Install Via REST
Rahul Maheshwari984791c2018-09-21 00:49:37 -0500200 ... Server Valid Certificate Valid Privatekey ok
201
202
203Test Continuous Client Certificate Install
204 [Documentation] Stress client certificate installtion.
205 [Tags] Test_Continuous_Client_Certificate_Install
206
Rahul Maheshwari665bc612018-10-24 04:57:53 -0500207 Repeat Keyword 3 times Certificate Install Via REST
Rahul Maheshwari984791c2018-09-21 00:49:37 -0500208 ... Client Valid Certificate Valid Privatekey ok
209
210
211***Keywords***
212
213Certificate Install Via REST
214 [Documentation] Test certificate install in the BMC via REST.
215 [Arguments] ${cert_type} ${cert_format} ${expected_status}
216
217 # Description of argument(s):
218 # cert_type Certificate type (e.g. "Server" or "Client").
219 # cert_format Certificate file format
220 # (e.g. Valid_Certificate_Valid_Privatekey).
221 # expected_status Expected status of certificate installation REST
222 # request(i.e. "ok" or "error").
223
224 ${cert_file_path}= Run Keyword if '${cert_format}' == 'Expired Certificate'
225 ... Generate Certificate File Via Openssl ${cert_format} -10
226 ... ELSE Generate Certificate File Via Openssl ${cert_format}
227
228 ${file_data}= OperatingSystem.Get Binary File ${cert_file_path}
229
230 Run Keyword If '${cert_type}' == 'Server'
231 ... Install Certificate File On BMC ${SERVER_CERTIFICATE_URI}
232 ... ${expected_status} ${1} data=${file_data}
233 ... ELSE IF '${cert_type}' == 'Client'
234 ... Install Certificate File On BMC ${CLIENT_CERTIFICATE_URI}
235 ... ${expected_status} ${1} data=${file_data}
Rahul Maheshwari081eadb2018-10-26 03:11:10 -0500236 ... ELSE IF '${cert_type}' == 'CA'
237 ... Install Certificate File On BMC ${CA_CERTIFICATE_URI}
238 ... ${expected_status} ${1} data=${file_data}
Rahul Maheshwari984791c2018-09-21 00:49:37 -0500239
240 # Adding delay after certificate installation.
241 sleep 10s
242 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path}
243 Should Not Be Empty ${cert_file_content}
244
245 ${bmc_cert_content}= Run Keyword If '${cert_type}' == 'Server'
246 ... Get Certificate Content From BMC Via Openssl
247 ... ELSE IF '${cert_type}' == 'Client'
Rahul Maheshwari081eadb2018-10-26 03:11:10 -0500248 ... Get Certificate File Content From BMC Client
249 ... ELSE IF '${cert_type}' == 'CA'
250 ... Get Certificate File Content From BMC CA
Rahul Maheshwari984791c2018-09-21 00:49:37 -0500251
252 Run Keyword if '${expected_status}' == 'ok'
253 ... Should Contain ${cert_file_content} ${bmc_cert_content}
254 ... ELSE IF '${expected_status}' == 'error'
255 ... Should Not Contain ${cert_file_content} ${bmc_cert_content}
Rahul Maheshwari665bc612018-10-24 04:57:53 -0500256
257
258Suite Setup Execution
259 [Documentation] Do suite setup tasks.
260
261 # Create certificate sub-directory in current working directory.
262 Create Directory certificate_dir
263 OperatingSystem.Directory Should Exist ${EXECDIR}${/}certificate_dir
264
265
266Test Teardown Execution
267 [Documentation] Do the post test teardown.
268
269 Empty Directory ${EXECDIR}${/}certificate_dir
270 FFDC On Test Case Fail