blob: 8227996f9b42d1bce89680af8395bd010e7f750f [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
10 ${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
31 Wait Until Keyword Succeeds 2 min 5 sec CreateMonitorPolicyType
32 Wait Until Keyword Succeeds 2 min 5 sec CreateNewMonitorPolicy
33 Wait Until Keyword Succeeds 2 min 5 sec DeployMonitorPolicy
HOCKLA2e519f52019-10-23 13:00:00 -050034 Wait Until Keyword Succeeds 2 min 10 sec GetAbbreviatedDecisionResult
Michael Mokryb4f69622019-05-13 13:09:17 -050035 Wait Until Keyword Succeeds 2 min 10 sec GetDecision
HOCKLA2e519f52019-10-23 13:00:00 -050036
Michael Mokryb4f69622019-05-13 13:09:17 -050037*** Keywords ***
38
39CreateMonitorPolicyType
40 [Documentation] Create Monitoring Policy Type
41 ${auth}= Create List healthcheck zb!XztG34
42 ${postjson}= Get file ${CURDIR}/data/onap.policies.monitoring.cdap.tca.hi.lo.app.json
43 Log Creating session https://${POLICY_API_IP}:6969
44 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
45 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
46 ${resp}= Post Request policy /policy/api/v1/policytypes data=${postjson} headers=${headers}
47 Log Received response from policy2 ${resp.text}
48 Should Be Equal As Strings ${resp.status_code} 200
49 ${postjsonobject} To Json ${postjson}
50 Dictionary Should Contain Key ${resp.json()} tosca_definitions_version
51 Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version
52
53CreateNewMonitorPolicy
54 [Documentation] Create a new Monitoring policy
55 ${auth}= Create List healthcheck zb!XztG34
56 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.json
57 Log Creating session https://${POLICY_API_IP}:6969
58 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
59 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
60 ${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}
61 Log Received response from policy4 ${resp.text}
62 ${postjsonobject} To Json ${postjson}
63 Should Be Equal As Strings ${resp.status_code} 200
64 Dictionary Should Contain Key ${resp.json()} tosca_definitions_version
65 Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version
66
67DeployMonitorPolicy
68 [Documentation] Runs Policy PAP to deploy a policy
69 ${auth}= Create List healthcheck zb!XztG34
70 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.deploy.json
71 Log Creating session https://${POLICY_PAP_IP}:6969
72 ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth}
73 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
74 ${resp}= Post Request policy /policy/pap/v1/pdps/policies data=${postjson} headers=${headers}
75 Log Received response from policy5 ${resp.text}
76 ${postjsonobject} To Json ${postjson}
77 Should Be Equal As Strings ${resp.status_code} 200
78
79GetStatisticsAfterDeployed
80 [Documentation] Runs Policy Xacml PDP Statistics after policy is deployed
HOCKLA2e519f52019-10-23 13:00:00 -050081 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryb4f69622019-05-13 13:09:17 -050082 Log Creating session https://${POLICY_PDPX_IP}:6969
83 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
84 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
85 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
86 Log Received response from policy ${resp.text}
87 Should Be Equal As Strings ${resp.status_code} 200
88 Should Be Equal As Strings ${resp.json()['code']} 200
89 Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 1
HOCKLA2e519f52019-10-23 13:00:00 -050090
91GetAbbreviatedDecisionResult
92 [Documentation] Get Decision with abbreviated results from Policy Xacml PDP
93 ${auth}= Create List healthcheck zb!XztG34
94 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json
95 Log Creating session https://${POLICY_PDPX_IP}:6969
96 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
97 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
98 ${params}= Create Dictionary abbrev=true
99 ${resp}= Post Request policy /policy/pdpx/v1/decision params=${params} data=${postjson} headers=${headers}
100 Log Received response from policy ${resp.text}
101 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
102 Should Be Equal As Strings ${resp.status_code} 200
103 Dictionary Should Contain Key ${policy} type
104 Dictionary Should Contain Key ${policy} metadata
105 Dictionary Should Not Contain Key ${policy} type_version
106 Dictionary Should Not Contain Key ${policy} properties
107 Dictionary Should Not Contain Key ${policy} name
108 Dictionary Should Not Contain Key ${policy} version
109
Michael Mokryb4f69622019-05-13 13:09:17 -0500110GetDecision
111 [Documentation] Get Decision from Policy Xacml PDP
112 ${auth}= Create List healthcheck zb!XztG34
113 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json
114 Log Creating session https://${POLICY_PDPX_IP}:6969
115 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
116 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
117 ${resp}= Post Request policy /policy/pdpx/v1/decision data=${postjson} headers=${headers}
118 Log Received response from policy ${resp.text}
HOCKLA2e519f52019-10-23 13:00:00 -0500119 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
Michael Mokryb4f69622019-05-13 13:09:17 -0500120 Should Be Equal As Strings ${resp.status_code} 200
HOCKLA2e519f52019-10-23 13:00:00 -0500121 Dictionary Should Contain Key ${policy} type
122 Dictionary Should Contain Key ${policy} metadata
123 Dictionary Should Contain Key ${policy} type_version
124 Dictionary Should Contain Key ${policy} properties
125 Dictionary Should Contain Key ${policy} name
126 Dictionary Should Contain Key ${policy} version
Michael Mokryb4f69622019-05-13 13:09:17 -0500127
128GetStatisticsAfterDecision
129 [Documentation] Runs Policy Xacml PDP Statistics after Decision request
130 ${auth}= Create List healthcheck zb!XztG34
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}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
135 Log Received response from policy ${resp.text}
136 Should Be Equal As Strings ${resp.status_code} 200
137 Should Be Equal As Strings ${resp.json()['code']} 200
138 Should Be Equal As Strings ${resp.json()['totalDecisionsCount'] 1
139
140UndeployMonitorPolicy
141 [Documentation] Runs Policy PAP to undeploy a policy
142 ${auth}= Create List healthcheck zb!XztG34
143 Log Creating session https://${POLICY_PAP_IP}:6969
144 ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth}
145 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
146 ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/onap.restart.tca headers=${headers}
147 Log Received response from policy ${resp.text}
148 Should Be Equal As Strings ${resp.status_code} 200
149
150GetStatisticsAfterUndeploy
151 [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed
152 ${auth}= Create List healthcheck zb!XztG34
153 Log Creating session https://${POLICY_PDPX_IP}:6969
154 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
155 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
156 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
157 Log Received response from policy ${resp.text}
158 Should Be Equal As Strings ${resp.status_code} 200
159 Should Be Equal As Strings ${resp.json()['code']} 200
160 Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 0
161
162