3 Library RequestsLibrary
4 Library OperatingSystem
10 [Documentation] Runs Policy Xacml PDP Health check
11 ${auth}= Create List healthcheck zb!XztG34
12 Log Creating session https://${POLICY_PDPX_IP}:6969
13 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
14 ${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
21 [Documentation] Runs Policy Xacml PDP Statistics
22 ${auth}= Create List healthcheck zb!XztG34
23 Log Creating session https://${POLICY_PDPX_IP}:6969
24 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
25 ${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
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
37 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
41 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
44 Wait Until Keyword Succeeds 0 min 15 sec GetOptimizationDecision
49 [Documentation] Create a Monitoring policy
50 ${auth}= Create List healthcheck zb!XztG34
51 ${postjson}= Get file ${DATA2}/vCPE.policy.monitoring.input.tosca.json
52 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
62 CreateOptimizationPolicy
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
77 [Documentation] Runs Policy PAP to deploy a policy
78 ${auth}= Create List healthcheck zb!XztG34
79 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.input.tosca.deploy.json
80 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
87 ${result}= Run Process ${SCR_DMAAP}/wait_topic.sh POLICY-PDP-PAP
88 ... responseTo xacml ACTIVE onap.restart.tca
90 GetStatisticsAfterDeployed
91 [Documentation] Runs Policy Xacml PDP Statistics after policy is deployed
92 ${auth}= Create List healthcheck zb!XztG34
93 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
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
116 GetAbbreviatedDecisionResult
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
135 GetMonitoringDecision
136 [Documentation] Get Decision from Monitoring Policy Xacml PDP
137 ${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}
144 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
145 Should Be Equal As Strings ${resp.status_code} 200
146 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
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}
162 ${policy}= Get From Dictionary ${resp.json()['policies']} SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP
163 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
169 GetOptimizationDecision
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
185 GetStatisticsAfterDecision
186 [Documentation] Runs Policy Xacml PDP Statistics after Decision request
187 ${auth}= Create List healthcheck zb!XztG34
188 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
197 UndeployMonitorPolicy
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
207 GetStatisticsAfterUndeploy
208 [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed
209 ${auth}= Create List healthcheck zb!XztG34
210 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