Aleksandra Maciaga | 6def597 | 2020-02-20 09:42:03 +0100 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Library RequestsLibrary |
| 4 | Library HttpLibrary.HTTP |
| 5 | Library Collections |
Tomasz Wrobel | 75573b0 | 2020-03-05 16:43:50 +0100 | [diff] [blame^] | 6 | Library ../libraries/CertClientManager.py |
Aleksandra Maciaga | 6def597 | 2020-02-20 09:42:03 +0100 | [diff] [blame] | 7 | Resource ../../../common.robot |
| 8 | Resource ./cert-service-properties.robot |
| 9 | |
| 10 | *** Keywords *** |
| 11 | |
| 12 | Create 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 | |
| 17 | Run 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 Maciaga | 6def597 | 2020-02-20 09:42:03 +0100 | [diff] [blame] | 23 | Validate Recieved Response |
| 24 | [Documentation] Validare message that has been received |
| 25 | [Arguments] ${resp} ${key} ${expected_value} |
| 26 | ${json}= Parse Json ${resp.content} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 27 | ${value}= Get From Dictionary ${json} ${key} |
| 28 | Should Be Equal As Strings ${value} ${expected_value} |
| 29 | |
| 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} |
| 35 | |
Aleksandra Maciaga | f630068 | 2020-03-04 17:11:30 +0100 | [diff] [blame] | 36 | Send Get Request with Header |
| 37 | [Documentation] Send request to passed url |
| 38 | [Arguments] ${path} ${csr_file} ${pk_file} |
| 39 | [Return] ${resp} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 40 | ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file} |
| 41 | ${resp}= Get Request ${http_session} ${path} headers=${headers} |
Aleksandra Maciaga | f630068 | 2020-03-04 17:11:30 +0100 | [diff] [blame] | 42 | |
| 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} |
| 49 | |
| 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 |
| 58 | |
| 59 | List 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 | |
| 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} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 70 | Should Be Equal As Strings ${resp.status_code} ${resp_code} |
| 71 | |
| 72 | Create 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 | |
| 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} |
Tomasz Wrobel | 75573b0 | 2020-03-05 16:43:50 +0100 | [diff] [blame^] | 85 | |
| 86 | Run Cert Service Client Container And Validate Exit Code |
| 87 | [Documentation] Run Cert Service Client Container And Validate Exit Code |
| 88 | [Arguments] ${env_file} ${expected_code} |
| 89 | ${exitcode}= Run Client Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${env_file} ${CERT_ADDRESS} ${CERT_SERVICE_NETWORK} |
| 90 | Remove Client Container ${CLIENT_CONTAINER_NAME} |
| 91 | Should Be Equal As Strings ${exitcode} ${expected_code} |