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