blob: 6e2fa008e7e2f2ef59a2828c1d58df8e029c17bd [file] [log] [blame]
Michael Mokry88f4d472019-03-04 12:00:05 -06001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
Jim Hahn2d949212020-05-11 10:13:32 -04005Library Process
Michael Mokry88f4d472019-03-04 12:00:05 -06006Library json
7
8*** Test Cases ***
9Healthcheck
10 [Documentation] Runs Policy Xacml PDP Health check
Jim Hahn5785bf82020-04-16 18:32:27 -040011 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryed8bae52019-03-12 15:10:53 -050012 Log Creating session https://${POLICY_PDPX_IP}:6969
13 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
Michael Mokry88f4d472019-03-04 12:00:05 -060014 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
15 ${resp}= Get Request policy /policy/pdpx/v1/healthcheck headers=${headers}
16 Log Received response from policy ${resp.text}
17 Should Be Equal As Strings ${resp.status_code} 200
18 Should Be Equal As Strings ${resp.json()['code']} 200
19
20Statistics
21 [Documentation] Runs Policy Xacml PDP Statistics
HOCKLA2e519f52019-10-23 13:00:00 -050022 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryed8bae52019-03-12 15:10:53 -050023 Log Creating session https://${POLICY_PDPX_IP}:6969
24 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
Michael Mokry88f4d472019-03-04 12:00:05 -060025 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
26 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
27 Log Received response from policy ${resp.text}
28 Should Be Equal As Strings ${resp.status_code} 200
29 Should Be Equal As Strings ${resp.json()['code']} 200
HOCKLA2e519f52019-10-23 13:00:00 -050030
Jim Hahn2d949212020-05-11 10:13:32 -040031MakeTopics
32 [Documentation] Creates the Policy topics
33 ${result}= Run Process ${SCR_DMAAP}/make_topic.sh POLICY-PDP-PAP
34 Should Be Equal As Integers ${result.rc} 0
35
Michael Mokryb4f69622019-05-13 13:09:17 -050036ExecuteXacmlPolicy
Jim Hahn514799f2020-04-20 12:05:50 -040037 Wait Until Keyword Succeeds 0 min 15 sec CreateMonitorPolicy
38 Wait Until Keyword Succeeds 0 min 15 sec CreateOptimizationPolicy
39 Wait Until Keyword Succeeds 0 min 15 sec GetDefaultDecision
40 Wait Until Keyword Succeeds 0 min 15 sec DeployPolicies
Jim Hahn5785bf82020-04-16 18:32:27 -040041 Wait Until Keyword Succeeds 0 min 15 sec GetAbbreviatedDecisionResult
42 Wait Until Keyword Succeeds 0 min 15 sec GetMonitoringDecision
43 Wait Until Keyword Succeeds 0 min 15 sec GetNamingDecision
Jim Hahn514799f2020-04-20 12:05:50 -040044 Wait Until Keyword Succeeds 0 min 15 sec GetOptimizationDecision
HOCKLA2e519f52019-10-23 13:00:00 -050045
Michael Mokryb4f69622019-05-13 13:09:17 -050046*** Keywords ***
47
Jim Hahn514799f2020-04-20 12:05:50 -040048CreateMonitorPolicy
49 [Documentation] Create a Monitoring policy
Michael Mokryb4f69622019-05-13 13:09:17 -050050 ${auth}= Create List healthcheck zb!XztG34
Jim Hahn514799f2020-04-20 12:05:50 -040051 ${postjson}= Get file ${DATA2}/vCPE.policy.monitoring.input.tosca.json
Michael Mokryb4f69622019-05-13 13:09:17 -050052 Log Creating session https://${POLICY_API_IP}:6969
53 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
54 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
55 ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies data=${postjson} headers=${headers}
56 Log Received response from policy4 ${resp.text}
57 ${postjsonobject} To Json ${postjson}
58 Should Be Equal As Strings ${resp.status_code} 200
59 Dictionary Should Contain Key ${resp.json()} tosca_definitions_version
60 Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version
61
Jim Hahn514799f2020-04-20 12:05:50 -040062CreateOptimizationPolicy
63 [Documentation] Create an Optimization policy
64 ${auth}= Create List healthcheck zb!XztG34
65 ${postjson}= Get file ${DATA2}/vCPE.policies.optimization.input.tosca.json
66 Log Creating session https://${POLICY_API_IP}:6969
67 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
68 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
69 ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.optimization.resource.AffinityPolicy/versions/1.0.0/policies data=${postjson} headers=${headers}
70 Log Received response from policy4 ${resp.text}
71 ${postjsonobject} To Json ${postjson}
72 Should Be Equal As Strings ${resp.status_code} 200
73 Dictionary Should Contain Key ${resp.json()} tosca_definitions_version
74 Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version
75
76DeployPolicies
Michael Mokryb4f69622019-05-13 13:09:17 -050077 [Documentation] Runs Policy PAP to deploy a policy
78 ${auth}= Create List healthcheck zb!XztG34
Jim Hahn514799f2020-04-20 12:05:50 -040079 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.input.tosca.deploy.json
Michael Mokryb4f69622019-05-13 13:09:17 -050080 Log Creating session https://${POLICY_PAP_IP}:6969
81 ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth}
82 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
83 ${resp}= Post Request policy /policy/pap/v1/pdps/policies data=${postjson} headers=${headers}
84 Log Received response from policy5 ${resp.text}
85 ${postjsonobject} To Json ${postjson}
86 Should Be Equal As Strings ${resp.status_code} 200
Jim Hahn2d949212020-05-11 10:13:32 -040087 ${result}= Run Process ${SCR_DMAAP}/wait_topic.sh POLICY-PDP-PAP
88 ... responseTo xacml ACTIVE onap.restart.tca
Michael Mokryb4f69622019-05-13 13:09:17 -050089
90GetStatisticsAfterDeployed
91 [Documentation] Runs Policy Xacml PDP Statistics after policy is deployed
HOCKLA2e519f52019-10-23 13:00:00 -050092 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryb4f69622019-05-13 13:09:17 -050093 Log Creating session https://${POLICY_PDPX_IP}:6969
94 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
95 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
96 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
97 Log Received response from policy ${resp.text}
98 Should Be Equal As Strings ${resp.status_code} 200
99 Should Be Equal As Strings ${resp.json()['code']} 200
100 Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 1
HOCKLA2e519f52019-10-23 13:00:00 -0500101
Jim Hahn514799f2020-04-20 12:05:50 -0400102GetDefaultDecision
103 [Documentation] Get Default Decision with no policies in Xacml PDP
104 ${auth}= Create List healthcheck zb!XztG34
105 ${postjson}= Get file ${CURDIR}/data/onap.policy.guard.decision.request.json
106 Log Creating session https://${POLICY_PDPX_IP}:6969
107 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
108 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
109 ${params}= Create Dictionary abbrev=true
110 ${resp}= Post Request policy /policy/pdpx/v1/decision params=${params} data=${postjson} headers=${headers}
111 Log Received response from policy ${resp.text}
112 ${status}= Get From Dictionary ${resp.json()} status
113 Should Be Equal As Strings ${resp.status_code} 200
114 Should Be Equal As Strings ${status} Permit
115
HOCKLA2e519f52019-10-23 13:00:00 -0500116GetAbbreviatedDecisionResult
117 [Documentation] Get Decision with abbreviated results from Policy Xacml PDP
118 ${auth}= Create List healthcheck zb!XztG34
119 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json
120 Log Creating session https://${POLICY_PDPX_IP}:6969
121 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
122 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
123 ${params}= Create Dictionary abbrev=true
124 ${resp}= Post Request policy /policy/pdpx/v1/decision params=${params} data=${postjson} headers=${headers}
125 Log Received response from policy ${resp.text}
126 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
127 Should Be Equal As Strings ${resp.status_code} 200
128 Dictionary Should Contain Key ${policy} type
129 Dictionary Should Contain Key ${policy} metadata
130 Dictionary Should Not Contain Key ${policy} type_version
131 Dictionary Should Not Contain Key ${policy} properties
132 Dictionary Should Not Contain Key ${policy} name
133 Dictionary Should Not Contain Key ${policy} version
134
Jim Hahn5785bf82020-04-16 18:32:27 -0400135GetMonitoringDecision
136 [Documentation] Get Decision from Monitoring Policy Xacml PDP
Michael Mokryb4f69622019-05-13 13:09:17 -0500137 ${auth}= Create List healthcheck zb!XztG34
138 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json
139 Log Creating session https://${POLICY_PDPX_IP}:6969
140 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
141 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
142 ${resp}= Post Request policy /policy/pdpx/v1/decision data=${postjson} headers=${headers}
143 Log Received response from policy ${resp.text}
HOCKLA2e519f52019-10-23 13:00:00 -0500144 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
Michael Mokryb4f69622019-05-13 13:09:17 -0500145 Should Be Equal As Strings ${resp.status_code} 200
HOCKLA2e519f52019-10-23 13:00:00 -0500146 Dictionary Should Contain Key ${policy} type
147 Dictionary Should Contain Key ${policy} metadata
148 Dictionary Should Contain Key ${policy} type_version
149 Dictionary Should Contain Key ${policy} properties
150 Dictionary Should Contain Key ${policy} name
151 Dictionary Should Contain Key ${policy} version
Jim Hahn5785bf82020-04-16 18:32:27 -0400152
153GetNamingDecision
154 [Documentation] Get Decision from Naming Policy Xacml PDP
155 ${auth}= Create List healthcheck zb!XztG34
156 ${postjson}= Get file ${CURDIR}/data/onap.policy.naming.decision.request.json
157 Log Creating session https://${POLICY_PDPX_IP}:6969
158 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
159 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
160 ${resp}= Post Request policy /policy/pdpx/v1/decision data=${postjson} headers=${headers}
161 Log Received response from policy ${resp.text}
Jim Hahnddb40432020-04-29 11:14:31 -0400162 ${policy}= Get From Dictionary ${resp.json()['policies']} SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP
Jim Hahn5785bf82020-04-16 18:32:27 -0400163 Should Be Equal As Strings ${resp.status_code} 200
164 Dictionary Should Contain Key ${policy} type
165 Dictionary Should Contain Key ${policy} type_version
166 Dictionary Should Contain Key ${policy} properties
167 Dictionary Should Contain Key ${policy} name
168
Jim Hahn514799f2020-04-20 12:05:50 -0400169GetOptimizationDecision
170 [Documentation] Get Decision from Optimization Policy Xacml PDP
171 ${auth}= Create List healthcheck zb!XztG34
172 ${postjson}= Get file ${CURDIR}/data/onap.policy.optimization.decision.request.json
173 Log Creating session https://${POLICY_PDPX_IP}:6969
174 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
175 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
176 ${resp}= Post Request policy /policy/pdpx/v1/decision data=${postjson} headers=${headers}
177 Log Received response from policy ${resp.text}
178 ${policy}= Get From Dictionary ${resp.json()['policies']} OSDF_CASABLANCA.Affinity_Default
179 Should Be Equal As Strings ${resp.status_code} 200
180 Dictionary Should Contain Key ${policy} type
181 Dictionary Should Contain Key ${policy} type_version
182 Dictionary Should Contain Key ${policy} properties
183 Dictionary Should Contain Key ${policy} name
184
Michael Mokryb4f69622019-05-13 13:09:17 -0500185GetStatisticsAfterDecision
186 [Documentation] Runs Policy Xacml PDP Statistics after Decision request
Jim Hahn5785bf82020-04-16 18:32:27 -0400187 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryb4f69622019-05-13 13:09:17 -0500188 Log Creating session https://${POLICY_PDPX_IP}:6969
189 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
190 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
191 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
192 Log Received response from policy ${resp.text}
193 Should Be Equal As Strings ${resp.status_code} 200
194 Should Be Equal As Strings ${resp.json()['code']} 200
195 Should Be Equal As Strings ${resp.json()['totalDecisionsCount'] 1
Jim Hahn5785bf82020-04-16 18:32:27 -0400196
Michael Mokryb4f69622019-05-13 13:09:17 -0500197UndeployMonitorPolicy
198 [Documentation] Runs Policy PAP to undeploy a policy
199 ${auth}= Create List healthcheck zb!XztG34
200 Log Creating session https://${POLICY_PAP_IP}:6969
201 ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth}
202 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
203 ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/onap.restart.tca headers=${headers}
204 Log Received response from policy ${resp.text}
205 Should Be Equal As Strings ${resp.status_code} 200
Jim Hahn5785bf82020-04-16 18:32:27 -0400206
Michael Mokryb4f69622019-05-13 13:09:17 -0500207GetStatisticsAfterUndeploy
208 [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed
Jim Hahn5785bf82020-04-16 18:32:27 -0400209 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryb4f69622019-05-13 13:09:17 -0500210 Log Creating session https://${POLICY_PDPX_IP}:6969
211 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
212 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
213 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
214 Log Received response from policy ${resp.text}
215 Should Be Equal As Strings ${resp.status_code} 200
216 Should Be Equal As Strings ${resp.json()['code']} 200
217 Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 0