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 |
| 6 | Resource ../../../common.robot |
| 7 | Resource ./cert-service-properties.robot |
| 8 | |
| 9 | *** Keywords *** |
| 10 | |
| 11 | Create sessions |
| 12 | [Documentation] Create all required sessions |
| 13 | Create Session aaf_cert_service_url ${AAFCERT_URL} |
| 14 | Set Suite Variable ${http_session} aaf_cert_service_url |
| 15 | |
| 16 | Run Healthcheck |
| 17 | [Documentation] Run Healthcheck |
| 18 | ${resp}= Get Request ${http_session} /actuator/health |
| 19 | Should Be Equal As Strings ${resp.status_code} 200 |
| 20 | Validate Recieved Response ${resp} status UP |
| 21 | |
Aleksandra Maciaga | 6def597 | 2020-02-20 09:42:03 +0100 | [diff] [blame] | 22 | Validate Recieved Response |
| 23 | [Documentation] Validare message that has been received |
| 24 | [Arguments] ${resp} ${key} ${expected_value} |
| 25 | ${json}= Parse Json ${resp.content} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 26 | ${value}= Get From Dictionary ${json} ${key} |
| 27 | Should Be Equal As Strings ${value} ${expected_value} |
| 28 | |
| 29 | Send Get Request And Validate Response |
| 30 | [Documentation] Send request to passed url and validate received response |
| 31 | [Arguments] ${path} ${resp_code} |
| 32 | ${resp}= Get Request ${http_session} ${path} |
| 33 | Should Be Equal As Strings ${resp.status_code} ${resp_code} |
| 34 | |
Aleksandra Maciaga | f630068 | 2020-03-04 17:11:30 +0100 | [diff] [blame^] | 35 | Send Get Request with Header |
| 36 | [Documentation] Send request to passed url |
| 37 | [Arguments] ${path} ${csr_file} ${pk_file} |
| 38 | [Return] ${resp} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 39 | ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file} |
| 40 | ${resp}= Get Request ${http_session} ${path} headers=${headers} |
Aleksandra Maciaga | f630068 | 2020-03-04 17:11:30 +0100 | [diff] [blame^] | 41 | |
| 42 | Send Get Request with Header And Expect Success |
| 43 | [Documentation] Send request to passed url and validate received response |
| 44 | [Arguments] ${path} ${csr_file} ${pk_file} |
| 45 | ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file} |
| 46 | Should Be Equal As Strings ${resp.status_code} 200 |
| 47 | Check Message Recieved On Success ${resp.content} |
| 48 | |
| 49 | Check Message Recieved On Success |
| 50 | [Documentation] Check if correct messsage has been sent on successful request |
| 51 | [Arguments] ${content} |
| 52 | ${resp_content}= Parse Json ${content} |
| 53 | Dictionary Should Contain Key ${resp_content} certificateChain |
| 54 | @{list}= Get From Dictionary ${resp_content} certificateChain |
| 55 | List Should Contain Certificates @{list} |
| 56 | Dictionary Should Contain Key ${resp_content} trustedCertificates |
| 57 | |
| 58 | List Should Contain Certificates |
| 59 | [Documentation] Verify if list contains certificates |
| 60 | [Arguments] @{list} |
| 61 | :FOR ${content} IN @{list} |
| 62 | \ Should Contain ${content} BEGIN CERTIFICATE |
| 63 | \ Should Contain ${content} END CERTIFICATE |
| 64 | |
| 65 | Send Get Request with Header And Expect Error |
| 66 | [Documentation] Send request to passed url and validate received response |
| 67 | [Arguments] ${path} ${csr_file} ${pk_file} ${resp_code} |
| 68 | ${resp}= Send Get Request with Header ${path} ${csr_file} ${pk_file} |
Aleksandra Maciaga | 8d762b1 | 2020-02-24 14:24:42 +0100 | [diff] [blame] | 69 | Should Be Equal As Strings ${resp.status_code} ${resp_code} |
| 70 | |
| 71 | Create Header with CSR and PK |
| 72 | [Documentation] Create header with CSR and PK |
| 73 | [Arguments] ${csr_file} ${pk_file} |
| 74 | [Return] ${headers} |
| 75 | ${csr}= Get Data From File ${csr_file} |
| 76 | ${pk}= Get Data From File ${pk_file} |
| 77 | ${headers}= Create Dictionary CSR=${csr} PK=${pk} |
| 78 | |
| 79 | Send Post Request And Validate Response |
| 80 | [Documentation] Send request to passed url and validate received response |
| 81 | [Arguments] ${path} ${resp_code} |
| 82 | ${resp}= Post Request ${http_session} ${path} |
| 83 | Should Be Equal As Strings ${resp.status_code} ${resp_code} |