blob: c532c17ad8c84ee3ad249b9a5a1fcea029c8575e [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The main interface for interacting with Policy. It handles low level stuff like managing the http request library and Policy required fields
3Library RequestsClientCert
4Library RequestsLibrary
5Library String
6Library JSONUtils
7Library Collections
8Resource global_properties.robot
9
10*** Variables ***
11${POLICY_HEALTH_CHECK_PATH} /healthcheck
DR695Hbf5a3a32017-06-30 13:09:57 -040012${POLICY_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_POLICY_SERVER_PORT}
Gary Wu251aa682018-07-30 15:22:20 -070013${POLICY_HEALTHCHECK_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_HEALTHCHECK_IP_ADDR}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
Brian Freemanca5e32e2018-07-23 12:47:21 -050014${POLICY_TEMPLATES} robot/assets/templates/policy
Brian Freemand65e2aa2018-07-26 11:13:46 -050015${DROOLS_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_DROOLS_SERVER_PORT}
Bilal A461aa5b2019-05-06 14:00:57 -040016${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}
DR695Hccff30b2017-02-17 18:44:24 -050023
24*** Keywords ***
25
26Run Policy Health Check
27 [Documentation] Runs Policy Health check
28 ${auth}= Create List ${GLOBAL_POLICY_USERNAME} ${GLOBAL_POLICY_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040029 Log Creating session ${POLICY_ENDPOINT}
30 ${session}= Create Session policy ${POLICY_HEALTHCHECK_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050031 ${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 Freemand65e2aa2018-07-26 11:13:46 -050041Run 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
DR695Hccff30b2017-02-17 18:44:24 -050053Run Policy Put Request
54 [Documentation] Runs Policy Put request
55 [Arguments] ${data_path} ${data}
DR695Hbf5a3a32017-06-30 13:09:57 -040056 Log Creating session ${POLICY_ENDPOINT}
57 ${session}= Create Session policy ${POLICY_ENDPOINT}
DR695Hccff30b2017-02-17 18:44:24 -050058 ${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 Freemane14d2572019-04-29 16:20:21 -050062
Brian Freemanc967dd62019-04-30 09:47:44 -050063Run 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 Freemane14d2572019-04-29 16:20:21 -050072Run 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 Freemanc967dd62019-04-30 09:47:44 -050081
DR695Hccff30b2017-02-17 18:44:24 -050082Run Policy Delete Request
83 [Documentation] Runs Policy Delete request
84 [Arguments] ${data_path} ${data}
DR695Hbf5a3a32017-06-30 13:09:57 -040085 Log Creating session ${POLICY_ENDPOINT}
86 ${session}= Create Session policy ${POLICY_ENDPOINT}
DR695Hccff30b2017-02-17 18:44:24 -050087 ${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
92Run Policy Get Configs Request
93 [Documentation] Runs Policy Get Configs request
94 [Arguments] ${data_path} ${data}
DR695Hbf5a3a32017-06-30 13:09:57 -040095 Log Creating session ${POLICY_ENDPOINT}
96 ${session}= Create Session policy ${POLICY_ENDPOINT}
DR695Hccff30b2017-02-17 18:44:24 -050097 ${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 Wu76bc74f2018-03-22 13:25:49 -0700100 [Return] ${resp}
101
102
103
Brian Freemanc967dd62019-04-30 09:47:44 -0500104Update vVFWCL Policy Old
Gary Wu76bc74f2018-03-22 13:25:49 -0700105 [Arguments] ${resource_id}
Brian Freemanca5e32e2018-07-23 12:47:21 -0500106 Run Keyword and Ignore Error Delete vFWCL Policy
Gary Wu76bc74f2018-03-22 13:25:49 -0700107 Sleep 20s
Brian Freemand65e2aa2018-07-26 11:13:46 -0500108 Log To Console Create vFWCL Policy
Gary Wu76bc74f2018-03-22 13:25:49 -0700109 Create vFWCL Policy ${resource_id}
110 Sleep 5s
Brian Freemand65e2aa2018-07-26 11:13:46 -0500111 Log To Console Push vFWCL Policy
Gary Wu76bc74f2018-03-22 13:25:49 -0700112 Push vFWCL Policy
113 Sleep 20s
Brian Freemand65e2aa2018-07-26 11:13:46 -0500114 Log To Console Reboot Drools
Gary Wu76bc74f2018-03-22 13:25:49 -0700115 Reboot Drools
116 Sleep 20s
Brian Freemand65e2aa2018-07-26 11:13:46 -0500117 Log To Console Validate vFWCL Policy
Brian Freemanc967dd62019-04-30 09:47:44 -0500118 Validate the vFWCL Policy Old
119
120Update vVFWCL Policy
Brian Freeman0d866b52019-05-08 20:30:14 -0500121 [Arguments] ${resource_id}
Brian Freemanc967dd62019-04-30 09:47:44 -0500122 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 Wu76bc74f2018-03-22 13:25:49 -0700132 Validate the vFWCL Policy
133
Brian Freemanc967dd62019-04-30 09:47:44 -0500134
Gary Wu76bc74f2018-03-22 13:25:49 -0700135Delete 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
140Create 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
147Push 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
153Reboot 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 Freemanc967dd62019-04-30 09:47:44 -0500168Validate the vFWCL Policy Old
Gary Wu76bc74f2018-03-22 13:25:49 -0700169 ${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 Freemane14d2572019-04-29 16:20:21 -0500173
Brian Freemanc967dd62019-04-30 09:47:44 -0500174Validate 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 Freemane14d2572019-04-29 16:20:21 -0500178
179Create 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
186Create 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
194Push 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 A461aa5b2019-05-06 14:00:57 -0400200Run 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
211Run 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
222Run 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
233Run 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
244Run 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