3 Library RequestsLibrary
4 Library OperatingSystem
9 [Documentation] Runs Policy Xacml PDP Health check
10 ${auth}= Create List healthcheck zb!XztG34
11 Log Creating session https://${POLICY_PDPX_IP}:6969
12 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
13 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
14 ${resp}= Get Request policy /policy/pdpx/v1/healthcheck headers=${headers}
15 Log Received response from policy ${resp.text}
16 Should Be Equal As Strings ${resp.status_code} 200
17 Should Be Equal As Strings ${resp.json()['code']} 200
20 [Documentation] Runs Policy Xacml PDP Statistics
21 ${auth}= Create List healthcheck zb!XztG34
22 Log Creating session https://${POLICY_PDPX_IP}:6969
23 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
24 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
25 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
26 Log Received response from policy ${resp.text}
27 Should Be Equal As Strings ${resp.status_code} 200
28 Should Be Equal As Strings ${resp.json()['code']} 200
31 Wait Until Keyword Succeeds 0 min 15 sec CreateMonitorPolicy
32 Wait Until Keyword Succeeds 0 min 15 sec CreateOptimizationPolicy
33 Wait Until Keyword Succeeds 0 min 15 sec GetDefaultDecision
34 Wait Until Keyword Succeeds 0 min 15 sec DeployPolicies
35 Wait Until Keyword Succeeds 0 min 15 sec GetAbbreviatedDecisionResult
36 Wait Until Keyword Succeeds 0 min 15 sec GetMonitoringDecision
37 Wait Until Keyword Succeeds 0 min 15 sec GetNamingDecision
38 Wait Until Keyword Succeeds 0 min 15 sec GetOptimizationDecision
43 [Documentation] Create a Monitoring policy
44 ${auth}= Create List healthcheck zb!XztG34
45 ${postjson}= Get file ${DATA2}/vCPE.policy.monitoring.input.tosca.json
46 Log Creating session https://${POLICY_API_IP}:6969
47 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
48 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
49 ${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}
50 Log Received response from policy4 ${resp.text}
51 ${postjsonobject} To Json ${postjson}
52 Should Be Equal As Strings ${resp.status_code} 200
53 Dictionary Should Contain Key ${resp.json()} tosca_definitions_version
54 Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version
56 CreateOptimizationPolicy
57 [Documentation] Create an Optimization policy
58 ${auth}= Create List healthcheck zb!XztG34
59 ${postjson}= Get file ${DATA2}/vCPE.policies.optimization.input.tosca.json
60 Log Creating session https://${POLICY_API_IP}:6969
61 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
62 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
63 ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.optimization.resource.AffinityPolicy/versions/1.0.0/policies data=${postjson} headers=${headers}
64 Log Received response from policy4 ${resp.text}
65 ${postjsonobject} To Json ${postjson}
66 Should Be Equal As Strings ${resp.status_code} 200
67 Dictionary Should Contain Key ${resp.json()} tosca_definitions_version
68 Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version
71 [Documentation] Runs Policy PAP to deploy a policy
72 ${auth}= Create List healthcheck zb!XztG34
73 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.input.tosca.deploy.json
74 Log Creating session https://${POLICY_PAP_IP}:6969
75 ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth}
76 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
77 ${resp}= Post Request policy /policy/pap/v1/pdps/policies data=${postjson} headers=${headers}
78 Log Received response from policy5 ${resp.text}
79 ${postjsonobject} To Json ${postjson}
80 Should Be Equal As Strings ${resp.status_code} 200
82 GetStatisticsAfterDeployed
83 [Documentation] Runs Policy Xacml PDP Statistics after policy is deployed
84 ${auth}= Create List healthcheck zb!XztG34
85 Log Creating session https://${POLICY_PDPX_IP}:6969
86 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
87 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
88 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
89 Log Received response from policy ${resp.text}
90 Should Be Equal As Strings ${resp.status_code} 200
91 Should Be Equal As Strings ${resp.json()['code']} 200
92 Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 1
95 [Documentation] Get Default Decision with no policies in Xacml PDP
96 ${auth}= Create List healthcheck zb!XztG34
97 ${postjson}= Get file ${CURDIR}/data/onap.policy.guard.decision.request.json
98 Log Creating session https://${POLICY_PDPX_IP}:6969
99 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
100 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
101 ${params}= Create Dictionary abbrev=true
102 ${resp}= Post Request policy /policy/pdpx/v1/decision params=${params} data=${postjson} headers=${headers}
103 Log Received response from policy ${resp.text}
104 ${status}= Get From Dictionary ${resp.json()} status
105 Should Be Equal As Strings ${resp.status_code} 200
106 Should Be Equal As Strings ${status} Permit
108 GetAbbreviatedDecisionResult
109 [Documentation] Get Decision with abbreviated results from Policy Xacml PDP
110 ${auth}= Create List healthcheck zb!XztG34
111 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json
112 Log Creating session https://${POLICY_PDPX_IP}:6969
113 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
114 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
115 ${params}= Create Dictionary abbrev=true
116 ${resp}= Post Request policy /policy/pdpx/v1/decision params=${params} data=${postjson} headers=${headers}
117 Log Received response from policy ${resp.text}
118 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
119 Should Be Equal As Strings ${resp.status_code} 200
120 Dictionary Should Contain Key ${policy} type
121 Dictionary Should Contain Key ${policy} metadata
122 Dictionary Should Not Contain Key ${policy} type_version
123 Dictionary Should Not Contain Key ${policy} properties
124 Dictionary Should Not Contain Key ${policy} name
125 Dictionary Should Not Contain Key ${policy} version
127 GetMonitoringDecision
128 [Documentation] Get Decision from Monitoring Policy Xacml PDP
129 ${auth}= Create List healthcheck zb!XztG34
130 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json
131 Log Creating session https://${POLICY_PDPX_IP}:6969
132 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
133 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
134 ${resp}= Post Request policy /policy/pdpx/v1/decision data=${postjson} headers=${headers}
135 Log Received response from policy ${resp.text}
136 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
137 Should Be Equal As Strings ${resp.status_code} 200
138 Dictionary Should Contain Key ${policy} type
139 Dictionary Should Contain Key ${policy} metadata
140 Dictionary Should Contain Key ${policy} type_version
141 Dictionary Should Contain Key ${policy} properties
142 Dictionary Should Contain Key ${policy} name
143 Dictionary Should Contain Key ${policy} version
146 [Documentation] Get Decision from Naming Policy Xacml PDP
147 ${auth}= Create List healthcheck zb!XztG34
148 ${postjson}= Get file ${CURDIR}/data/onap.policy.naming.decision.request.json
149 Log Creating session https://${POLICY_PDPX_IP}:6969
150 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
151 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
152 ${resp}= Post Request policy /policy/pdpx/v1/decision data=${postjson} headers=${headers}
153 Log Received response from policy ${resp.text}
154 ${policy}= Get From Dictionary ${resp.json()['policies']} SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP
155 Should Be Equal As Strings ${resp.status_code} 200
156 Dictionary Should Contain Key ${policy} type
157 Dictionary Should Contain Key ${policy} type_version
158 Dictionary Should Contain Key ${policy} properties
159 Dictionary Should Contain Key ${policy} name
161 GetOptimizationDecision
162 [Documentation] Get Decision from Optimization Policy Xacml PDP
163 ${auth}= Create List healthcheck zb!XztG34
164 ${postjson}= Get file ${CURDIR}/data/onap.policy.optimization.decision.request.json
165 Log Creating session https://${POLICY_PDPX_IP}:6969
166 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
167 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
168 ${resp}= Post Request policy /policy/pdpx/v1/decision data=${postjson} headers=${headers}
169 Log Received response from policy ${resp.text}
170 ${policy}= Get From Dictionary ${resp.json()['policies']} OSDF_CASABLANCA.Affinity_Default
171 Should Be Equal As Strings ${resp.status_code} 200
172 Dictionary Should Contain Key ${policy} type
173 Dictionary Should Contain Key ${policy} type_version
174 Dictionary Should Contain Key ${policy} properties
175 Dictionary Should Contain Key ${policy} name
177 GetStatisticsAfterDecision
178 [Documentation] Runs Policy Xacml PDP Statistics after Decision request
179 ${auth}= Create List healthcheck zb!XztG34
180 Log Creating session https://${POLICY_PDPX_IP}:6969
181 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
182 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
183 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
184 Log Received response from policy ${resp.text}
185 Should Be Equal As Strings ${resp.status_code} 200
186 Should Be Equal As Strings ${resp.json()['code']} 200
187 Should Be Equal As Strings ${resp.json()['totalDecisionsCount'] 1
189 UndeployMonitorPolicy
190 [Documentation] Runs Policy PAP to undeploy a policy
191 ${auth}= Create List healthcheck zb!XztG34
192 Log Creating session https://${POLICY_PAP_IP}:6969
193 ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth}
194 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
195 ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/onap.restart.tca headers=${headers}
196 Log Received response from policy ${resp.text}
197 Should Be Equal As Strings ${resp.status_code} 200
199 GetStatisticsAfterUndeploy
200 [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed
201 ${auth}= Create List healthcheck zb!XztG34
202 Log Creating session https://${POLICY_PDPX_IP}:6969
203 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
204 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
205 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
206 Log Received response from policy ${resp.text}
207 Should Be Equal As Strings ${resp.status_code} 200
208 Should Be Equal As Strings ${resp.json()['code']} 200
209 Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 0