Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation The main interface for interacting with Policy. It handles low level stuff like managing the http request library and Policy required fields |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 3 | Library RequestsLibrary |
| 4 | Library String |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 5 | Library Collections |
| 6 | Resource global_properties.robot |
| 7 | |
| 8 | *** Variables *** |
| 9 | ${POLICY_HEALTH_CHECK_PATH} /healthcheck |
| 10 | |
| 11 | *** Keywords *** |
| 12 | |
| 13 | Run 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 | |
| 28 | Run 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} |
HOCKLA | 3e332f4 | 2019-02-20 09:32:19 -0600 | [diff] [blame] | 37 | |
| 38 | Run 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 Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 48 | Run 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 | |
| 58 | Run 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} |
HOCKLA | 3e332f4 | 2019-02-20 09:32:19 -0600 | [diff] [blame] | 66 | [Return] ${resp} |