blob: a622ae6ca5f94a4f20ad67a358c6ed3e79a17c4f [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
DR695Hbf5a3a32017-06-30 13:09:57 -040012${POLICY_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_POLICY_SERVER_PORT}
13${POLICY_HEALTHCHECK_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
DR695Hccff30b2017-02-17 18:44:24 -050014
15*** Keywords ***
16
17Run Policy Health Check
18 [Documentation] Runs Policy Health check
19 ${auth}= Create List ${GLOBAL_POLICY_USERNAME} ${GLOBAL_POLICY_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040020 Log Creating session ${POLICY_ENDPOINT}
21 ${session}= Create Session policy ${POLICY_HEALTHCHECK_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050022 ${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}
DR695Hbf5a3a32017-06-30 13:09:57 -040035 Log Creating session ${POLICY_ENDPOINT}
36 ${session}= Create Session policy ${POLICY_ENDPOINT}
DR695Hccff30b2017-02-17 18:44:24 -050037 ${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}
DR695Hbf5a3a32017-06-30 13:09:57 -040045 Log Creating session ${POLICY_ENDPOINT}
46 ${session}= Create Session policy ${POLICY_ENDPOINT}
DR695Hccff30b2017-02-17 18:44:24 -050047 ${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}
DR695Hbf5a3a32017-06-30 13:09:57 -040055 Log Creating session ${POLICY_ENDPOINT}
56 ${session}= Create Session policy ${POLICY_ENDPOINT}
DR695Hccff30b2017-02-17 18:44:24 -050057 ${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}