blob: 11ff7c5a49e69a5e72405a539371599be12578a9 [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
DR695Hccff30b2017-02-17 18:44:24 -05003Library RequestsLibrary
4Library String
Sylvain Desbureaux2e33ff62019-05-15 14:41:18 +02005Library Collections
DR695H910097e2019-05-08 13:55:32 -04006Library SSHLibrary
7Library OperatingSystem
DR695Hd9794652019-07-19 18:20:40 -04008Library ONAPLibrary.Templating WITH NAME Templating
DR695Hccff30b2017-02-17 18:44:24 -05009Resource global_properties.robot
DR695H910097e2019-05-08 13:55:32 -040010Resource ssh/files.robot
DR695Hccff30b2017-02-17 18:44:24 -050011
12*** Variables ***
mrichommed7855e22020-04-07 17:03:46 +020013${POLICY_NEW_HEALTHCHECK_PATH} /policy/pap/v1/components/healthcheck
mrichomme455d3992020-04-03 14:56:40 +020014${POLICY_NEW_HEALTHCHECK_ENDPOINT} ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_PAP_IP_ADDR}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
DR695H34409422019-06-20 10:56:46 -040015${POLICY_TEMPLATES} policy
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}
Bilal A461aa5b2019-05-06 14:00:57 -040018${POLICY_PDPX_IP} ${GLOBAL_INJECTED_POLICY_PDPX_IP_ADDR}
Bilal A461aa5b2019-05-06 14:00:57 -040019${POLICY_HEALTHCHECK_USERNAME} ${GLOBAL_POLICY_HEALTHCHECK_USERNAME}
20${POLICY_HEALTHCHECK_PASSWORD} ${GLOBAL_POLICY_HEALTHCHECK_PASSWORD}
Nagendra9028704889532020-09-04 15:44:45 +053021${json_path_policy} /var/opt/ONAP/robot/assets/policy/
22${POLICY_GET_POLICY_URI} /policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig/versions/1.0.0
23${POLICY_CREATE_POLICY_URI} /policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies
DR695Hccff30b2017-02-17 18:44:24 -050024
Brian Freeman88fbb992019-05-17 17:46:56 -050025
DR695Hccff30b2017-02-17 18:44:24 -050026*** Keywords ***
27
28Run Policy Health Check
Pamela Dragosh0adce512020-08-25 13:18:02 -040029 [Documentation] Runs Policy Health Check
mrichomme455d3992020-04-03 14:56:40 +020030 ${auth}= Create List ${GLOBAL_POLICY_HEALTHCHECK_USERNAME} ${GLOBAL_POLICY_HEALTHCHECK_PASSWORD}
31 Log Creating session ${POLICY_NEW_HEALTHCHECK_ENDPOINT}
32 ${session}= Create Session policy ${POLICY_NEW_HEALTHCHECK_ENDPOINT} auth=${auth}
33 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
mrichommed7855e22020-04-07 17:03:46 +020034 ${resp}= Get Request policy ${POLICY_NEW_HEALTHCHECK_PATH} headers=${headers}
mrichomme455d3992020-04-03 14:56:40 +020035 Log Received response from policy ${resp.text}
36 Should Be Equal As Strings ${resp.status_code} 200
37 Should Be True ${resp.json()['healthy']}
38
Brian Freeman55b96e22019-05-08 20:49:45 -050039Run Policy Pap Get Request
40 [Documentation] Runs Policy Pap Get request
41 [Arguments] ${data_path}
42 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
43 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
Sylvain Desbureaux2e33ff62019-05-15 14:41:18 +020044 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
Brian Freeman55b96e22019-05-08 20:49:45 -050045 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
46 ${resp}= Get Request policy ${data_path} headers=${headers}
47 Log Received response from Policy Pap ${resp.text}
48 [Return] ${resp}
49
Brian Freeman55b96e22019-05-08 20:49:45 -050050Run Policy Api Post Request
51 [Documentation] Runs Policy Api Post request
52 [Arguments] ${data_path} ${data}
53 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
Sylvain Desbureaux2e33ff62019-05-15 14:41:18 +020054 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
Brian Freeman55b96e22019-05-08 20:49:45 -050055 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
56 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
57 ${resp}= Post Request policy ${data_path} data=${data} headers=${headers}
58 Log Received response from policy ${resp.text}
59 [Return] ${resp}
60
Brian Freeman55b96e22019-05-08 20:49:45 -050061Run Policy Pap Post Request
62 [Documentation] Runs Policy Pap Post request
63 [Arguments] ${data_path} ${data}
64 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
Sylvain Desbureaux2e33ff62019-05-15 14:41:18 +020065 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
Brian Freeman55b96e22019-05-08 20:49:45 -050066 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
67 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
68 ${resp}= Post Request policy ${data_path} data=${data} headers=${headers}
69 Log Received response from policy ${resp.text}
70 [Return] ${resp}
71
Brian Freemane6c3d282019-09-30 14:20:02 -050072Undeploy Policy
73 [Documentation] Runs Policy PAP Undeploy a Policy from PDP Groups
74 [Arguments] ${policy_name}
75 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
76 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
77 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
78 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
79 ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/${policy_name} headers=${headers}
80 Log Received response from policy ${resp.text}
81 Should Be Equal As Strings ${resp.status_code} 200
82
Brian Freemanc967dd62019-04-30 09:47:44 -050083Update vVFWCL Policy
Brian Freeman0d866b52019-05-08 20:30:14 -050084 [Arguments] ${resource_id}
DR695H8e7028b2019-07-10 10:13:58 -040085 Log Create vFWCL Monitoring Policy
Brian Freemanbb584612020-05-05 09:07:15 -050086 Create vFirewall Monitoring Policy ${resource_id}
Brian Freemanc967dd62019-04-30 09:47:44 -050087 Sleep 5s
DR695H8e7028b2019-07-10 10:13:58 -040088 Log Create vFWCL Operational Policy
Brian Freeman75948282019-05-14 20:44:46 -050089 ${op_policy_version}= Create vFirewall Operational Policy ${resource_id}
Brian Freemanc967dd62019-04-30 09:47:44 -050090 Sleep 5s
DR695H8e7028b2019-07-10 10:13:58 -040091 Log Push vFWCL To PDP Group
Brian Freeman75948282019-05-14 20:44:46 -050092 Push vFirewall Policies To PDP Group ${op_policy_version}
Brian Freemanc967dd62019-04-30 09:47:44 -050093 Sleep 20s
DR695H8e7028b2019-07-10 10:13:58 -040094 Log Validate vFWCL Policy
Gary Wu76bc74f2018-03-22 13:25:49 -070095 Validate the vFWCL Policy
96
Brian Freeman55b96e22019-05-08 20:49:45 -050097Validate the vFWCL Policy
98 ${resp}= Run Policy Pap Get Request /policy/pap/v1/pdps
Brian Freemanc967dd62019-04-30 09:47:44 -050099 Log Received response from policy ${resp.text}
100 Should Be Equal As Strings ${resp.status_code} 200
Brian Freemane14d2572019-04-29 16:20:21 -0500101
102Create vFirewall Monitoring Policy
Brian Freemanbb584612020-05-05 09:07:15 -0500103 [Arguments] ${resource_id}
104 ${dict}= Create Dictionary RESOURCE_ID=${resource_id}
DR695Hd9794652019-07-19 18:20:40 -0400105 Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER}
106 ${data}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_policy_monitoring_input_tosca.jinja ${dict}
Pamela Dragosh0adce512020-08-25 13:18:02 -0400107 ${resp}= Run Policy Api Post Request /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies ${data}
Brian Freemane14d2572019-04-29 16:20:21 -0500108 Should Be Equal As Strings ${resp.status_code} 200
109
Brian Freeman88fbb992019-05-17 17:46:56 -0500110Create vFirewall Operational Policy
DR695H34409422019-06-20 10:56:46 -0400111 [Arguments] ${resource_id}
112 ${dict}= Create Dictionary RESOURCE_ID=${resource_id}
DR695Hd9794652019-07-19 18:20:40 -0400113 Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER}
Brian Freemandf0ca462020-05-06 15:10:06 -0500114 ${data_2}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_policy_operational_content_input.jinja ${dict}
DR695H8e7028b2019-07-10 10:13:58 -0400115 Log ${data_2}
Brian Freemandf0ca462020-05-06 15:10:06 -0500116 ${resp}= Run Policy Api Post Request /policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies ${data_2}
DR695H34409422019-06-20 10:56:46 -0400117 Should Be Equal As Strings ${resp.status_code} 200
Brian Freemandf0ca462020-05-06 15:10:06 -0500118 [Return] ${resp.json()['version']}
Brian Freeman88fbb992019-05-17 17:46:56 -0500119
Brian Freemane14d2572019-04-29 16:20:21 -0500120Push vFirewall Policies To PDP Group
DR695H34409422019-06-20 10:56:46 -0400121 [Arguments] ${op_policy_version}
122 ${dict}= Create Dictionary OP_POLICY_VERSION=${op_policy_version}
DR695Hd9794652019-07-19 18:20:40 -0400123 Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER}
124 ${data}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_push.jinja ${dict}
DR695H34409422019-06-20 10:56:46 -0400125 ${resp}= Run Policy Pap Post Request /policy/pap/v1/pdps/policies ${data}
126 Should Be Equal As Strings ${resp.status_code} 200
Nagendra9028704889532020-09-04 15:44:45 +0530127
128Run Create Policy Post Request
129 [Documentation] Runs Create Policy Post request
130 #[Arguments] ${data}
131 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
132 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
133 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
134 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
135 ${json_policy} Get Binary File ${json_path_policy}create_policy.json
136 ${resp}= Post Request policy ${POLICY_CREATE_POLICY_URI} data=${json_policy} headers=${headers}
137 Log Received response from policy ${resp.text}
138 [Return] ${resp}
139 Should Be Equal As Strings ${resp.status_code} 200
140
141Run Get Policy Get Request
142 [Documentation] Runs Get Policy request
143 #[Arguments] ${data}
144 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
145 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
146 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
147 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
148 ${resp}= Get Request policy ${POLICY_GET_POLICY_URI} headers=${headers}
149 Log Received response from policy ${resp.text}
150 [Return] ${resp}
151 Should Be Equal As Strings ${resp.status_code} 200
152
153Run Deploy Policy Pap Post Request
154 [Documentation] Runs Deploy Policy Pap Post request
155 #[Arguments] ${data_path} ${data}
156 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
157 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
158 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
159 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
160 ${json_deploy} Get Binary File ${json_path_policy}deploy_policy.json
161 ${resp}= Post Request policy /policy/pap/v1/pdps/policies data=${json_deploy} headers=${headers}
162 Log Received response from policy ${resp.text}
163 [Return] ${resp}
164 Should Be Equal As Strings ${resp.status_code} 200
165
166Run Undeploy Policy
167 [Documentation] Runs Policy PAP Undeploy a Policy from PDP Groups
168 #[Arguments] ${policy_name}
169 ${auth}= Create List ${POLICY_HEALTHCHECK_USERNAME} ${POLICY_HEALTHCHECK_PASSWORD}
170 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
171 Log Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
172 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
173 ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/operational.modifyconfig headers=${headers}
174 Log Received response from policy ${resp.text}
175 Should Be Equal As Strings ${resp.status_code} 200
176
177
178Run Delete Policy Request
179 [Documentation] Runs Policy Delete request
180 #[Arguments] ${data_path} ${data}
181 Log Creating session ${POLICY_ENDPOINT}
182 ${session}= Create Session policy ${POLICY_ENDPOINT}
183 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json Authorization=Basic ${GLOBAL_POLICY_AUTH} ClientAuth=${GLOBAL_POLICY
184_CLIENTAUTH}
185 ${resp}= Delete Request policy ${POLICY_GET_POLICY_URI} headers=${headers}
186 Log Received response from policy ${resp.text}
187 [Return] ${resp}
188 Should Be Equal As Strings ${resp.status_code} 200