Rahul Maheshwari | 984791c | 2018-09-21 00:49:37 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Test certificate in OpenBMC. |
| 4 | |
| 5 | Resource ../lib/rest_client.robot |
| 6 | Resource ../lib/resource.txt |
| 7 | Resource ../lib/openbmc_ffdc.robot |
| 8 | Resource ../lib/certificate_utils.robot |
| 9 | |
Rahul Maheshwari | 665bc61 | 2018-10-24 04:57:53 -0500 | [diff] [blame^] | 10 | Suite Setup Suite Setup Execution |
| 11 | Test Teardown Test Teardown Execution |
| 12 | |
| 13 | Force Tags Certificate_Test |
Rahul Maheshwari | 984791c | 2018-09-21 00:49:37 -0500 | [diff] [blame] | 14 | |
| 15 | |
| 16 | *** Test Cases *** |
| 17 | |
| 18 | Test 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 | |
| 27 | Test 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 | |
| 37 | Test 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 | |
| 47 | Test 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 | |
| 57 | Test 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 | |
| 65 | Test 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 | |
| 74 | Test 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 | |
| 84 | Test 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 | |
| 94 | Test 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 | |
| 104 | Test 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 | |
| 112 | Test Delete Server Certificate |
| 113 | [Documentation] Delete server certificate and verify. |
| 114 | [Tags] Test_Delete_Server_Certificate |
| 115 | |
| 116 | ${cert_file_path}= Generate Certificate File Via Openssl |
| 117 | ... Valid Certificate Valid Privatekey |
| 118 | ${file_data}= OperatingSystem.Get Binary File ${cert_file_path} |
| 119 | ${cert_file_content}= OperatingSystem.Get File ${cert_file_path} |
| 120 | |
| 121 | Install Certificate File On BMC ${SERVER_CERTIFICATE_URI} |
| 122 | ... data=${file_data} |
| 123 | |
| 124 | OpenBMC Delete Request ${SERVER_CERTIFICATE_URI} |
| 125 | # Adding delay after certificate deletion |
Rahul Maheshwari | 665bc61 | 2018-10-24 04:57:53 -0500 | [diff] [blame^] | 126 | Sleep 30s |
Rahul Maheshwari | 984791c | 2018-09-21 00:49:37 -0500 | [diff] [blame] | 127 | |
| 128 | ${bmc_cert_content}= Get Certificate Content From BMC Via Openssl |
| 129 | Should Not Contain ${cert_file_content} ${bmc_cert_content} |
| 130 | |
| 131 | |
| 132 | Test Delete Client Certificate |
| 133 | [Documentation] Delete client certificate and verify. |
| 134 | [Tags] Test_Delete_Client_Certificate |
| 135 | |
| 136 | ${cert_file_path}= Generate Certificate File Via Openssl |
| 137 | ... Valid Certificate Valid Privatekey |
| 138 | ${file_data}= OperatingSystem.Get Binary File ${cert_file_path} |
| 139 | ${cert_file_content}= OperatingSystem.Get File ${cert_file_path} |
| 140 | |
| 141 | Install Certificate File On BMC ${CLIENT_CERTIFICATE_URI} |
| 142 | ... data=${file_data} |
| 143 | |
| 144 | OpenBMC Delete Request ${CLIENT_CERTIFICATE_URI} |
| 145 | # Adding delay after certificate deletion |
| 146 | Sleep 30s |
| 147 | |
Rahul Maheshwari | caa12a4 | 2018-10-24 03:44:23 -0500 | [diff] [blame] | 148 | ${msg}= Run Keyword And Expect Error * |
| 149 | ... Get Client Certificate File Content From BMC |
Rahul Maheshwari | 984791c | 2018-09-21 00:49:37 -0500 | [diff] [blame] | 150 | |
Rahul Maheshwari | caa12a4 | 2018-10-24 03:44:23 -0500 | [diff] [blame] | 151 | Should Contain ${msg} No such file or directory ignore_case=True |
Rahul Maheshwari | 984791c | 2018-09-21 00:49:37 -0500 | [diff] [blame] | 152 | |
| 153 | |
| 154 | Test Continuous Server Certificate Install |
| 155 | [Documentation] Stress server certificate installtion. |
| 156 | [Tags] Test_Continuous_Server_Certificate_Install |
| 157 | |
Rahul Maheshwari | 665bc61 | 2018-10-24 04:57:53 -0500 | [diff] [blame^] | 158 | Repeat Keyword 3 times Certificate Install Via REST |
Rahul Maheshwari | 984791c | 2018-09-21 00:49:37 -0500 | [diff] [blame] | 159 | ... Server Valid Certificate Valid Privatekey ok |
| 160 | |
| 161 | |
| 162 | Test Continuous Client Certificate Install |
| 163 | [Documentation] Stress client certificate installtion. |
| 164 | [Tags] Test_Continuous_Client_Certificate_Install |
| 165 | |
Rahul Maheshwari | 665bc61 | 2018-10-24 04:57:53 -0500 | [diff] [blame^] | 166 | Repeat Keyword 3 times Certificate Install Via REST |
Rahul Maheshwari | 984791c | 2018-09-21 00:49:37 -0500 | [diff] [blame] | 167 | ... Client Valid Certificate Valid Privatekey ok |
| 168 | |
| 169 | |
| 170 | ***Keywords*** |
| 171 | |
| 172 | Certificate Install Via REST |
| 173 | [Documentation] Test certificate install in the BMC via REST. |
| 174 | [Arguments] ${cert_type} ${cert_format} ${expected_status} |
| 175 | |
| 176 | # Description of argument(s): |
| 177 | # cert_type Certificate type (e.g. "Server" or "Client"). |
| 178 | # cert_format Certificate file format |
| 179 | # (e.g. Valid_Certificate_Valid_Privatekey). |
| 180 | # expected_status Expected status of certificate installation REST |
| 181 | # request(i.e. "ok" or "error"). |
| 182 | |
| 183 | ${cert_file_path}= Run Keyword if '${cert_format}' == 'Expired Certificate' |
| 184 | ... Generate Certificate File Via Openssl ${cert_format} -10 |
| 185 | ... ELSE Generate Certificate File Via Openssl ${cert_format} |
| 186 | |
| 187 | ${file_data}= OperatingSystem.Get Binary File ${cert_file_path} |
| 188 | |
| 189 | Run Keyword If '${cert_type}' == 'Server' |
| 190 | ... Install Certificate File On BMC ${SERVER_CERTIFICATE_URI} |
| 191 | ... ${expected_status} ${1} data=${file_data} |
| 192 | ... ELSE IF '${cert_type}' == 'Client' |
| 193 | ... Install Certificate File On BMC ${CLIENT_CERTIFICATE_URI} |
| 194 | ... ${expected_status} ${1} data=${file_data} |
| 195 | |
| 196 | # Adding delay after certificate installation. |
| 197 | sleep 10s |
| 198 | ${cert_file_content}= OperatingSystem.Get File ${cert_file_path} |
| 199 | Should Not Be Empty ${cert_file_content} |
| 200 | |
| 201 | ${bmc_cert_content}= Run Keyword If '${cert_type}' == 'Server' |
| 202 | ... Get Certificate Content From BMC Via Openssl |
| 203 | ... ELSE IF '${cert_type}' == 'Client' |
| 204 | ... Get Client Certificate File Content From BMC |
| 205 | |
| 206 | Run Keyword if '${expected_status}' == 'ok' |
| 207 | ... Should Contain ${cert_file_content} ${bmc_cert_content} |
| 208 | ... ELSE IF '${expected_status}' == 'error' |
| 209 | ... Should Not Contain ${cert_file_content} ${bmc_cert_content} |
Rahul Maheshwari | 665bc61 | 2018-10-24 04:57:53 -0500 | [diff] [blame^] | 210 | |
| 211 | |
| 212 | Suite Setup Execution |
| 213 | [Documentation] Do suite setup tasks. |
| 214 | |
| 215 | # Create certificate sub-directory in current working directory. |
| 216 | Create Directory certificate_dir |
| 217 | OperatingSystem.Directory Should Exist ${EXECDIR}${/}certificate_dir |
| 218 | |
| 219 | |
| 220 | Test Teardown Execution |
| 221 | [Documentation] Do the post test teardown. |
| 222 | |
| 223 | Empty Directory ${EXECDIR}${/}certificate_dir |
| 224 | FFDC On Test Case Fail |