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 |
| 3 | Library eteutils/RequestsClientCert.py |
| 4 | #Library RequestsClientCert |
| 5 | Library RequestsLibrary |
| 6 | Library String |
| 7 | Library eteutils/JSONUtils.py |
| 8 | #Library JSONUtils |
| 9 | Library Collections |
| 10 | Resource global_properties.robot |
| 11 | |
| 12 | *** Variables *** |
| 13 | ${POLICY_HEALTH_CHECK_PATH} /healthcheck |
| 14 | |
| 15 | *** Keywords *** |
| 16 | |
| 17 | Run 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 | |
| 32 | Run 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 | |
| 42 | Run 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 | |
| 52 | Run 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} |