blob: 5f25f0b0aacdd4011cea0d9647b89181421ca02a [file] [log] [blame]
Aleksandra Maciaga6def5972020-02-20 09:42:03 +01001*** Settings ***
2
3Library RequestsLibrary
4Library HttpLibrary.HTTP
5Library Collections
6Resource ../../../common.robot
7Resource ./cert-service-properties.robot
8
9*** Keywords ***
10
11Create 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
16Run 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 Maciaga6def5972020-02-20 09:42:03 +010022Validate Recieved Response
23 [Documentation] Validare message that has been received
24 [Arguments] ${resp} ${key} ${expected_value}
25 ${json}= Parse Json ${resp.content}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010026 ${value}= Get From Dictionary ${json} ${key}
27 Should Be Equal As Strings ${value} ${expected_value}
28
29Send 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 Maciagaf6300682020-03-04 17:11:30 +010035Send Get Request with Header
36 [Documentation] Send request to passed url
37 [Arguments] ${path} ${csr_file} ${pk_file}
38 [Return] ${resp}
Aleksandra Maciaga8d762b12020-02-24 14:24:42 +010039 ${headers}= Create Header with CSR and PK ${csr_file} ${pk_file}
40 ${resp}= Get Request ${http_session} ${path} headers=${headers}
Aleksandra Maciagaf6300682020-03-04 17:11:30 +010041
42Send 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
49Check 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
58List 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
65Send 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 Maciaga8d762b12020-02-24 14:24:42 +010069 Should Be Equal As Strings ${resp.status_code} ${resp_code}
70
71Create 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
79Send 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}