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 |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 12 | ${POLICY_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_POLICY_SERVER_PORT} |
Gary Wu | 251aa68 | 2018-07-30 15:22:20 -0700 | [diff] [blame] | 13 | ${POLICY_HEALTHCHECK_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_HEALTHCHECK_IP_ADDR}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
Brian Freeman | ca5e32e | 2018-07-23 12:47:21 -0500 | [diff] [blame] | 14 | ${POLICY_TEMPLATES} robot/assets/templates/policy |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 15 | ${DROOLS_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_DROOLS_SERVER_PORT} |
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} |
| 18 | ${POLICY_DISTRIBUTION_IP} ${GLOBAL_INJECTED_POLICY_DISTRIBUTION_IP_ADDR} |
| 19 | ${POLICY_PDPX_IP} ${GLOBAL_INJECTED_POLICY_PDPX_IP_ADDR} |
| 20 | ${POLICY_APEX_PDP_IP} ${GLOBAL_INJECTED_POLICY_APEX_PDP_IP_ADDR} |
| 21 | ${POLICY_HEALTHCHECK_USERNAME} ${GLOBAL_POLICY_HEALTHCHECK_USERNAME} |
| 22 | ${POLICY_HEALTHCHECK_PASSWORD} ${GLOBAL_POLICY_HEALTHCHECK_PASSWORD} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 23 | |
| 24 | *** Keywords *** |
| 25 | |
| 26 | Run Policy Health Check |
| 27 | [Documentation] Runs Policy Health check |
| 28 | ${auth}= Create List ${GLOBAL_POLICY_USERNAME} ${GLOBAL_POLICY_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 29 | Log Creating session ${POLICY_ENDPOINT} |
| 30 | ${session}= Create Session policy ${POLICY_HEALTHCHECK_ENDPOINT} auth=${auth} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 31 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 32 | ${resp}= Get Request policy ${POLICY_HEALTH_CHECK_PATH} headers=${headers} |
| 33 | Log Received response from policy ${resp.text} |
| 34 | Should Be Equal As Strings ${resp.status_code} 200 |
| 35 | Should Be True ${resp.json()['healthy']} |
| 36 | @{ITEMS}= Copy List ${resp.json()['details']} |
| 37 | :FOR ${ELEMENT} IN @{ITEMS} |
| 38 | \ Should Be Equal As Strings ${ELEMENT['code']} 200 |
| 39 | \ Should Be True ${ELEMENT['healthy']} |
| 40 | |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 41 | Run Drools Get Request |
| 42 | [Documentation] Runs Drools Get Request |
| 43 | [Arguments] ${data_path} |
| 44 | ${auth}= Create List ${GLOBAL_DROOLS_USERNAME} ${GLOBAL_DROOLS_PASSWORD} |
| 45 | Log Creating session ${POLICY_ENDPOINT} |
| 46 | ${session}= Create Session policy ${DROOLS_ENDPOINT} auth=${auth} |
| 47 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 48 | ${resp}= Get Request policy ${data_path} headers=${headers} |
| 49 | Log Received response from policy ${resp.text} |
| 50 | Should Be Equal As Strings ${resp.status_code} 200 |
| 51 | [Return] ${resp} |
| 52 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 53 | Run Policy Put Request |
| 54 | [Documentation] Runs Policy Put request |
| 55 | [Arguments] ${data_path} ${data} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 56 | Log Creating session ${POLICY_ENDPOINT} |
| 57 | ${session}= Create Session policy ${POLICY_ENDPOINT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 58 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST |
| 59 | ${resp}= Put Request policy ${data_path} data=${data} headers=${headers} |
| 60 | Log Received response from policy ${resp.text} |
| 61 | [Return] ${resp} |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 62 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 63 | Run Policy Get Request |
| 64 | [Documentation] Runs Policy Get request |
| 65 | [Arguments] ${data_path} |
| 66 | Log Creating session ${POLICY_ENDPOINT} |
| 67 | ${session}= Create Session policy ${POLICY_ENDPOINT} |
| 68 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST |
| 69 | ${resp}= Get Request policy ${data_path} headers=${headers} |
| 70 | Log Received response from policy ${resp.text} |
| 71 | |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 72 | Run Policy Post Request |
| 73 | [Documentation] Runs Policy Post request |
| 74 | [Arguments] ${data_path} ${data} |
| 75 | Log Creating session ${POLICY_ENDPOINT} |
| 76 | ${session}= Create Session policy ${POLICY_ENDPOINT} |
| 77 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST |
| 78 | ${resp}= Post Request policy ${data_path} data=${data} headers=${headers} |
| 79 | Log Received response from policy ${resp.text} |
| 80 | [Return] ${resp} |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 81 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 82 | Run Policy Delete Request |
| 83 | [Documentation] Runs Policy Delete request |
| 84 | [Arguments] ${data_path} ${data} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 85 | Log Creating session ${POLICY_ENDPOINT} |
| 86 | ${session}= Create Session policy ${POLICY_ENDPOINT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 87 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST |
| 88 | ${resp}= Delete Request policy ${data_path} data=${data} headers=${headers} |
| 89 | Log Received response from policy ${resp.text} |
| 90 | [Return] ${resp} |
| 91 | |
| 92 | Run Policy Get Configs Request |
| 93 | [Documentation] Runs Policy Get Configs request |
| 94 | [Arguments] ${data_path} ${data} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 95 | Log Creating session ${POLICY_ENDPOINT} |
| 96 | ${session}= Create Session policy ${POLICY_ENDPOINT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 97 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} |
| 98 | ${resp}= Post Request policy ${data_path} data=${data} headers=${headers} |
| 99 | Log Received response from policy ${resp.text} |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 100 | [Return] ${resp} |
| 101 | |
| 102 | |
| 103 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 104 | Update vVFWCL Policy Old |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 105 | [Arguments] ${resource_id} |
Brian Freeman | ca5e32e | 2018-07-23 12:47:21 -0500 | [diff] [blame] | 106 | Run Keyword and Ignore Error Delete vFWCL Policy |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 107 | Sleep 20s |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 108 | Log To Console Create vFWCL Policy |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 109 | Create vFWCL Policy ${resource_id} |
| 110 | Sleep 5s |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 111 | Log To Console Push vFWCL Policy |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 112 | Push vFWCL Policy |
| 113 | Sleep 20s |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 114 | Log To Console Reboot Drools |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 115 | Reboot Drools |
| 116 | Sleep 20s |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 117 | Log To Console Validate vFWCL Policy |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 118 | Validate the vFWCL Policy Old |
| 119 | |
| 120 | Update vVFWCL Policy |
Brian Freeman | 0d866b5 | 2019-05-08 20:30:14 -0500 | [diff] [blame^] | 121 | [Arguments] ${resource_id} |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 122 | Log To Console Create vFWCL Monitoring Policy |
| 123 | Create vFirewall Monitoring Policy |
| 124 | Sleep 5s |
| 125 | Log To Console Create vFWCL Operational Policy |
| 126 | Create vFirewall Operational Policy ${resource_id} |
| 127 | Sleep 5s |
| 128 | Log To Console Push vFWCL To PDP Group |
| 129 | Push vFirewall Policies To PDP Group |
| 130 | Sleep 20s |
| 131 | Log To Console Validate vFWCL Policy |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 132 | Validate the vFWCL Policy |
| 133 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 134 | |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 135 | Delete vFWCL Policy |
| 136 | ${data}= OperatingSystem.Get File ${POLICY_TEMPLATES}/FirewallPolicy_delete.template |
| 137 | ${resp}= Run Policy Delete Request /pdp/api/deletePolicy ${data} |
| 138 | Should Be Equal As Strings ${resp.status_code} 200 |
| 139 | |
| 140 | Create vFWCL Policy |
| 141 | [Arguments] ${resource_id} |
| 142 | ${dict}= Create Dictionary RESOURCE_ID=${resource_id} |
| 143 | ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/FirewallPolicy_update.template ${dict} |
| 144 | ${resp}= Run Policy Put Request /pdp/api/updatePolicy ${data} |
| 145 | Should Be Equal As Strings ${resp.status_code} 200 |
| 146 | |
| 147 | Push vFWCL Policy |
| 148 | ${dict}= Create Dictionary |
| 149 | ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/FirewallPolicy_push.template ${dict} |
| 150 | ${resp}= Run Policy Put Request /pdp/api/pushPolicy ${data} |
| 151 | Should Be Equal As Strings ${resp.status_code} 200 |
| 152 | |
| 153 | Reboot Drools |
| 154 | ${stop}= Catenate docker exec -t -u policy drools bash -c "source /opt/app/policy/etc/profile.d/env.sh; policy stop" |
| 155 | ${start}= Catenate docker exec -t -u policy drools bash -c "source /opt/app/policy/etc/profile.d/env.sh; policy start" |
| 156 | Wait Until Keyword Succeeds 120 5 sec Open Connection And Log In ${GLOBAL_INJECTED_POLICY_IP_ADDR} root ${GLOBAL_VM_PRIVATE_KEY} |
| 157 | Write ${stop} |
| 158 | ${status} ${stdout}= Run Keyword And Ignore Error SSHLibrary.Read Until Regexp has stopped |
| 159 | Log ${status}: stdout=${stdout} |
| 160 | ${ctrlc}= Evaluate '\x03' |
| 161 | Run Keyword If '${status}' == 'FAIL' Write ${ctrlc} |
| 162 | Sleep 5s |
| 163 | Write ${start} |
| 164 | ${stdout}= SSHLibrary.Read Until Regexp is running |
| 165 | Log stdout=${stdout} |
| 166 | Should Contain ${stdout} is running |
| 167 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 168 | Validate the vFWCL Policy Old |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 169 | ${resp}= Run Drools Get Request /policy/pdp/engine/controllers/amsterdam/drools |
| 170 | Should Be Equal As Strings ${resp.status_code} 200 |
| 171 | ${resp}= Run Drools Get Request /policy/pdp/engine/controllers/amsterdam/drools/facts/closedloop-amsterdam/org.onap.policy.controlloop.Params |
| 172 | Should Be Equal As Strings ${resp.status_code} 200 |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 173 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame] | 174 | Validate the vFWCL Policy |
| 175 | ${resp}= Run Policy Get Request /policy/pap/v1/pdps |
| 176 | Log Received response from policy ${resp.text} |
| 177 | Should Be Equal As Strings ${resp.status_code} 200 |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 178 | |
| 179 | Create vFirewall Monitoring Policy |
| 180 | ${dict}= Create Dictionary |
| 181 | ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/vFirewall_policy_monitoring_input_tosca.template ${dict} |
| 182 | ${resp}= Run Policy Post Request /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies ${data} |
| 183 | Should Be Equal As Strings ${resp.status_code} 200 |
| 184 | |
| 185 | |
| 186 | Create vFirewall Operational Policy |
| 187 | [Arguments] ${resource_id} |
| 188 | ${dict}= Create Dictionary RESOURCE_ID=${resource_id} |
| 189 | ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/vFirewall_policy_operational_input.template ${dict} |
| 190 | ${resp}= Run Policy Post Request /policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies ${data} |
| 191 | Should Be Equal As Strings ${resp.status_code} 200 |
| 192 | |
| 193 | |
| 194 | Push vFirewall Policies To PDP Group |
| 195 | ${dict}= Create Dictionary |
| 196 | ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/vFirewall_push.template ${dict} |
| 197 | ${resp}= Run Policy Post Request /policy/pap/v1/pdps/policies ${data} |
| 198 | Should Be Equal As Strings ${resp.status_code} 200 |
| 199 | |
Bilal A | 461aa5b | 2019-05-06 14:00:57 -0400 | [diff] [blame] | 200 | Run Policy API Healthcheck |
| 201 | [Documentation] Runs Policy Api Health check |
| 202 | ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD} |
| 203 | Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
| 204 | ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth} |
| 205 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 206 | ${resp}= Get Request policy /policy/api/v1/healthcheck headers=${headers} |
| 207 | Log Received response from policy ${resp.text} |
| 208 | Should Be Equal As Strings ${resp.status_code} 200 |
| 209 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 210 | |
| 211 | Run Policy PAP Healthcheck |
| 212 | [Documentation] Runs Policy PAP Health check |
| 213 | ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD} |
| 214 | Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
| 215 | ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth} |
| 216 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 217 | ${resp}= Get Request policy /policy/pap/v1/healthcheck headers=${headers} |
| 218 | Log Received response from policy ${resp.text} |
| 219 | Should Be Equal As Strings ${resp.status_code} 200 |
| 220 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 221 | |
| 222 | Run Policy Distribution Healthcheck |
| 223 | [Documentation] Runs Policy Distribution Health check |
| 224 | ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD} |
| 225 | Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_DISTRIBUTION_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
| 226 | ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_DISTRIBUTION_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth} |
| 227 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 228 | ${resp}= Get Request policy /healthcheck headers=${headers} |
| 229 | Log Received response from policy ${resp.text} |
| 230 | Should Be Equal As Strings ${resp.status_code} 200 |
| 231 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 232 | |
| 233 | Run Policy XACML PDP Healthcheck |
| 234 | [Documentation] Runs Policy Xacml PDP Health check |
| 235 | ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD} |
| 236 | Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PDPX_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
| 237 | ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PDPX_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth} |
| 238 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 239 | ${resp}= Get Request policy /policy/pdpx/v1/healthcheck headers=${headers} |
| 240 | Log Received response from policy ${resp.text} |
| 241 | Should Be Equal As Strings ${resp.status_code} 200 |
| 242 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 243 | |
| 244 | Run Policy APEX PDP Healthcheck |
| 245 | [Documentation] Runs Policy Apex PDP Health check |
| 246 | ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD} |
| 247 | Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_APEX_PDP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} |
| 248 | ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_APEX_PDP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth} |
| 249 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 250 | ${resp}= Get Request policy /policy/apex-pdp/v1/healthcheck headers=${headers} |
| 251 | Log Received response from policy ${resp.text} |
| 252 | Should Be Equal As Strings ${resp.status_code} 200 |
| 253 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 254 | |