blob: a8315e7f1e5f54a7b78993eb025cd4753cc3cf87 [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
86Run 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}