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} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 16 | |
| 17 | *** Keywords *** |
| 18 | |
| 19 | Run Policy Health Check |
| 20 | [Documentation] Runs Policy Health check |
| 21 | ${auth}= Create List ${GLOBAL_POLICY_USERNAME} ${GLOBAL_POLICY_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 22 | Log Creating session ${POLICY_ENDPOINT} |
| 23 | ${session}= Create Session policy ${POLICY_HEALTHCHECK_ENDPOINT} auth=${auth} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 24 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 25 | ${resp}= Get Request policy ${POLICY_HEALTH_CHECK_PATH} headers=${headers} |
| 26 | Log Received response from policy ${resp.text} |
| 27 | Should Be Equal As Strings ${resp.status_code} 200 |
| 28 | Should Be True ${resp.json()['healthy']} |
| 29 | @{ITEMS}= Copy List ${resp.json()['details']} |
| 30 | :FOR ${ELEMENT} IN @{ITEMS} |
| 31 | \ Should Be Equal As Strings ${ELEMENT['code']} 200 |
| 32 | \ Should Be True ${ELEMENT['healthy']} |
| 33 | |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 34 | Run Drools Get Request |
| 35 | [Documentation] Runs Drools Get Request |
| 36 | [Arguments] ${data_path} |
| 37 | ${auth}= Create List ${GLOBAL_DROOLS_USERNAME} ${GLOBAL_DROOLS_PASSWORD} |
| 38 | Log Creating session ${POLICY_ENDPOINT} |
| 39 | ${session}= Create Session policy ${DROOLS_ENDPOINT} auth=${auth} |
| 40 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 41 | ${resp}= Get Request policy ${data_path} headers=${headers} |
| 42 | Log Received response from policy ${resp.text} |
| 43 | Should Be Equal As Strings ${resp.status_code} 200 |
| 44 | [Return] ${resp} |
| 45 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 46 | Run Policy Put Request |
| 47 | [Documentation] Runs Policy Put request |
| 48 | [Arguments] ${data_path} ${data} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 49 | Log Creating session ${POLICY_ENDPOINT} |
| 50 | ${session}= Create Session policy ${POLICY_ENDPOINT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 51 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST |
| 52 | ${resp}= Put Request policy ${data_path} data=${data} headers=${headers} |
| 53 | Log Received response from policy ${resp.text} |
| 54 | [Return] ${resp} |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 55 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame^] | 56 | Run Policy Get Request |
| 57 | [Documentation] Runs Policy Get request |
| 58 | [Arguments] ${data_path} |
| 59 | Log Creating session ${POLICY_ENDPOINT} |
| 60 | ${session}= Create Session policy ${POLICY_ENDPOINT} |
| 61 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST |
| 62 | ${resp}= Get Request policy ${data_path} headers=${headers} |
| 63 | Log Received response from policy ${resp.text} |
| 64 | |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 65 | Run Policy Post Request |
| 66 | [Documentation] Runs Policy Post request |
| 67 | [Arguments] ${data_path} ${data} |
| 68 | Log Creating session ${POLICY_ENDPOINT} |
| 69 | ${session}= Create Session policy ${POLICY_ENDPOINT} |
| 70 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST |
| 71 | ${resp}= Post Request policy ${data_path} data=${data} headers=${headers} |
| 72 | Log Received response from policy ${resp.text} |
| 73 | [Return] ${resp} |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame^] | 74 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 75 | Run Policy Delete Request |
| 76 | [Documentation] Runs Policy Delete request |
| 77 | [Arguments] ${data_path} ${data} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 78 | Log Creating session ${POLICY_ENDPOINT} |
| 79 | ${session}= Create Session policy ${POLICY_ENDPOINT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 80 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} Environment=TEST |
| 81 | ${resp}= Delete Request policy ${data_path} data=${data} headers=${headers} |
| 82 | Log Received response from policy ${resp.text} |
| 83 | [Return] ${resp} |
| 84 | |
| 85 | Run Policy Get Configs Request |
| 86 | [Documentation] Runs Policy Get Configs request |
| 87 | [Arguments] ${data_path} ${data} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 88 | Log Creating session ${POLICY_ENDPOINT} |
| 89 | ${session}= Create Session policy ${POLICY_ENDPOINT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 90 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY_CLIENTAUTH} |
| 91 | ${resp}= Post Request policy ${data_path} data=${data} headers=${headers} |
| 92 | Log Received response from policy ${resp.text} |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 93 | [Return] ${resp} |
| 94 | |
| 95 | |
| 96 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame^] | 97 | Update vVFWCL Policy Old |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 98 | [Arguments] ${resource_id} |
Brian Freeman | ca5e32e | 2018-07-23 12:47:21 -0500 | [diff] [blame] | 99 | Run Keyword and Ignore Error Delete vFWCL Policy |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 100 | Sleep 20s |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 101 | Log To Console Create vFWCL Policy |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 102 | Create vFWCL Policy ${resource_id} |
| 103 | Sleep 5s |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 104 | Log To Console Push vFWCL Policy |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 105 | Push vFWCL Policy |
| 106 | Sleep 20s |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 107 | Log To Console Reboot Drools |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 108 | Reboot Drools |
| 109 | Sleep 20s |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 110 | Log To Console Validate vFWCL Policy |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame^] | 111 | Validate the vFWCL Policy Old |
| 112 | |
| 113 | Update vVFWCL Policy |
| 114 | [Arguments] ${resource_id} |
| 115 | Log To Console Create vFWCL Monitoring Policy |
| 116 | Create vFirewall Monitoring Policy |
| 117 | Sleep 5s |
| 118 | Log To Console Create vFWCL Operational Policy |
| 119 | Create vFirewall Operational Policy ${resource_id} |
| 120 | Sleep 5s |
| 121 | Log To Console Push vFWCL To PDP Group |
| 122 | Push vFirewall Policies To PDP Group |
| 123 | Sleep 20s |
| 124 | Log To Console Validate vFWCL Policy |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 125 | Validate the vFWCL Policy |
| 126 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame^] | 127 | |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 128 | Delete vFWCL Policy |
| 129 | ${data}= OperatingSystem.Get File ${POLICY_TEMPLATES}/FirewallPolicy_delete.template |
| 130 | ${resp}= Run Policy Delete Request /pdp/api/deletePolicy ${data} |
| 131 | Should Be Equal As Strings ${resp.status_code} 200 |
| 132 | |
| 133 | Create vFWCL Policy |
| 134 | [Arguments] ${resource_id} |
| 135 | ${dict}= Create Dictionary RESOURCE_ID=${resource_id} |
| 136 | ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/FirewallPolicy_update.template ${dict} |
| 137 | ${resp}= Run Policy Put Request /pdp/api/updatePolicy ${data} |
| 138 | Should Be Equal As Strings ${resp.status_code} 200 |
| 139 | |
| 140 | Push vFWCL Policy |
| 141 | ${dict}= Create Dictionary |
| 142 | ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/FirewallPolicy_push.template ${dict} |
| 143 | ${resp}= Run Policy Put Request /pdp/api/pushPolicy ${data} |
| 144 | Should Be Equal As Strings ${resp.status_code} 200 |
| 145 | |
| 146 | Reboot Drools |
| 147 | ${stop}= Catenate docker exec -t -u policy drools bash -c "source /opt/app/policy/etc/profile.d/env.sh; policy stop" |
| 148 | ${start}= Catenate docker exec -t -u policy drools bash -c "source /opt/app/policy/etc/profile.d/env.sh; policy start" |
| 149 | Wait Until Keyword Succeeds 120 5 sec Open Connection And Log In ${GLOBAL_INJECTED_POLICY_IP_ADDR} root ${GLOBAL_VM_PRIVATE_KEY} |
| 150 | Write ${stop} |
| 151 | ${status} ${stdout}= Run Keyword And Ignore Error SSHLibrary.Read Until Regexp has stopped |
| 152 | Log ${status}: stdout=${stdout} |
| 153 | ${ctrlc}= Evaluate '\x03' |
| 154 | Run Keyword If '${status}' == 'FAIL' Write ${ctrlc} |
| 155 | Sleep 5s |
| 156 | Write ${start} |
| 157 | ${stdout}= SSHLibrary.Read Until Regexp is running |
| 158 | Log stdout=${stdout} |
| 159 | Should Contain ${stdout} is running |
| 160 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame^] | 161 | Validate the vFWCL Policy Old |
Gary Wu | 76bc74f | 2018-03-22 13:25:49 -0700 | [diff] [blame] | 162 | ${resp}= Run Drools Get Request /policy/pdp/engine/controllers/amsterdam/drools |
| 163 | Should Be Equal As Strings ${resp.status_code} 200 |
| 164 | ${resp}= Run Drools Get Request /policy/pdp/engine/controllers/amsterdam/drools/facts/closedloop-amsterdam/org.onap.policy.controlloop.Params |
| 165 | Should Be Equal As Strings ${resp.status_code} 200 |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 166 | |
Brian Freeman | c967dd6 | 2019-04-30 09:47:44 -0500 | [diff] [blame^] | 167 | Validate the vFWCL Policy |
| 168 | ${resp}= Run Policy Get Request /policy/pap/v1/pdps |
| 169 | Log Received response from policy ${resp.text} |
| 170 | Should Be Equal As Strings ${resp.status_code} 200 |
Brian Freeman | e14d257 | 2019-04-29 16:20:21 -0500 | [diff] [blame] | 171 | |
| 172 | Create vFirewall Monitoring Policy |
| 173 | ${dict}= Create Dictionary |
| 174 | ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/vFirewall_policy_monitoring_input_tosca.template ${dict} |
| 175 | ${resp}= Run Policy Post Request /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies ${data} |
| 176 | Should Be Equal As Strings ${resp.status_code} 200 |
| 177 | |
| 178 | |
| 179 | Create vFirewall Operational Policy |
| 180 | [Arguments] ${resource_id} |
| 181 | ${dict}= Create Dictionary RESOURCE_ID=${resource_id} |
| 182 | ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/vFirewall_policy_operational_input.template ${dict} |
| 183 | ${resp}= Run Policy Post Request /policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies ${data} |
| 184 | Should Be Equal As Strings ${resp.status_code} 200 |
| 185 | |
| 186 | |
| 187 | Push vFirewall Policies To PDP Group |
| 188 | ${dict}= Create Dictionary |
| 189 | ${data}= Fill JSON Template File ${POLICY_TEMPLATES}/vFirewall_push.template ${dict} |
| 190 | ${resp}= Run Policy Post Request /policy/pap/v1/pdps/policies ${data} |
| 191 | Should Be Equal As Strings ${resp.status_code} 200 |
| 192 | |