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 | |
| 10 | Test Teardown FFDC On Test Case Fail |
| 11 | |
| 12 | |
| 13 | *** Test Cases *** |
| 14 | |
| 15 | Test Server Certificate Install With Valid Certificate And Valid Private Key |
| 16 | [Documentation] Test server certificate install with valid certificate |
| 17 | ... and valid private key. |
| 18 | [Tags] Test_Server_Certificate_Install_With_Valid_Certificate_And_Valid_Private_Key |
| 19 | [Template] Certificate Install Via REST |
| 20 | # Certificate type Certificate file format Expected Status |
| 21 | Server Valid Certificate Valid Privatekey ok |
| 22 | |
| 23 | |
| 24 | Test Server Certificate Install With Empty Certificate And Valid Private Key |
| 25 | [Documentation] Test server certificate install with empty certificate |
| 26 | ... and valid private key. |
| 27 | [Tags] Test_Server_Certificate_Install_With_Empty_Certificate_And_Valid_Private_Key |
| 28 | [Template] Certificate Install Via REST |
| 29 | |
| 30 | # Certificate type Certificate file format Expected Status |
| 31 | Server Empty Certificate Valid Privatekey error |
| 32 | |
| 33 | |
| 34 | Test Server Certificate Install With Valid Certificate And Empty Private Key |
| 35 | [Documentation] Test server certificate install with valid certificate |
| 36 | ... and empty private key. |
| 37 | [Tags] Test_Server_Certificate_Install_With_Valid_Certificate_And_Empty_Private_Key |
| 38 | [Template] Certificate Install Via REST |
| 39 | |
| 40 | # Certificate type Certificate file format Expected Status |
| 41 | Server Valid Certificate Empty Privatekey error |
| 42 | |
| 43 | |
| 44 | Test Server Certificate Install With Empty Certificate And Empty Private Key |
| 45 | [Documentation] Test server certificate install with empty certificate |
| 46 | ... and empty private key. |
| 47 | [Tags] Test_Server_Certificate_Install_With_Empty_Certificate_And_Empty_Private_Key |
| 48 | [Template] Certificate Install Via REST |
| 49 | |
| 50 | # Certificate type Certificate file format Expected Status |
| 51 | Server Empty Certificate Empty Privatekey error |
| 52 | |
| 53 | |
| 54 | Test Server Certificate Install With Expired Certificate |
| 55 | [Documentation] Test server certificate install with expired certificate. |
| 56 | [Tags] Test_Server_Certificate_Install_With_Expired_Certificate |
| 57 | [Template] Certificate Install Via REST |
| 58 | # Certificate type Certificate file format Expected Status |
| 59 | Server Expired Certificate error |
| 60 | |
| 61 | |
| 62 | Test Client Certificate Install With Valid Certificate And Valid Private Key |
| 63 | [Documentation] Test client certificate install with valid certificate |
| 64 | ... and valid private key. |
| 65 | [Tags] Test_Client_Certificate_Install_With_Valid_Certificate_And_Valid_Private_Key |
| 66 | [Template] Certificate Install Via REST |
| 67 | # Certificate type Certificate file format Expected Status |
| 68 | Client Valid Certificate Valid Privatekey ok |
| 69 | |
| 70 | |
| 71 | Test Client Certificate Install With Empty Certificate And Valid Private Key |
| 72 | [Documentation] Test client certificate install with empty certificate |
| 73 | ... and valid private key. |
| 74 | [Tags] Test_Client_Certificate_Install_With_Empty_Certificate_And_Valid_Private_Key |
| 75 | [Template] Certificate Install Via REST |
| 76 | |
| 77 | # Certificate type Certificate file format Expected Status |
| 78 | Client Empty Certificate Valid Privatekey error |
| 79 | |
| 80 | |
| 81 | Test Client Certificate Install With Valid Certificate And Empty Private Key |
| 82 | [Documentation] Test client certificate install with valid certificate |
| 83 | ... and empty private key. |
| 84 | [Tags] Test_Client_Certificate_Install_With_Valid_Certificate_And_Empty_Private_Key |
| 85 | [Template] Certificate Install Via REST |
| 86 | |
| 87 | # Certificate type Certificate file format Expected Status |
| 88 | Client Valid Certificate Empty Privatekey error |
| 89 | |
| 90 | |
| 91 | Test Client Certificate Install With Empty Certificate And Empty Private Key |
| 92 | [Documentation] Test client certificate install with empty certificate |
| 93 | ... and empty private key. |
| 94 | [Tags] Test_Client_Certificate_Install_With_Empty_Certificate_And_Empty_Private_Key |
| 95 | [Template] Certificate Install Via REST |
| 96 | |
| 97 | # Certificate type Certificate file format Expected Status |
| 98 | Client Empty Certificate Empty Privatekey error |
| 99 | |
| 100 | |
| 101 | Test Client Certificate Install With Expired Certificate |
| 102 | [Documentation] Test client certificate install with expired certificate. |
| 103 | [Tags] Test_Client_Certificate_Install_With_Expired_Certificate |
| 104 | [Template] Certificate Install Via REST |
| 105 | # Certificate type Certificate file format Expected Status |
| 106 | Client Expired Certificate error |
| 107 | |
| 108 | |
| 109 | Test Delete Server Certificate |
| 110 | [Documentation] Delete server certificate and verify. |
| 111 | [Tags] Test_Delete_Server_Certificate |
| 112 | |
| 113 | ${cert_file_path}= Generate Certificate File Via Openssl |
| 114 | ... Valid Certificate Valid Privatekey |
| 115 | ${file_data}= OperatingSystem.Get Binary File ${cert_file_path} |
| 116 | ${cert_file_content}= OperatingSystem.Get File ${cert_file_path} |
| 117 | |
| 118 | Install Certificate File On BMC ${SERVER_CERTIFICATE_URI} |
| 119 | ... data=${file_data} |
| 120 | |
| 121 | OpenBMC Delete Request ${SERVER_CERTIFICATE_URI} |
| 122 | # Adding delay after certificate deletion |
| 123 | Sleep 10s |
| 124 | |
| 125 | ${bmc_cert_content}= Get Certificate Content From BMC Via Openssl |
| 126 | Should Not Contain ${cert_file_content} ${bmc_cert_content} |
| 127 | |
| 128 | |
| 129 | Test Delete Client Certificate |
| 130 | [Documentation] Delete client certificate and verify. |
| 131 | [Tags] Test_Delete_Client_Certificate |
| 132 | |
| 133 | ${cert_file_path}= Generate Certificate File Via Openssl |
| 134 | ... Valid Certificate Valid Privatekey |
| 135 | ${file_data}= OperatingSystem.Get Binary File ${cert_file_path} |
| 136 | ${cert_file_content}= OperatingSystem.Get File ${cert_file_path} |
| 137 | |
| 138 | Install Certificate File On BMC ${CLIENT_CERTIFICATE_URI} |
| 139 | ... data=${file_data} |
| 140 | |
| 141 | OpenBMC Delete Request ${CLIENT_CERTIFICATE_URI} |
| 142 | # Adding delay after certificate deletion |
| 143 | Sleep 30s |
| 144 | |
Rahul Maheshwari | caa12a4 | 2018-10-24 03:44:23 -0500 | [diff] [blame] | 145 | ${msg}= Run Keyword And Expect Error * |
| 146 | ... Get Client Certificate File Content From BMC |
Rahul Maheshwari | 984791c | 2018-09-21 00:49:37 -0500 | [diff] [blame] | 147 | |
Rahul Maheshwari | caa12a4 | 2018-10-24 03:44:23 -0500 | [diff] [blame] | 148 | Should Contain ${msg} No such file or directory ignore_case=True |
Rahul Maheshwari | 984791c | 2018-09-21 00:49:37 -0500 | [diff] [blame] | 149 | |
| 150 | |
| 151 | Test Continuous Server Certificate Install |
| 152 | [Documentation] Stress server certificate installtion. |
| 153 | [Tags] Test_Continuous_Server_Certificate_Install |
| 154 | |
| 155 | Repeat Keyword 50 times Certificate Install Via REST |
| 156 | ... Server Valid Certificate Valid Privatekey ok |
| 157 | |
| 158 | |
| 159 | Test Continuous Client Certificate Install |
| 160 | [Documentation] Stress client certificate installtion. |
| 161 | [Tags] Test_Continuous_Client_Certificate_Install |
| 162 | |
| 163 | Repeat Keyword 50 times Certificate Install Via REST |
| 164 | ... Client Valid Certificate Valid Privatekey ok |
| 165 | |
| 166 | |
| 167 | ***Keywords*** |
| 168 | |
| 169 | Certificate Install Via REST |
| 170 | [Documentation] Test certificate install in the BMC via REST. |
| 171 | [Arguments] ${cert_type} ${cert_format} ${expected_status} |
| 172 | |
| 173 | # Description of argument(s): |
| 174 | # cert_type Certificate type (e.g. "Server" or "Client"). |
| 175 | # cert_format Certificate file format |
| 176 | # (e.g. Valid_Certificate_Valid_Privatekey). |
| 177 | # expected_status Expected status of certificate installation REST |
| 178 | # request(i.e. "ok" or "error"). |
| 179 | |
| 180 | ${cert_file_path}= Run Keyword if '${cert_format}' == 'Expired Certificate' |
| 181 | ... Generate Certificate File Via Openssl ${cert_format} -10 |
| 182 | ... ELSE Generate Certificate File Via Openssl ${cert_format} |
| 183 | |
| 184 | ${file_data}= OperatingSystem.Get Binary File ${cert_file_path} |
| 185 | |
| 186 | Run Keyword If '${cert_type}' == 'Server' |
| 187 | ... Install Certificate File On BMC ${SERVER_CERTIFICATE_URI} |
| 188 | ... ${expected_status} ${1} data=${file_data} |
| 189 | ... ELSE IF '${cert_type}' == 'Client' |
| 190 | ... Install Certificate File On BMC ${CLIENT_CERTIFICATE_URI} |
| 191 | ... ${expected_status} ${1} data=${file_data} |
| 192 | |
| 193 | # Adding delay after certificate installation. |
| 194 | sleep 10s |
| 195 | ${cert_file_content}= OperatingSystem.Get File ${cert_file_path} |
| 196 | Should Not Be Empty ${cert_file_content} |
| 197 | |
| 198 | ${bmc_cert_content}= Run Keyword If '${cert_type}' == 'Server' |
| 199 | ... Get Certificate Content From BMC Via Openssl |
| 200 | ... ELSE IF '${cert_type}' == 'Client' |
| 201 | ... Get Client Certificate File Content From BMC |
| 202 | |
| 203 | Run Keyword if '${expected_status}' == 'ok' |
| 204 | ... Should Contain ${cert_file_content} ${bmc_cert_content} |
| 205 | ... ELSE IF '${expected_status}' == 'error' |
| 206 | ... Should Not Contain ${cert_file_content} ${bmc_cert_content} |