blob: d4d4fd931e8d9fcd50b11ef69232e52b5c6d5333 [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 Jeremicz9c14f192020-03-19 14:51:51 +01009Library ../libraries/JksFilesValidator.py ${MOUNT_PATH}
Aleksandra Maciaga6def5972020-02-20 09:42:03 +010010
11*** Keywords ***
12
13Create sessions
14 [Documentation] Create all required sessions
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +010015 ${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
Aleksandra Maciaga6def5972020-02-20 09:42:03 +010018
19Run Healthcheck
20 [Documentation] Run Healthcheck
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +010021 ${resp}= Get Request ${https_valid_cert_session} /actuator/health
Aleksandra Maciaga6def5972020-02-20 09:42:03 +010022 Should Be Equal As Strings ${resp.status_code} 200
23 Validate Recieved Response ${resp} status UP
24
Aleksandra Maciaga6def5972020-02-20 09:42:03 +010025Validate Recieved Response
26 [Documentation] Validare message that has been received
27 [Arguments] ${resp} ${key} ${expected_value}
28 ${json}= Parse Json ${resp.content}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010029 ${value}= Get From Dictionary ${json} ${key}
30 Should Be Equal As Strings ${value} ${expected_value}
31
32Send Get Request And Validate Response
33 [Documentation] Send request to passed url and validate received response
34 [Arguments] ${path} ${resp_code}
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +010035 ${resp}= Get Request ${https_valid_cert_session} ${path}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010036 Should Be Equal As Strings ${resp.status_code} ${resp_code}
37
Aleksandra Maciagaf6300682020-03-04 17:11:30 +010038Send Get Request with Header
39 [Documentation] Send request to passed url
40 [Arguments] ${path} ${csr_file} ${pk_file}
41 [Return] ${resp}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010042 ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file}
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +010043 ${resp}= Get Request ${https_valid_cert_session} ${path} headers=${headers}
Aleksandra Maciagaf6300682020-03-04 17:11:30 +010044
45Send 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}
51
52Check 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
60
61List Should Contain Certificates
62 [Documentation] Verify if list contains certificates
63 [Arguments] @{list}
64 :FOR ${content} IN @{list}
65 \ Should Contain ${content} BEGIN CERTIFICATE
66 \ Should Contain ${content} END CERTIFICATE
67
68Send 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}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010072 Should Be Equal As Strings ${resp.status_code} ${resp_code}
73
74Create Header with CSR and PK
75 [Documentation] Create header with CSR and PK
76 [Arguments] ${csr_file} ${pk_file}
77 [Return] ${headers}
78 ${csr}= Get Data From File ${csr_file}
79 ${pk}= Get Data From File ${pk_file}
80 ${headers}= Create Dictionary CSR=${csr} PK=${pk}
81
82Send Post Request And Validate Response
83 [Documentation] Send request to passed url and validate received response
84 [Arguments] ${path} ${resp_code}
Aleksandra Maciaga13b7d052020-03-26 17:28:47 +010085 ${resp}= Post Request ${https_valid_cert_session} ${path}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010086 Should Be Equal As Strings ${resp.status_code} ${resp_code}
Tomasz Wrobel75573b02020-03-05 16:43:50 +010087
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010088Run Cert Service Client And Validate JKS File Creation And Client Exit Code
Tomasz Wrobel75573b02020-03-05 16:43:50 +010089 [Documentation] Run Cert Service Client Container And Validate Exit Code
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010090 [Arguments] ${env_file} ${expected_exit_code}
kjaniak25fac3a2020-03-18 13:01:36 +010091 ${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 +010092 ${can_open}= Can Open Keystore And Truststore With Pass
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010093 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
96
Joanna Jeremicz9c14f192020-03-19 14:51:51 +010097Run 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}
105
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +0100106Run 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}
kjaniak25fac3a2020-03-18 13:01:36 +0100109 ${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 +0100110 ${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}