DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [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 RequestsClientCert |
| 4 | Library RequestsLibrary |
| 5 | Library String |
| 6 | Library JSONUtils |
| 7 | Library Collections |
| 8 | Resource global_properties.robot |
| 9 | |
| 10 | *** Variables *** |
| 11 | ${POLICY_HEALTH_CHECK_PATH} /healthcheck |
| 12 | |
| 13 | *** Keywords *** |
| 14 | |
| 15 | Run 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 | |
| 30 | Run 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 | |
| 40 | Run 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 | |
| 50 | Run 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} |