blob: 791787081cb28d5d75313cfcf3d87603704fcac0 [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
3Library eteutils/RequestsClientCert.py
4#Library RequestsClientCert
5Library RequestsLibrary
6Library String
7Library eteutils/JSONUtils.py
8#Library JSONUtils
9Library Collections
10Resource global_properties.robot
11
12*** Variables ***
13${POLICY_HEALTH_CHECK_PATH} /healthcheck
14
15*** Keywords ***
16
17Run Policy Health Check
18 [Documentation] Runs Policy Health check
19 ${auth}= Create List ${GLOBAL_POLICY_USERNAME} ${GLOBAL_POLICY_PASSWORD}
20 Log Creating session ${GLOBAL_POLICY_SERVER_URL}
21 ${session}= Create Session policy ${GLOBAL_POLICY_HEALTHCHECK_URL} auth=${auth}
22 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
23 ${resp}= Get Request policy ${POLICY_HEALTH_CHECK_PATH} headers=${headers}
24 Log Received response from policy ${resp.text}
25 Should Be Equal As Strings ${resp.status_code} 200
26 Should Be True ${resp.json()['healthy']}
27 @{ITEMS}= Copy List ${resp.json()['details']}
28 :FOR ${ELEMENT} IN @{ITEMS}
29 \ Should Be Equal As Strings ${ELEMENT['code']} 200
30 \ Should Be True ${ELEMENT['healthy']}
31
32Run Policy Put Request
33 [Documentation] Runs Policy Put request
34 [Arguments] ${data_path} ${data}
35 Log Creating session ${GLOBAL_POLICY_SERVER_URL}
36 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_URL}
37 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST
38 ${resp}= Put Request policy ${data_path} data=${data} headers=${headers}
39 Log Received response from policy ${resp.text}
40 [Return] ${resp}
41
42Run Policy Delete Request
43 [Documentation] Runs Policy Delete request
44 [Arguments] ${data_path} ${data}
45 Log Creating session ${GLOBAL_POLICY_SERVER_URL}
46 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_URL}
47 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST
48 ${resp}= Delete Request policy ${data_path} data=${data} headers=${headers}
49 Log Received response from policy ${resp.text}
50 [Return] ${resp}
51
52Run Policy Get Configs Request
53 [Documentation] Runs Policy Get Configs request
54 [Arguments] ${data_path} ${data}
55 Log Creating session ${GLOBAL_POLICY_SERVER_URL}
56 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_URL}
57 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH}
58 ${resp}= Post Request policy ${data_path} data=${data} headers=${headers}
59 Log Received response from policy ${resp.text}
60 [Return] ${resp}