blob: da7fdd87048a5efeb45a629723c55a7165f34139 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** Settings ***
2Documentation The main interface for interacting with Policy. It handles low level stuff like managing the http request library and Policy required fields
Gary Wu9abb61c2018-09-27 10:38:50 -07003Library RequestsLibrary
4Library String
Gary Wu9abb61c2018-09-27 10:38:50 -07005Library Collections
6Resource global_properties.robot
7
8*** Variables ***
9${POLICY_HEALTH_CHECK_PATH} /healthcheck
10
11*** Keywords ***
12
13Run Policy Health Check
14 [Documentation] Runs Policy Health check
15 ${auth}= Create List ${GLOBAL_POLICY_USERNAME} ${GLOBAL_POLICY_PASSWORD}
16 Log Creating session ${GLOBAL_POLICY_SERVER_URL}
17 ${session}= Create Session policy ${GLOBAL_POLICY_HEALTHCHECK_URL} auth=${auth}
18 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
19 ${resp}= Get Request policy ${POLICY_HEALTH_CHECK_PATH} headers=${headers}
20 Log Received response from policy ${resp.text}
21 Should Be Equal As Strings ${resp.status_code} 200
22 Should Be True ${resp.json()['healthy']}
23 @{ITEMS}= Copy List ${resp.json()['details']}
24 :FOR ${ELEMENT} IN @{ITEMS}
25 \ Should Be Equal As Strings ${ELEMENT['code']} 200
26 \ Should Be True ${ELEMENT['healthy']}
27
28Run Policy Put Request
29 [Documentation] Runs Policy Put request
30 [Arguments] ${data_path} ${data}
31 Log Creating session ${GLOBAL_POLICY_SERVER_URL}
32 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_URL}
33 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST
34 ${resp}= Put Request policy ${data_path} data=${data} headers=${headers}
35 Log Received response from policy ${resp.text}
36 [Return] ${resp}
HOCKLA3e332f42019-02-20 09:32:19 -060037
38Run Policy Post Request
39 [Documentation] Runs Policy Post request
40 [Arguments] ${data_path} ${data}
41 Log Creating session ${GLOBAL_POLICY_SERVER_URL}
42 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_URL}
43 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST
44 ${resp}= Post Request policy ${data_path} data=${data} headers=${headers}
45 Log Received response from policy ${resp.text}
46 [Return] ${resp}
47
Gary Wu9abb61c2018-09-27 10:38:50 -070048Run Policy Delete Request
49 [Documentation] Runs Policy Delete request
50 [Arguments] ${data_path} ${data}
51 Log Creating session ${GLOBAL_POLICY_SERVER_URL}
52 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_URL}
53 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST
54 ${resp}= Delete Request policy ${data_path} data=${data} headers=${headers}
55 Log Received response from policy ${resp.text}
56 [Return] ${resp}
57
58Run Policy Get Configs Request
59 [Documentation] Runs Policy Get Configs request
60 [Arguments] ${data_path} ${data}
61 Log Creating session ${GLOBAL_POLICY_SERVER_URL}
62 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_URL}
63 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH}
64 ${resp}= Post Request policy ${data_path} data=${data} headers=${headers}
65 Log Received response from policy ${resp.text}
HOCKLA3e332f42019-02-20 09:32:19 -060066 [Return] ${resp}