3 Library RequestsLibrary
4 Library HttpLibrary.HTTP
6 Library ../libraries/CertClientManager.py
7 Resource ../../../common.robot
8 Resource ./cert-service-properties.robot
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
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
23 Validate Recieved Response
24 [Documentation] Validare message that has been received
25 [Arguments] ${resp} ${key} ${expected_value}
26 ${json}= Parse Json ${resp.content}
27 ${value}= Get From Dictionary ${json} ${key}
28 Should Be Equal As Strings ${value} ${expected_value}
30 Send 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}
36 Send Get Request with Header
37 [Documentation] Send request to passed url
38 [Arguments] ${path} ${csr_file} ${pk_file}
40 ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file}
41 ${resp}= Get Request ${http_session} ${path} headers=${headers}
43 Send 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}
50 Check 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
59 List Should Contain Certificates
60 [Documentation] Verify if list contains certificates
62 :FOR ${content} IN @{list}
63 \ Should Contain ${content} BEGIN CERTIFICATE
64 \ Should Contain ${content} END CERTIFICATE
66 Send 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}
70 Should Be Equal As Strings ${resp.status_code} ${resp_code}
72 Create Header with CSR and PK
73 [Documentation] Create header with CSR and PK
74 [Arguments] ${csr_file} ${pk_file}
76 ${csr}= Get Data From File ${csr_file}
77 ${pk}= Get Data From File ${pk_file}
78 ${headers}= Create Dictionary CSR=${csr} PK=${pk}
80 Send 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}
86 Run Cert Service Client And Validate JKS File Creation And Client Exit Code
87 [Documentation] Run Cert Service Client Container And Validate Exit Code
88 [Arguments] ${env_file} ${expected_exit_code}
89 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
90 ${can_open}= Can Open Keystore And Truststore With Pass ${CLIENT_CONTAINER_NAME}
91 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
95 Run 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}
98 ${exit_code}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_SERVICE_ADDRESS}${CERT_SERVICE_ENDPOINT} ${CERT_SERVICE_NETWORK}
99 ${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}