blob: 39c26a6a299256900e2f0bf9e7b779380e721ee7 [file] [log] [blame]
Aleksandra Maciaga6def5972020-02-20 09:42:03 +01001*** Settings ***
2
Joanna Jeremicz9c14f192020-03-19 14:51:51 +01003Resource ../../../common.robot
4Resource ./cert-service-properties.robot
Aleksandra Maciaga6def5972020-02-20 09:42:03 +01005Library RequestsLibrary
6Library HttpLibrary.HTTP
7Library Collections
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +01008Library ../libraries/CertClientManager.py ${MOUNT_PATH} ${TRUSTSTORE_PATH}
Joanna Jeremiczc21b0082020-06-15 16:21:55 +02009Library ../libraries/P12ArtifactsValidator.py ${MOUNT_PATH}
10Library ../libraries/JksArtifactsValidator.py ${MOUNT_PATH}
11Library ../libraries/PemArtifactsValidator.py ${MOUNT_PATH}
Aleksandra Maciaga6def5972020-02-20 09:42:03 +010012
13*** Keywords ***
14
15Create sessions
16 [Documentation] Create all required sessions
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +010017 ${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 Maciaga6def5972020-02-20 09:42:03 +010020
21Run Healthcheck
22 [Documentation] Run Healthcheck
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +010023 ${resp}= Get Request ${https_valid_cert_session} /actuator/health
Aleksandra Maciaga6def5972020-02-20 09:42:03 +010024 Should Be Equal As Strings ${resp.status_code} 200
25 Validate Recieved Response ${resp} status UP
26
Aleksandra Maciaga6def5972020-02-20 09:42:03 +010027Validate Recieved Response
28 [Documentation] Validare message that has been received
29 [Arguments] ${resp} ${key} ${expected_value}
30 ${json}= Parse Json ${resp.content}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010031 ${value}= Get From Dictionary ${json} ${key}
32 Should Be Equal As Strings ${value} ${expected_value}
33
34Send Get Request And Validate Response
35 [Documentation] Send request to passed url and validate received response
36 [Arguments] ${path} ${resp_code}
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +010037 ${resp}= Get Request ${https_valid_cert_session} ${path}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010038 Should Be Equal As Strings ${resp.status_code} ${resp_code}
39
Aleksandra Maciagaf6300682020-03-04 17:11:30 +010040Send Get Request with Header
41 [Documentation] Send request to passed url
42 [Arguments] ${path} ${csr_file} ${pk_file}
43 [Return] ${resp}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010044 ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file}
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +010045 ${resp}= Get Request ${https_valid_cert_session} ${path} headers=${headers}
Aleksandra Maciagaf6300682020-03-04 17:11:30 +010046
47Send 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
54Check 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
63List 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
70Send 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 Maciaga8d762b12020-02-24 14:24:42 +010074 Should Be Equal As Strings ${resp.status_code} ${resp_code}
75
76Create 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
84Send Post Request And Validate Response
85 [Documentation] Send request to passed url and validate received response
86 [Arguments] ${path} ${resp_code}
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +010087 ${resp}= Post Request ${https_valid_cert_session} ${path}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010088 Should Be Equal As Strings ${resp.status_code} ${resp_code}
Tomasz Wrobel75573b02020-03-05 16:43:50 +010089
Joanna Jeremiczc21b0082020-06-15 16:21:55 +020090Run Cert Service Client And Validate PKCS12 File Creation And Client Exit Code
Tomasz Wrobel75573b02020-03-05 16:43:50 +010091 [Documentation] Run Cert Service Client Container And Validate Exit Code
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010092 [Arguments] ${env_file} ${expected_exit_code}
kjaniak25fac3a2020-03-18 13:01:36 +010093 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
Remigiusz Janeczeked0f3be2020-03-19 14:20:22 +010094 ${can_open}= Can Open Keystore And Truststore With Pass
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010095 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 Jeremiczc21b0082020-06-15 16:21:55 +020099Run 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
108Run 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 Jeremicz9c14f192020-03-19 14:51:51 +0100117Run 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 Jeremiczc21b0082020-06-15 16:21:55 +0200121 ${data} ${isEqual}= Get And Compare Data Jks ${env_file}
Joanna Jeremicz9c14f192020-03-19 14:51:51 +0100122 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 Jeremiczc21b0082020-06-15 16:21:55 +0200126Run 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 Wrobel6ed06d52020-03-11 15:31:10 +0100137Run 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}
kjaniak25fac3a2020-03-18 13:01:36 +0100140 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +0100141 ${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 Jeremiczc21b0082020-06-15 16:21:55 +0200147
148Run 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