blob: a128178c6a11402b541448f401da2f87d8147417 [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
Joanna Jeremicz9c14f192020-03-19 14:51:51 +01008Library ../libraries/CertClientManager.py ${MOUNT_PATH}
9Library ../libraries/JksFilesValidator.py ${MOUNT_PATH}
Aleksandra Maciaga6def5972020-02-20 09:42:03 +010010
11*** Keywords ***
12
13Create sessions
14 [Documentation] Create all required sessions
15 Create Session aaf_cert_service_url ${AAFCERT_URL}
16 Set Suite Variable ${http_session} aaf_cert_service_url
17
18Run Healthcheck
19 [Documentation] Run Healthcheck
20 ${resp}= Get Request ${http_session} /actuator/health
21 Should Be Equal As Strings ${resp.status_code} 200
22 Validate Recieved Response ${resp} status UP
23
Aleksandra Maciaga6def5972020-02-20 09:42:03 +010024Validate Recieved Response
25 [Documentation] Validare message that has been received
26 [Arguments] ${resp} ${key} ${expected_value}
27 ${json}= Parse Json ${resp.content}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010028 ${value}= Get From Dictionary ${json} ${key}
29 Should Be Equal As Strings ${value} ${expected_value}
30
31Send Get Request And Validate Response
32 [Documentation] Send request to passed url and validate received response
33 [Arguments] ${path} ${resp_code}
34 ${resp}= Get Request ${http_session} ${path}
35 Should Be Equal As Strings ${resp.status_code} ${resp_code}
36
Aleksandra Maciagaf6300682020-03-04 17:11:30 +010037Send Get Request with Header
38 [Documentation] Send request to passed url
39 [Arguments] ${path} ${csr_file} ${pk_file}
40 [Return] ${resp}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010041 ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file}
42 ${resp}= Get Request ${http_session} ${path} headers=${headers}
Aleksandra Maciagaf6300682020-03-04 17:11:30 +010043
44Send Get Request with Header And Expect Success
45 [Documentation] Send request to passed url and validate received response
46 [Arguments] ${path} ${csr_file} ${pk_file}
47 ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file}
48 Should Be Equal As Strings ${resp.status_code} 200
49 Check Message Recieved On Success ${resp.content}
50
51Check Message Recieved On Success
52 [Documentation] Check if correct messsage has been sent on successful request
53 [Arguments] ${content}
54 ${resp_content}= Parse Json ${content}
55 Dictionary Should Contain Key ${resp_content} certificateChain
56 @{list}= Get From Dictionary ${resp_content} certificateChain
57 List Should Contain Certificates @{list}
58 Dictionary Should Contain Key ${resp_content} trustedCertificates
59
60List Should Contain Certificates
61 [Documentation] Verify if list contains certificates
62 [Arguments] @{list}
63 :FOR ${content} IN @{list}
64 \ Should Contain ${content} BEGIN CERTIFICATE
65 \ Should Contain ${content} END CERTIFICATE
66
67Send Get Request with Header And Expect Error
68 [Documentation] Send request to passed url and validate received response
69 [Arguments] ${path} ${csr_file} ${pk_file} ${resp_code}
70 ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010071 Should Be Equal As Strings ${resp.status_code} ${resp_code}
72
73Create Header with CSR and PK
74 [Documentation] Create header with CSR and PK
75 [Arguments] ${csr_file} ${pk_file}
76 [Return] ${headers}
77 ${csr}= Get Data From File ${csr_file}
78 ${pk}= Get Data From File ${pk_file}
79 ${headers}= Create Dictionary CSR=${csr} PK=${pk}
80
81Send Post Request And Validate Response
82 [Documentation] Send request to passed url and validate received response
83 [Arguments] ${path} ${resp_code}
84 ${resp}= Post Request ${http_session} ${path}
85 Should Be Equal As Strings ${resp.status_code} ${resp_code}
Tomasz Wrobel75573b02020-03-05 16:43:50 +010086
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010087Run Cert Service Client And Validate JKS File Creation And Client Exit Code
Tomasz Wrobel75573b02020-03-05 16:43:50 +010088 [Documentation] Run Cert Service Client Container And Validate Exit Code
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010089 [Arguments] ${env_file} ${expected_exit_code}
kjaniak25fac3a2020-03-18 13:01:36 +010090 ${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 +010091 ${can_open}= Can Open Keystore And Truststore With Pass
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010092 Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path
93 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code}
94 Should Be True ${can_open} Cannot Open Keystore/TrustStore by passpshase
95
Joanna Jeremicz9c14f192020-03-19 14:51:51 +010096Run Cert Service Client And Validate JKS Files Contain Expected Data
97 [Documentation] Run Cert Service Client Container And Validate JKS Files Contain Expected Data
98 [Arguments] ${env_file} ${expected_exit_code}
99 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
100 ${data} ${isEqual}= Get And Compare Data ${env_file}
101 Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path_with_data
102 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code}
103 Should Be True ${isEqual} Keystore doesn't contain ${data.expectedData}. Actual data is: ${data.actualData}
104
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +0100105Run Cert Service Client And Validate Http Response Code And Client Exit Code
106 [Documentation] Run Cert Service Client Container And Validate Exit Code
107 [Arguments] ${env_file} ${expected_api_response_code} ${expected_exit_code}
kjaniak25fac3a2020-03-18 13:01:36 +0100108 ${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 +0100109 ${can_find_API_response}= Can Find Api Response In Logs ${CLIENT_CONTAINER_NAME}
110 ${api_response_code}= Get Api Response From Logs ${CLIENT_CONTAINER_NAME}
111 Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} negative_path
112 Should Be True ${can_find_API_response} Cannot Find API response in logs
113 Should Be Equal As Strings ${api_response_code} ${expected_api_response_code} API return ${api_response_code} but expected: ${expected_api_response_code}
114 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code}