Aleksandra Maciaga | 6def597 | 2020-02-20 09:42:03 +0100 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
Joanna Jeremicz | 9c14f19 | 2020-03-19 14:51:51 +0100 | [diff] [blame] | 3 | Resource ../../../common.robot |
| 4 | Resource ./cert-service-properties.robot |
Aleksandra Maciaga | 6def597 | 2020-02-20 09:42:03 +0100 | [diff] [blame] | 5 | Library RequestsLibrary |
| 6 | Library HttpLibrary.HTTP |
| 7 | Library Collections |
Aleksandra Maciaga | 13b7d05 | 2020-03-26 17:28:47 +0100 | [diff] [blame] | 8 | Library ../libraries/CertClientManager.py ${MOUNT_PATH} ${TRUSTSTORE_PATH} |
Joanna Jeremicz | c21b008 | 2020-06-15 16:21:55 +0200 | [diff] [blame] | 9 | Library ../libraries/P12ArtifactsValidator.py ${MOUNT_PATH} |
| 10 | Library ../libraries/JksArtifactsValidator.py ${MOUNT_PATH} |
| 11 | Library ../libraries/PemArtifactsValidator.py ${MOUNT_PATH} |
Aleksandra Maciaga | 6def597 | 2020-02-20 09:42:03 +0100 | [diff] [blame] | 12 | |
| 13 | *** Keywords *** |
| 14 | |
| 15 | Create sessions |
| 16 | [Documentation] Create all required sessions |
Aleksandra Maciaga | 13b7d05 | 2020-03-26 17:28:47 +0100 | [diff] [blame] | 17 | ${certs}= Create List ${CERTSERVICE_SERVER_CRT} ${CERTSERVICE_SERVER_KEY} |
| 18 | Create Client Cert Session alias ${AAFCERT_URL} client_certs=${certs} verify=${ROOTCA} |
| 19 | Set Suite Variable ${https_valid_cert_session} alias |
Aleksandra Maciaga | 6def597 | 2020-02-20 09:42:03 +0100 | [diff] [blame] | 20 | |
| 21 | Run Healthcheck |
| 22 | [Documentation] Run Healthcheck |
Aleksandra Maciaga | 13b7d05 | 2020-03-26 17:28:47 +0100 | [diff] [blame] | 23 | ${resp}= Get Request ${https_valid_cert_session} /actuator/health |
Aleksandra Maciaga | 6def597 | 2020-02-20 09:42:03 +0100 | [diff] [blame] | 24 | Should Be Equal As Strings ${resp.status_code} 200 |
| 25 | Validate Recieved Response ${resp} status UP |
| 26 | |
Aleksandra Maciaga | 6def597 | 2020-02-20 09:42:03 +0100 | [diff] [blame] | 27 | Validate Recieved Response |
| 28 | [Documentation] Validare message that has been received |
| 29 | [Arguments] ${resp} ${key} ${expected_value} |
| 30 | ${json}= Parse Json ${resp.content} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 31 | ${value}= Get From Dictionary ${json} ${key} |
| 32 | Should Be Equal As Strings ${value} ${expected_value} |
| 33 | |
| 34 | Send Get Request And Validate Response |
| 35 | [Documentation] Send request to passed url and validate received response |
| 36 | [Arguments] ${path} ${resp_code} |
Aleksandra Maciaga | 13b7d05 | 2020-03-26 17:28:47 +0100 | [diff] [blame] | 37 | ${resp}= Get Request ${https_valid_cert_session} ${path} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 38 | Should Be Equal As Strings ${resp.status_code} ${resp_code} |
| 39 | |
Aleksandra Maciaga | f630068 | 2020-03-04 17:11:30 +0100 | [diff] [blame] | 40 | Send Get Request with Header |
| 41 | [Documentation] Send request to passed url |
| 42 | [Arguments] ${path} ${csr_file} ${pk_file} |
| 43 | [Return] ${resp} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 44 | ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file} |
Aleksandra Maciaga | 13b7d05 | 2020-03-26 17:28:47 +0100 | [diff] [blame] | 45 | ${resp}= Get Request ${https_valid_cert_session} ${path} headers=${headers} |
Aleksandra Maciaga | f630068 | 2020-03-04 17:11:30 +0100 | [diff] [blame] | 46 | |
| 47 | Send Get Request with Header And Expect Success |
| 48 | [Documentation] Send request to passed url and validate received response |
| 49 | [Arguments] ${path} ${csr_file} ${pk_file} |
| 50 | ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file} |
| 51 | Should Be Equal As Strings ${resp.status_code} 200 |
| 52 | Check Message Recieved On Success ${resp.content} |
| 53 | |
| 54 | Check Message Recieved On Success |
| 55 | [Documentation] Check if correct messsage has been sent on successful request |
| 56 | [Arguments] ${content} |
| 57 | ${resp_content}= Parse Json ${content} |
| 58 | Dictionary Should Contain Key ${resp_content} certificateChain |
| 59 | @{list}= Get From Dictionary ${resp_content} certificateChain |
| 60 | List Should Contain Certificates @{list} |
| 61 | Dictionary Should Contain Key ${resp_content} trustedCertificates |
| 62 | |
| 63 | List Should Contain Certificates |
| 64 | [Documentation] Verify if list contains certificates |
| 65 | [Arguments] @{list} |
| 66 | :FOR ${content} IN @{list} |
| 67 | \ Should Contain ${content} BEGIN CERTIFICATE |
| 68 | \ Should Contain ${content} END CERTIFICATE |
| 69 | |
| 70 | Send Get Request with Header And Expect Error |
| 71 | [Documentation] Send request to passed url and validate received response |
| 72 | [Arguments] ${path} ${csr_file} ${pk_file} ${resp_code} |
| 73 | ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 74 | Should Be Equal As Strings ${resp.status_code} ${resp_code} |
| 75 | |
| 76 | Create Header with CSR and PK |
| 77 | [Documentation] Create header with CSR and PK |
| 78 | [Arguments] ${csr_file} ${pk_file} |
| 79 | [Return] ${headers} |
| 80 | ${csr}= Get Data From File ${csr_file} |
| 81 | ${pk}= Get Data From File ${pk_file} |
| 82 | ${headers}= Create Dictionary CSR=${csr} PK=${pk} |
| 83 | |
| 84 | Send Post Request And Validate Response |
| 85 | [Documentation] Send request to passed url and validate received response |
| 86 | [Arguments] ${path} ${resp_code} |
Aleksandra Maciaga | 13b7d05 | 2020-03-26 17:28:47 +0100 | [diff] [blame] | 87 | ${resp}= Post Request ${https_valid_cert_session} ${path} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 88 | Should Be Equal As Strings ${resp.status_code} ${resp_code} |
Tomasz Wrobel | 75573b0 | 2020-03-05 16:43:50 +0100 | [diff] [blame] | 89 | |
Joanna Jeremicz | c21b008 | 2020-06-15 16:21:55 +0200 | [diff] [blame] | 90 | Run Cert Service Client And Validate PKCS12 File Creation And Client Exit Code |
Tomasz Wrobel | 75573b0 | 2020-03-05 16:43:50 +0100 | [diff] [blame] | 91 | [Documentation] Run Cert Service Client Container And Validate Exit Code |
Tomasz Wrobel | 6ed06d5 | 2020-03-11 15:31:10 +0100 | [diff] [blame] | 92 | [Arguments] ${env_file} ${expected_exit_code} |
kjaniak | 25fac3a | 2020-03-18 13:01:36 +0100 | [diff] [blame] | 93 | ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK} |
Remigiusz Janeczek | ed0f3be | 2020-03-19 14:20:22 +0100 | [diff] [blame] | 94 | ${can_open}= Can Open Keystore And Truststore With Pass |
Tomasz Wrobel | 6ed06d5 | 2020-03-11 15:31:10 +0100 | [diff] [blame] | 95 | Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path |
| 96 | Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code} |
| 97 | Should Be True ${can_open} Cannot Open Keystore/TrustStore by passpshase |
| 98 | |
Joanna Jeremicz | c21b008 | 2020-06-15 16:21:55 +0200 | [diff] [blame] | 99 | Run Cert Service Client And Validate JKS File Creation And Client Exit Code |
| 100 | [Documentation] Run Cert Service Client Container And Validate Exit Code |
| 101 | [Arguments] ${env_file} ${expected_exit_code} |
| 102 | ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK} |
| 103 | ${can_open}= Can Open Keystore And Truststore With Pass Jks |
| 104 | Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path |
| 105 | Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code} |
| 106 | Should Be True ${can_open} Cannot Open Keystore/TrustStore by passpshase |
| 107 | |
| 108 | Run Cert Service Client And Validate PKCS12 Files Contain Expected Data |
| 109 | [Documentation] Run Cert Service Client Container And Validate PKCS12 Files Contain Expected Data |
| 110 | [Arguments] ${env_file} ${expected_exit_code} |
| 111 | ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK} |
| 112 | ${data} ${isEqual}= Get And Compare Data P12 ${env_file} |
| 113 | Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path_with_data |
| 114 | Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code} |
| 115 | Should Be True ${isEqual} Keystore doesn't contain ${data.expectedData}. Actual data is: ${data.actualData} |
| 116 | |
Joanna Jeremicz | 9c14f19 | 2020-03-19 14:51:51 +0100 | [diff] [blame] | 117 | Run Cert Service Client And Validate JKS Files Contain Expected Data |
| 118 | [Documentation] Run Cert Service Client Container And Validate JKS Files Contain Expected Data |
| 119 | [Arguments] ${env_file} ${expected_exit_code} |
| 120 | ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK} |
Joanna Jeremicz | c21b008 | 2020-06-15 16:21:55 +0200 | [diff] [blame] | 121 | ${data} ${isEqual}= Get And Compare Data Jks ${env_file} |
Joanna Jeremicz | 9c14f19 | 2020-03-19 14:51:51 +0100 | [diff] [blame] | 122 | Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path_with_data |
| 123 | Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code} |
| 124 | Should Be True ${isEqual} Keystore doesn't contain ${data.expectedData}. Actual data is: ${data.actualData} |
| 125 | |
Joanna Jeremicz | c21b008 | 2020-06-15 16:21:55 +0200 | [diff] [blame] | 126 | Run Cert Service Client And Validate PEM Files Contain Expected Data |
| 127 | [Documentation] Run Cert Service Client Container And Validate PEM Files Contain Expected Data |
| 128 | [Arguments] ${env_file} ${expected_exit_code} |
| 129 | ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK} |
| 130 | ${existNotEmpty}= Artifacts Exist And Are Not Empty |
| 131 | ${data} ${isEqual}= Get And Compare Data Pem ${env_file} |
| 132 | Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path_with_data |
| 133 | Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code} |
| 134 | Should Be True ${existNotEmpty} PEM artifacts not created properly |
| 135 | Should Be True ${isEqual} Keystore doesn't contain ${data.expectedData}. Actual data is: ${data.actualData} |
| 136 | |
Tomasz Wrobel | 6ed06d5 | 2020-03-11 15:31:10 +0100 | [diff] [blame] | 137 | Run Cert Service Client And Validate Http Response Code And Client Exit Code |
| 138 | [Documentation] Run Cert Service Client Container And Validate Exit Code |
| 139 | [Arguments] ${env_file} ${expected_api_response_code} ${expected_exit_code} |
kjaniak | 25fac3a | 2020-03-18 13:01:36 +0100 | [diff] [blame] | 140 | ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK} |
Tomasz Wrobel | 6ed06d5 | 2020-03-11 15:31:10 +0100 | [diff] [blame] | 141 | ${can_find_API_response}= Can Find Api Response In Logs ${CLIENT_CONTAINER_NAME} |
| 142 | ${api_response_code}= Get Api Response From Logs ${CLIENT_CONTAINER_NAME} |
| 143 | Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} negative_path |
| 144 | Should Be True ${can_find_API_response} Cannot Find API response in logs |
| 145 | Should Be Equal As Strings ${api_response_code} ${expected_api_response_code} API return ${api_response_code} but expected: ${expected_api_response_code} |
| 146 | Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code} |
Joanna Jeremicz | c21b008 | 2020-06-15 16:21:55 +0200 | [diff] [blame] | 147 | |
| 148 | Run Cert Service Client And Validate Client Exit Code |
| 149 | [Documentation] Run Cert Service Client Container And Validate Exit Code |
| 150 | [Arguments] ${env_file} ${expected_exit_code} |
| 151 | ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK} |
| 152 | Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} negative_path |
| 153 | Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code} |
| 154 | |