blob: 3e6048b11acbc5754661705a6afffadf5de2e0a0 [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}
DR695Hccff30b2017-02-17 18:44:24 -050021
Brian Freeman88fbb992019-05-17 17:46:56 -050022
DR695Hccff30b2017-02-17 18:44:24 -050023*** Keywords ***
24
25Run Policy Health Check
Pamela Dragosh0adce512020-08-25 13:18:02 -040026 [Documentation] Runs Policy Health Check
mrichomme455d3992020-04-03 14:56:40 +020027 ${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
mrichommed7855e22020-04-07 17:03:46 +020031 ${resp}= Get Request policy ${POLICY_NEW_HEALTHCHECK_PATH} headers=${headers}
mrichomme455d3992020-04-03 14:56:40 +020032 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 Freeman55b96e22019-05-08 20:49:45 -050036Run 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 Desbureaux2e33ff62019-05-15 14:41:18 +020041 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
Brian Freeman55b96e22019-05-08 20:49:45 -050042 ${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 Freeman55b96e22019-05-08 20:49:45 -050047Run 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 Desbureaux2e33ff62019-05-15 14:41:18 +020051 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
Brian Freeman55b96e22019-05-08 20:49:45 -050052 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 Freeman55b96e22019-05-08 20:49:45 -050058Run 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 Desbureaux2e33ff62019-05-15 14:41:18 +020062 ${session}= Create Session policy ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT} auth=${auth}
Brian Freeman55b96e22019-05-08 20:49:45 -050063 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 Freemane6c3d282019-09-30 14:20:02 -050069Undeploy 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 Freemanc967dd62019-04-30 09:47:44 -050080Update vVFWCL Policy
Brian Freeman0d866b52019-05-08 20:30:14 -050081 [Arguments] ${resource_id}
DR695H8e7028b2019-07-10 10:13:58 -040082 Log Create vFWCL Monitoring Policy
Brian Freemanbb584612020-05-05 09:07:15 -050083 Create vFirewall Monitoring Policy ${resource_id}
Brian Freemanc967dd62019-04-30 09:47:44 -050084 Sleep 5s
DR695H8e7028b2019-07-10 10:13:58 -040085 Log Create vFWCL Operational Policy
Brian Freeman75948282019-05-14 20:44:46 -050086 ${op_policy_version}= Create vFirewall Operational Policy ${resource_id}
Brian Freemanc967dd62019-04-30 09:47:44 -050087 Sleep 5s
DR695H8e7028b2019-07-10 10:13:58 -040088 Log Push vFWCL To PDP Group
Brian Freeman75948282019-05-14 20:44:46 -050089 Push vFirewall Policies To PDP Group ${op_policy_version}
Brian Freemanc967dd62019-04-30 09:47:44 -050090 Sleep 20s
DR695H8e7028b2019-07-10 10:13:58 -040091 Log Validate vFWCL Policy
Gary Wu76bc74f2018-03-22 13:25:49 -070092 Validate the vFWCL Policy
93
Brian Freeman55b96e22019-05-08 20:49:45 -050094Validate the vFWCL Policy
95 ${resp}= Run Policy Pap Get Request /policy/pap/v1/pdps
Brian Freemanc967dd62019-04-30 09:47:44 -050096 Log Received response from policy ${resp.text}
97 Should Be Equal As Strings ${resp.status_code} 200
Brian Freemane14d2572019-04-29 16:20:21 -050098
99Create vFirewall Monitoring Policy
Brian Freemanbb584612020-05-05 09:07:15 -0500100 [Arguments] ${resource_id}
101 ${dict}= Create Dictionary RESOURCE_ID=${resource_id}
DR695Hd9794652019-07-19 18:20:40 -0400102 Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER}
103 ${data}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_policy_monitoring_input_tosca.jinja ${dict}
Pamela Dragosh0adce512020-08-25 13:18:02 -0400104 ${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 -0500105 Should Be Equal As Strings ${resp.status_code} 200
106
Brian Freeman88fbb992019-05-17 17:46:56 -0500107Create vFirewall Operational Policy
DR695H34409422019-06-20 10:56:46 -0400108 [Arguments] ${resource_id}
109 ${dict}= Create Dictionary RESOURCE_ID=${resource_id}
DR695Hd9794652019-07-19 18:20:40 -0400110 Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER}
Brian Freemandf0ca462020-05-06 15:10:06 -0500111 ${data_2}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_policy_operational_content_input.jinja ${dict}
DR695H8e7028b2019-07-10 10:13:58 -0400112 Log ${data_2}
Brian Freemandf0ca462020-05-06 15:10:06 -0500113 ${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 -0400114 Should Be Equal As Strings ${resp.status_code} 200
Brian Freemandf0ca462020-05-06 15:10:06 -0500115 [Return] ${resp.json()['version']}
Brian Freeman88fbb992019-05-17 17:46:56 -0500116
Brian Freemane14d2572019-04-29 16:20:21 -0500117Push vFirewall Policies To PDP Group
DR695H34409422019-06-20 10:56:46 -0400118 [Arguments] ${op_policy_version}
119 ${dict}= Create Dictionary OP_POLICY_VERSION=${op_policy_version}
DR695Hd9794652019-07-19 18:20:40 -0400120 Templating.Create Environment policy ${GLOBAL_TEMPLATE_FOLDER}
121 ${data}= Templating.Apply Template policy ${POLICY_TEMPLATES}/vFirewall_push.jinja ${dict}
DR695H34409422019-06-20 10:56:46 -0400122 ${resp}= Run Policy Pap Post Request /policy/pap/v1/pdps/policies ${data}
123 Should Be Equal As Strings ${resp.status_code} 200