3 Resource ../../../common.robot
4 Resource ./cert-service-properties.robot
5 Library RequestsLibrary
6 Library HttpLibrary.HTTP
8 Library ../libraries/CertClientManager.py ${MOUNT_PATH} ${TRUSTSTORE_PATH}
9 Library ../libraries/P12ArtifactsValidator.py ${MOUNT_PATH}
10 Library ../libraries/JksArtifactsValidator.py ${MOUNT_PATH}
11 Library ../libraries/PemArtifactsValidator.py ${MOUNT_PATH}
16 [Documentation] Create all required sessions
17 ${certs}= Create List ${CERTSERVICE_SERVER_CRT} ${CERTSERVICE_SERVER_KEY}
18 Create Client Cert Session alias ${OOMCERT_URL} client_certs=${certs} verify=${ROOTCA}
19 Set Suite Variable ${https_valid_cert_session} alias
22 [Documentation] Run Healthcheck
23 ${resp}= Get Request ${https_valid_cert_session} /actuator/health
24 Should Be Equal As Strings ${resp.status_code} 200
25 Validate Recieved Response ${resp} status UP
27 Validate Recieved Response
28 [Documentation] Validare message that has been received
29 [Arguments] ${resp} ${key} ${expected_value}
30 ${json}= Parse Json ${resp.content}
31 ${value}= Get From Dictionary ${json} ${key}
32 Should Be Equal As Strings ${value} ${expected_value}
34 Send Get Request And Validate Response
35 [Documentation] Send request to passed url and validate received response
36 [Arguments] ${path} ${resp_code}
37 ${resp}= Get Request ${https_valid_cert_session} ${path}
38 Should Be Equal As Strings ${resp.status_code} ${resp_code}
40 Send Get Request with Header
41 [Documentation] Send request to passed url
42 [Arguments] ${path} ${csr_file} ${pk_file}
44 ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file}
45 ${resp}= Get Request ${https_valid_cert_session} ${path} headers=${headers}
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}
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
63 List Should Contain Certificates
64 [Documentation] Verify if list contains certificates
66 FOR ${content} IN @{list}
67 Should Contain ${content} BEGIN CERTIFICATE
68 Should Contain ${content} END CERTIFICATE
71 Send Get Request with Header And Expect Error
72 [Documentation] Send request to passed url and validate received response
73 [Arguments] ${path} ${csr_file} ${pk_file} ${resp_code}
74 ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file}
75 Should Be Equal As Strings ${resp.status_code} ${resp_code}
77 Create Header with CSR and PK
78 [Documentation] Create header with CSR and PK
79 [Arguments] ${csr_file} ${pk_file}
81 ${csr}= Get Data From File ${csr_file}
82 ${pk}= Get Data From File ${pk_file}
83 ${headers}= Create Dictionary CSR=${csr} PK=${pk}
85 Send Post Request And Validate Response
86 [Documentation] Send request to passed url and validate received response
87 [Arguments] ${path} ${resp_code}
88 ${resp}= Post Request ${https_valid_cert_session} ${path}
89 Should Be Equal As Strings ${resp.status_code} ${resp_code}
91 Run Cert Service Client And Validate PKCS12 File Creation And Client Exit Code
92 [Documentation] Run Cert Service Client Container And Validate Exit Code
93 [Arguments] ${env_file} ${expected_exit_code}
94 [Teardown] Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path
95 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
96 ${can_open}= Can Open Keystore And Truststore With Pass
97 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code}
98 Should Be True ${can_open} Cannot Open Keystore/TrustStore by passpshase
100 Run Cert Service Client And Validate JKS File Creation And Client Exit Code
101 [Documentation] Run Cert Service Client Container And Validate Exit Code
102 [Arguments] ${env_file} ${expected_exit_code}
103 [Teardown] Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path
104 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
105 ${can_open}= Can Open Keystore And Truststore With Pass Jks
106 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code}
107 Should Be True ${can_open} Cannot Open Keystore/TrustStore by passpshase
109 Run Cert Service Client And Validate PKCS12 Files Contain Expected Data
110 [Documentation] Run Cert Service Client Container And Validate PKCS12 Files Contain Expected Data
111 [Arguments] ${env_file} ${expected_exit_code}
112 [Teardown] Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path_with_data
113 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
114 ${data} ${isEqual}= Get And Compare Data P12 ${env_file}
115 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code}
116 Should Be True ${isEqual} Keystore doesn't contain ${data.expectedData}. Actual data is: ${data.actualData}
118 Run Cert Service Client And Validate JKS Files Contain Expected Data
119 [Documentation] Run Cert Service Client Container And Validate JKS Files Contain Expected Data
120 [Arguments] ${env_file} ${expected_exit_code}
121 [Teardown] Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path_with_data
122 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
123 ${data} ${isEqual}= Get And Compare Data Jks ${env_file}
124 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code}
125 Should Be True ${isEqual} Keystore doesn't contain ${data.expectedData}. Actual data is: ${data.actualData}
127 Run Cert Service Client And Validate PEM Files Contain Expected Data
128 [Documentation] Run Cert Service Client Container And Validate PEM Files Contain Expected Data
129 [Arguments] ${env_file} ${expected_exit_code}
130 [Teardown] Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path_with_data
131 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
132 ${existNotEmpty}= Artifacts Exist And Are Not Empty
133 ${data} ${isEqual}= Get And Compare Data Pem ${env_file}
134 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code}
135 Should Be True ${existNotEmpty} PEM artifacts not created properly
136 Should Be True ${isEqual} Keystore doesn't contain ${data.expectedData}. Actual data is: ${data.actualData}
138 Run Cert Service Client And Validate Http Response Code And Client Exit Code
139 [Documentation] Run Cert Service Client Container And Validate Exit Code
140 [Arguments] ${env_file} ${expected_api_response_code} ${expected_exit_code}
141 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
142 ${can_find_API_response}= Can Find Api Response In Logs ${CLIENT_CONTAINER_NAME}
143 ${api_response_code}= Get Api Response From Logs ${CLIENT_CONTAINER_NAME}
144 [Teardown] Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} negative_path
145 Should Be True ${can_find_API_response} Cannot Find API response in logs
146 Should Be Equal As Strings ${api_response_code} ${expected_api_response_code} API return ${api_response_code} but expected: ${expected_api_response_code}
147 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code}
149 Run Cert Service Client And Validate Client Exit Code
150 [Documentation] Run Cert Service Client Container And Validate Exit Code
151 [Arguments] ${env_file} ${expected_exit_code}
152 [Teardown] Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} negative_path
153 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
154 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code}