blob: 250e01f1f815ef0e072513a0ce58355103e025eb [file] [log] [blame]
Michael Mokry88f4d472019-03-04 12:00:05 -06001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
5Library json
6
7*** Test Cases ***
8Healthcheck
9 [Documentation] Runs Policy Xacml PDP Health check
Jim Hahn5785bf82020-04-16 18:32:27 -040010 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryed8bae52019-03-12 15:10:53 -050011 Log Creating session https://${POLICY_PDPX_IP}:6969
12 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
Michael Mokry88f4d472019-03-04 12:00:05 -060013 ${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
18
19Statistics
20 [Documentation] Runs Policy Xacml PDP Statistics
HOCKLA2e519f52019-10-23 13:00:00 -050021 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryed8bae52019-03-12 15:10:53 -050022 Log Creating session https://${POLICY_PDPX_IP}:6969
23 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
Michael Mokry88f4d472019-03-04 12:00:05 -060024 ${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
HOCKLA2e519f52019-10-23 13:00:00 -050029
Michael Mokryb4f69622019-05-13 13:09:17 -050030ExecuteXacmlPolicy
Jim Hahn514799f2020-04-20 12:05:50 -040031 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
Jim Hahn5785bf82020-04-16 18:32:27 -040035 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
Jim Hahn514799f2020-04-20 12:05:50 -040038 Wait Until Keyword Succeeds 0 min 15 sec GetOptimizationDecision
HOCKLA2e519f52019-10-23 13:00:00 -050039
Michael Mokryb4f69622019-05-13 13:09:17 -050040*** Keywords ***
41
Jim Hahn514799f2020-04-20 12:05:50 -040042CreateMonitorPolicy
43 [Documentation] Create a Monitoring policy
Michael Mokryb4f69622019-05-13 13:09:17 -050044 ${auth}= Create List healthcheck zb!XztG34
Jim Hahn514799f2020-04-20 12:05:50 -040045 ${postjson}= Get file ${DATA2}/vCPE.policy.monitoring.input.tosca.json
Michael Mokryb4f69622019-05-13 13:09:17 -050046 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
55
Jim Hahn514799f2020-04-20 12:05:50 -040056CreateOptimizationPolicy
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
69
70DeployPolicies
Michael Mokryb4f69622019-05-13 13:09:17 -050071 [Documentation] Runs Policy PAP to deploy a policy
72 ${auth}= Create List healthcheck zb!XztG34
Jim Hahn514799f2020-04-20 12:05:50 -040073 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.input.tosca.deploy.json
Michael Mokryb4f69622019-05-13 13:09:17 -050074 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
81
82GetStatisticsAfterDeployed
83 [Documentation] Runs Policy Xacml PDP Statistics after policy is deployed
HOCKLA2e519f52019-10-23 13:00:00 -050084 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryb4f69622019-05-13 13:09:17 -050085 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
HOCKLA2e519f52019-10-23 13:00:00 -050093
Jim Hahn514799f2020-04-20 12:05:50 -040094GetDefaultDecision
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
107
HOCKLA2e519f52019-10-23 13:00:00 -0500108GetAbbreviatedDecisionResult
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
126
Jim Hahn5785bf82020-04-16 18:32:27 -0400127GetMonitoringDecision
128 [Documentation] Get Decision from Monitoring Policy Xacml PDP
Michael Mokryb4f69622019-05-13 13:09:17 -0500129 ${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}
HOCKLA2e519f52019-10-23 13:00:00 -0500136 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
Michael Mokryb4f69622019-05-13 13:09:17 -0500137 Should Be Equal As Strings ${resp.status_code} 200
HOCKLA2e519f52019-10-23 13:00:00 -0500138 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
Jim Hahn5785bf82020-04-16 18:32:27 -0400144
145GetNamingDecision
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}
Jim Hahnddb40432020-04-29 11:14:31 -0400154 ${policy}= Get From Dictionary ${resp.json()['policies']} SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP
Jim Hahn5785bf82020-04-16 18:32:27 -0400155 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
160
Jim Hahn514799f2020-04-20 12:05:50 -0400161GetOptimizationDecision
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
176
Michael Mokryb4f69622019-05-13 13:09:17 -0500177GetStatisticsAfterDecision
178 [Documentation] Runs Policy Xacml PDP Statistics after Decision request
Jim Hahn5785bf82020-04-16 18:32:27 -0400179 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryb4f69622019-05-13 13:09:17 -0500180 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
Jim Hahn5785bf82020-04-16 18:32:27 -0400188
Michael Mokryb4f69622019-05-13 13:09:17 -0500189UndeployMonitorPolicy
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
Jim Hahn5785bf82020-04-16 18:32:27 -0400198
Michael Mokryb4f69622019-05-13 13:09:17 -0500199GetStatisticsAfterUndeploy
200 [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed
Jim Hahn5785bf82020-04-16 18:32:27 -0400201 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryb4f69622019-05-13 13:09:17 -0500202 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