blob: 75cebadc96232b5348813bc2e1404243669589a9 [file] [log] [blame]
Aleksandra Maciaga6def5972020-02-20 09:42:03 +01001*** Settings ***
2
3Library RequestsLibrary
4Library HttpLibrary.HTTP
5Library Collections
Tomasz Wrobel75573b02020-03-05 16:43:50 +01006Library ../libraries/CertClientManager.py
Aleksandra Maciaga6def5972020-02-20 09:42:03 +01007Resource ../../../common.robot
8Resource ./cert-service-properties.robot
9
10*** Keywords ***
11
12Create sessions
13 [Documentation] Create all required sessions
14 Create Session aaf_cert_service_url ${AAFCERT_URL}
15 Set Suite Variable ${http_session} aaf_cert_service_url
16
17Run Healthcheck
18 [Documentation] Run Healthcheck
19 ${resp}= Get Request ${http_session} /actuator/health
20 Should Be Equal As Strings ${resp.status_code} 200
21 Validate Recieved Response ${resp} status UP
22
Aleksandra Maciaga6def5972020-02-20 09:42:03 +010023Validate Recieved Response
24 [Documentation] Validare message that has been received
25 [Arguments] ${resp} ${key} ${expected_value}
26 ${json}= Parse Json ${resp.content}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010027 ${value}= Get From Dictionary ${json} ${key}
28 Should Be Equal As Strings ${value} ${expected_value}
29
30Send Get Request And Validate Response
31 [Documentation] Send request to passed url and validate received response
32 [Arguments] ${path} ${resp_code}
33 ${resp}= Get Request ${http_session} ${path}
34 Should Be Equal As Strings ${resp.status_code} ${resp_code}
35
Aleksandra Maciagaf6300682020-03-04 17:11:30 +010036Send Get Request with Header
37 [Documentation] Send request to passed url
38 [Arguments] ${path} ${csr_file} ${pk_file}
39 [Return] ${resp}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010040 ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file}
41 ${resp}= Get Request ${http_session} ${path} headers=${headers}
Aleksandra Maciagaf6300682020-03-04 17:11:30 +010042
43Send Get Request with Header And Expect Success
44 [Documentation] Send request to passed url and validate received response
45 [Arguments] ${path} ${csr_file} ${pk_file}
46 ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file}
47 Should Be Equal As Strings ${resp.status_code} 200
48 Check Message Recieved On Success ${resp.content}
49
50Check Message Recieved On Success
51 [Documentation] Check if correct messsage has been sent on successful request
52 [Arguments] ${content}
53 ${resp_content}= Parse Json ${content}
54 Dictionary Should Contain Key ${resp_content} certificateChain
55 @{list}= Get From Dictionary ${resp_content} certificateChain
56 List Should Contain Certificates @{list}
57 Dictionary Should Contain Key ${resp_content} trustedCertificates
58
59List Should Contain Certificates
60 [Documentation] Verify if list contains certificates
61 [Arguments] @{list}
62 :FOR ${content} IN @{list}
63 \ Should Contain ${content} BEGIN CERTIFICATE
64 \ Should Contain ${content} END CERTIFICATE
65
66Send Get Request with Header And Expect Error
67 [Documentation] Send request to passed url and validate received response
68 [Arguments] ${path} ${csr_file} ${pk_file} ${resp_code}
69 ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010070 Should Be Equal As Strings ${resp.status_code} ${resp_code}
71
72Create Header with CSR and PK
73 [Documentation] Create header with CSR and PK
74 [Arguments] ${csr_file} ${pk_file}
75 [Return] ${headers}
76 ${csr}= Get Data From File ${csr_file}
77 ${pk}= Get Data From File ${pk_file}
78 ${headers}= Create Dictionary CSR=${csr} PK=${pk}
79
80Send Post Request And Validate Response
81 [Documentation] Send request to passed url and validate received response
82 [Arguments] ${path} ${resp_code}
83 ${resp}= Post Request ${http_session} ${path}
84 Should Be Equal As Strings ${resp.status_code} ${resp_code}
Tomasz Wrobel75573b02020-03-05 16:43:50 +010085
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010086Run Cert Service Client And Validate JKS File Creation And Client Exit Code
Tomasz Wrobel75573b02020-03-05 16:43:50 +010087 [Documentation] Run Cert Service Client Container And Validate Exit Code
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010088 [Arguments] ${env_file} ${expected_exit_code}
kjaniak25fac3a2020-03-18 13:01:36 +010089 ${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 +010090 ${can_open}= Can Open Keystore And Truststore With Pass
Tomasz Wrobel6ed06d52020-03-11 15:31:10 +010091 Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} positive_path
92 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return: ${exitcode} exit code, but expected: ${expected_exit_code}
93 Should Be True ${can_open} Cannot Open Keystore/TrustStore by passpshase
94
95Run Cert Service Client And Validate Http Response Code And Client Exit Code
96 [Documentation] Run Cert Service Client Container And Validate Exit Code
97 [Arguments] ${env_file} ${expected_api_response_code} ${expected_exit_code}
kjaniak25fac3a2020-03-18 13:01:36 +010098 ${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 +010099 ${can_find_API_response}= Can Find Api Response In Logs ${CLIENT_CONTAINER_NAME}
100 ${api_response_code}= Get Api Response From Logs ${CLIENT_CONTAINER_NAME}
101 Remove Client Container And Save Logs ${CLIENT_CONTAINER_NAME} negative_path
102 Should Be True ${can_find_API_response} Cannot Find API response in logs
103 Should Be Equal As Strings ${api_response_code} ${expected_api_response_code} API return ${api_response_code} but expected: ${expected_api_response_code}
104 Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code}