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/JksFilesValidator.py ${MOUNT_PATH}
14 [Documentation] Create all required sessions
15 ${certs}= Create List ${CERTSERVICE_SERVER_CRT} ${CERTSERVICE_SERVER_KEY}
16 Create Client Cert Session alias ${AAFCERT_URL} client_certs=${certs} verify=${ROOTCA}
17 Set Suite Variable ${https_valid_cert_session} alias
20 [Documentation] Run Healthcheck
21 ${resp}= Get Request ${https_valid_cert_session} /actuator/health
22 Should Be Equal As Strings ${resp.status_code} 200
23 Validate Recieved Response ${resp} status UP
25 Validate Recieved Response
26 [Documentation] Validare message that has been received
27 [Arguments] ${resp} ${key} ${expected_value}
28 ${json}= Parse Json ${resp.content}
29 ${value}= Get From Dictionary ${json} ${key}
30 Should Be Equal As Strings ${value} ${expected_value}
32 Send Get Request And Validate Response
33 [Documentation] Send request to passed url and validate received response
34 [Arguments] ${path} ${resp_code}
35 ${resp}= Get Request ${https_valid_cert_session} ${path}
36 Should Be Equal As Strings ${resp.status_code} ${resp_code}
38 Send Get Request with Header
39 [Documentation] Send request to passed url
40 [Arguments] ${path} ${csr_file} ${pk_file}
42 ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file}
43 ${resp}= Get Request ${https_valid_cert_session} ${path} headers=${headers}
45 Send Get Request with Header And Expect Success
46 [Documentation] Send request to passed url and validate received response
47 [Arguments] ${path} ${csr_file} ${pk_file}
48 ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file}
49 Should Be Equal As Strings ${resp.status_code} 200
50 Check Message Recieved On Success ${resp.content}
52 Check Message Recieved On Success
53 [Documentation] Check if correct messsage has been sent on successful request
54 [Arguments] ${content}
55 ${resp_content}= Parse Json ${content}
56 Dictionary Should Contain Key ${resp_content} certificateChain
57 @{list}= Get From Dictionary ${resp_content} certificateChain
58 List Should Contain Certificates @{list}
59 Dictionary Should Contain Key ${resp_content} trustedCertificates
61 List Should Contain Certificates
62 [Documentation] Verify if list contains certificates
64 :FOR ${content} IN @{list}
65 \ Should Contain ${content} BEGIN CERTIFICATE
66 \ Should Contain ${content} END CERTIFICATE
68 Send Get Request with Header And Expect Error
69 [Documentation] Send request to passed url and validate received response
70 [Arguments] ${path} ${csr_file} ${pk_file} ${resp_code}
71 ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file}
72 Should Be Equal As Strings ${resp.status_code} ${resp_code}
74 Create Header with CSR and PK
75 [Documentation] Create header with CSR and PK
76 [Arguments] ${csr_file} ${pk_file}
78 ${csr}= Get Data From File ${csr_file}
79 ${pk}= Get Data From File ${pk_file}
80 ${headers}= Create Dictionary CSR=${csr} PK=${pk}
82 Send Post Request And Validate Response
83 [Documentation] Send request to passed url and validate received response
84 [Arguments] ${path} ${resp_code}
85 ${resp}= Post Request ${https_valid_cert_session} ${path}
86 Should Be Equal As Strings ${resp.status_code} ${resp_code}
88 Run Cert Service Client And Validate JKS File Creation And Client Exit Code
89 [Documentation] Run Cert Service Client Container And Validate Exit Code
90 [Arguments] ${env_file} ${expected_exit_code}
91 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
92 ${can_open}= Can Open Keystore And Truststore With Pass
93 Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path
94 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code}
95 Should Be True ${can_open} Cannot Open Keystore/TrustStore by passpshase
97 Run Cert Service Client And Validate JKS Files Contain Expected Data
98 [Documentation] Run Cert Service Client Container And Validate JKS Files Contain Expected Data
99 [Arguments] ${env_file} ${expected_exit_code}
100 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
101 ${data} ${isEqual}= Get And Compare Data ${env_file}
102 Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path_with_data
103 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code}
104 Should Be True ${isEqual} Keystore doesn't contain ${data.expectedData}. Actual data is: ${data.actualData}
106 Run Cert Service Client And Validate Http Response Code And Client Exit Code
107 [Documentation] Run Cert Service Client Container And Validate Exit Code
108 [Arguments] ${env_file} ${expected_api_response_code} ${expected_exit_code}
109 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
110 ${can_find_API_response}= Can Find Api Response In Logs ${CLIENT_CONTAINER_NAME}
111 ${api_response_code}= Get Api Response From Logs ${CLIENT_CONTAINER_NAME}
112 Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} negative_path
113 Should Be True ${can_find_API_response} Cannot Find API response in logs
114 Should Be Equal As Strings ${api_response_code} ${expected_api_response_code} API return ${api_response_code} but expected: ${expected_api_response_code}
115 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code}