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 |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 3 | Library RequestsLibrary |
| 4 | Library String |
Sylvain Desbureaux | 2e33ff6 | 2019-05-15 14:41:18 +0200 | [diff] [blame] | 5 | Library Collections |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 6 | Library SSHLibrary |
| 7 | Library OperatingSystem |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 8 | Library ONAPLibrary.Templating WITH NAME Templating |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 9 | Resource global_properties.robot |
DR695H | 910097e | 2019-05-08 13:55:32 -0400 | [diff] [blame] | 10 | Resource ssh/files.robot |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 11 | |
| 12 | *** Variables *** |
mrichomme | d7855e2 | 2020-04-07 17:03:46 +0200 | [diff] [blame] | 13 | ${POLICY_NEW_HEALTHCHECK_PATH} /policy/pap/v1/components/healthcheck |
mrichomme | 455d399 | 2020-04-03 14:56:40 +0200 | [diff] [blame] | 14 | ${POLICY_NEW_HEALTHCHECK_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_PAP_IP_ADDR}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
DR695H | 3440942 | 2019-06-20 10:56:46 -0400 | [diff] [blame] | 15 | ${POLICY_TEMPLATES} policy |
Bilal A | 461aa5b | 2019-05-06 14:00:57 -0400 | [diff] [blame] | 16 | ${POLICY_API_IP} ${GLOBAL_INJECTED_POLICY_API_IP_ADDR} |
| 17 | ${POLICY_PAP_IP} ${GLOBAL_INJECTED_POLICY_PAP_IP_ADDR} |
Bilal A | 461aa5b | 2019-05-06 14:00:57 -0400 | [diff] [blame] | 18 | ${POLICY_PDPX_IP} ${GLOBAL_INJECTED_POLICY_PDPX_IP_ADDR} |
Bilal A | 461aa5b | 2019-05-06 14:00:57 -0400 | [diff] [blame] | 19 | ${POLICY_HEALTHCHECK_USERNAME} ${GLOBAL_POLICY_HEALTHCHECK_USERNAME} |
| 20 | ${POLICY_HEALTHCHECK_PASSWORD} ${GLOBAL_POLICY_HEALTHCHECK_PASSWORD} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 21 | |
Brian Freeman | 88fbb99 | 2019-05-17 17:46:56 -0500 | [diff] [blame] | 22 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 23 | *** Keywords *** |
| 24 | |
| 25 | Run Policy Health Check |
Pamela Dragosh | 0adce51 | 2020-08-25 13:18:02 -0400 | [diff] [blame] | 26 | [Documentation] Runs Policy Health Check |
mrichomme | 455d399 | 2020-04-03 14:56:40 +0200 | [diff] [blame] | 27 | ${auth}= Create List ${GLOBAL_POLICY_HEALTHCHECK_USERNAME} ${GLOBAL_POLICY_HEALTHCHECK_PASSWORD} |
| 28 | Log Creating session ${POLICY_NEW_HEALTHCHECK_ENDPOINT} |
| 29 | ${session}= Create Session policy ${POLICY_NEW_HEALTHCHECK_ENDPOINT} auth=${auth} |
| 30 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
mrichomme | d7855e2 | 2020-04-07 17:03:46 +0200 | [diff] [blame] | 31 | ${resp}= Get Request policy ${POLICY_NEW_HEALTHCHECK_PATH} headers=${headers} |
mrichomme | 455d399 | 2020-04-03 14:56:40 +0200 | [diff] [blame] | 32 | Log Received response from policy ${resp.text} |
| 33 | Should Be Equal As Strings ${resp.status_code} 200 |
| 34 | Should Be True ${resp.json()['healthy']} |
| 35 | |
Brian Freeman | 55b96e2 | 2019-05-08 20:49:45 -0500 | [diff] [blame] | 36 | Run Policy Pap Get Request |
| 37 | [Documentation] Runs Policy Pap Get request |
| 38 | [Arguments] ${data_path} |
| 39 | ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD} |
| 40 | Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
Sylvain Desbureaux | 2e33ff6 | 2019-05-15 14:41:18 +0200 | [diff] [blame] | 41 | ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth} |
Brian Freeman | 55b96e2 | 2019-05-08 20:49:45 -0500 | [diff] [blame] | 42 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 43 | ${resp}= Get Request policy ${data_path} headers=${headers} |
| 44 | Log Received response from Policy Pap ${resp.text} |
| 45 | [Return] ${resp} |
| 46 | |
Brian Freeman | 55b96e2 | 2019-05-08 20:49:45 -0500 | [diff] [blame] | 47 | Run Policy Api Post Request |
| 48 | [Documentation] Runs Policy Api Post request |
| 49 | [Arguments] ${data_path} ${data} |
| 50 | ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD} |
Sylvain Desbureaux | 2e33ff6 | 2019-05-15 14:41:18 +0200 | [diff] [blame] | 51 | ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth} |
Brian Freeman | 55b96e2 | 2019-05-08 20:49:45 -0500 | [diff] [blame] | 52 | Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
| 53 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 54 | ${resp}= Post Request policy ${data_path} data=${data} headers=${headers} |
| 55 | Log Received response from policy ${resp.text} |
| 56 | [Return] ${resp} |
| 57 | |
Brian Freeman | 55b96e2 | 2019-05-08 20:49:45 -0500 | [diff] [blame] | 58 | Run Policy Pap Post Request |
| 59 | [Documentation] Runs Policy Pap Post request |
| 60 | [Arguments] ${data_path} ${data} |
| 61 | ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD} |
Sylvain Desbureaux | 2e33ff6 | 2019-05-15 14:41:18 +0200 | [diff] [blame] | 62 | ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth} |
Brian Freeman | 55b96e2 | 2019-05-08 20:49:45 -0500 | [diff] [blame] | 63 | Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
| 64 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 65 | ${resp}= Post Request policy ${data_path} data=${data} headers=${headers} |
| 66 | Log Received response from policy ${resp.text} |
| 67 | [Return] ${resp} |
| 68 | |
Brian Freeman | e6c3d28 | 2019-09-30 14:20:02 -0500 | [diff] [blame] | 69 | Undeploy Policy |
| 70 | [Documentation] Runs Policy PAP Undeploy a Policy from PDP Groups |
| 71 | [Arguments] ${policy_name} |
| 72 | ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD} |
| 73 | ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth} |
| 74 | Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
| 75 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 76 | ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/${policy_name} headers=${headers} |
| 77 | Log Received response from policy ${resp.text} |
| 78 | Should Be Equal As Strings ${resp.status_code} 200 |
| 79 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 80 | Update vVFWCL Policy |
Brian Freeman | 0d866b5 | 2019-05-08 20:30:14 -0500 | [diff] [blame] | 81 | [Arguments] ${resource_id} |
DR695H | 8e7028b | 2019-07-10 10:13:58 -0400 | [diff] [blame] | 82 | Log Create vFWCL Monitoring Policy |
Brian Freeman | bb58461 | 2020-05-05 09:07:15 -0500 | [diff] [blame] | 83 | Create vFirewall Monitoring Policy ${resource_id} |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 84 | Sleep 5s |
DR695H | 8e7028b | 2019-07-10 10:13:58 -0400 | [diff] [blame] | 85 | Log Create vFWCL Operational Policy |
Brian Freeman | 7594828 | 2019-05-14 20:44:46 -0500 | [diff] [blame] | 86 | ${op_policy_version}= Create vFirewall Operational Policy ${resource_id} |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 87 | Sleep 5s |
DR695H | 8e7028b | 2019-07-10 10:13:58 -0400 | [diff] [blame] | 88 | Log Push vFWCL To PDP Group |
Brian Freeman | 7594828 | 2019-05-14 20:44:46 -0500 | [diff] [blame] | 89 | Push vFirewall Policies To PDP Group ${op_policy_version} |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 90 | Sleep 20s |
DR695H | 8e7028b | 2019-07-10 10:13:58 -0400 | [diff] [blame] | 91 | Log Validate vFWCL Policy |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 92 | Validate the vFWCL Policy |
| 93 | |
Brian Freeman | 55b96e2 | 2019-05-08 20:49:45 -0500 | [diff] [blame] | 94 | Validate the vFWCL Policy |
| 95 | ${resp}= Run Policy Pap Get Request /policy/pap/v1/pdps |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 96 | Log Received response from policy ${resp.text} |
| 97 | Should Be Equal As Strings ${resp.status_code} 200 |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 98 | |
| 99 | Create vFirewall Monitoring Policy |
Brian Freeman | bb58461 | 2020-05-05 09:07:15 -0500 | [diff] [blame] | 100 | [Arguments] ${resource_id} |
| 101 | ${dict}= Create Dictionary RESOURCE_ID=${resource_id} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 102 | Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER} |
| 103 | ${data}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_policy_monitoring_input_tosca.jinja ${dict} |
Pamela Dragosh | 0adce51 | 2020-08-25 13:18:02 -0400 | [diff] [blame] | 104 | ${resp}= Run Policy Api Post Request /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies ${data} |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 105 | Should Be Equal As Strings ${resp.status_code} 200 |
| 106 | |
Brian Freeman | 88fbb99 | 2019-05-17 17:46:56 -0500 | [diff] [blame] | 107 | Create vFirewall Operational Policy |
DR695H | 3440942 | 2019-06-20 10:56:46 -0400 | [diff] [blame] | 108 | [Arguments] ${resource_id} |
| 109 | ${dict}= Create Dictionary RESOURCE_ID=${resource_id} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 110 | Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER} |
Brian Freeman | df0ca46 | 2020-05-06 15:10:06 -0500 | [diff] [blame] | 111 | ${data_2}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_policy_operational_content_input.jinja ${dict} |
DR695H | 8e7028b | 2019-07-10 10:13:58 -0400 | [diff] [blame] | 112 | Log ${data_2} |
Brian Freeman | df0ca46 | 2020-05-06 15:10:06 -0500 | [diff] [blame] | 113 | ${resp}= Run Policy Api Post Request /policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies ${data_2} |
DR695H | 3440942 | 2019-06-20 10:56:46 -0400 | [diff] [blame] | 114 | Should Be Equal As Strings ${resp.status_code} 200 |
Brian Freeman | df0ca46 | 2020-05-06 15:10:06 -0500 | [diff] [blame] | 115 | [Return] ${resp.json()['version']} |
Brian Freeman | 88fbb99 | 2019-05-17 17:46:56 -0500 | [diff] [blame] | 116 | |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 117 | Push vFirewall Policies To PDP Group |
DR695H | 3440942 | 2019-06-20 10:56:46 -0400 | [diff] [blame] | 118 | [Arguments] ${op_policy_version} |
| 119 | ${dict}= Create Dictionary OP_POLICY_VERSION=${op_policy_version} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 120 | Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER} |
| 121 | ${data}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_push.jinja ${dict} |
DR695H | 3440942 | 2019-06-20 10:56:46 -0400 | [diff] [blame] | 122 | ${resp}= Run Policy Pap Post Request /policy/pap/v1/pdps/policies ${data} |
| 123 | Should Be Equal As Strings ${resp.status_code} 200 |