blob: 0305af8e9fd2ba91d5711680f3be28efb829b37e [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
Michael Mokryb4f69622019-05-13 13:09:17 -050031 Wait Until Keyword Succeeds 2 min 5 sec CreateNewMonitorPolicy
32 Wait Until Keyword Succeeds 2 min 5 sec DeployMonitorPolicy
HOCKLA2e519f52019-10-23 13:00:00 -050033 Wait Until Keyword Succeeds 2 min 10 sec GetAbbreviatedDecisionResult
Michael Mokryb4f69622019-05-13 13:09:17 -050034 Wait Until Keyword Succeeds 2 min 10 sec GetDecision
HOCKLA2e519f52019-10-23 13:00:00 -050035
Michael Mokryb4f69622019-05-13 13:09:17 -050036*** Keywords ***
37
Michael Mokryb4f69622019-05-13 13:09:17 -050038CreateNewMonitorPolicy
39 [Documentation] Create a new Monitoring policy
40 ${auth}= Create List healthcheck zb!XztG34
41 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.json
42 Log Creating session https://${POLICY_API_IP}:6969
43 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
44 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
45 ${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}
46 Log Received response from policy4 ${resp.text}
47 ${postjsonobject} To Json ${postjson}
48 Should Be Equal As Strings ${resp.status_code} 200
49 Dictionary Should Contain Key ${resp.json()} tosca_definitions_version
50 Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version
51
52DeployMonitorPolicy
53 [Documentation] Runs Policy PAP to deploy a policy
54 ${auth}= Create List healthcheck zb!XztG34
55 ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.deploy.json
56 Log Creating session https://${POLICY_PAP_IP}:6969
57 ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth}
58 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
59 ${resp}= Post Request policy /policy/pap/v1/pdps/policies data=${postjson} headers=${headers}
60 Log Received response from policy5 ${resp.text}
61 ${postjsonobject} To Json ${postjson}
62 Should Be Equal As Strings ${resp.status_code} 200
63
64GetStatisticsAfterDeployed
65 [Documentation] Runs Policy Xacml PDP Statistics after policy is deployed
HOCKLA2e519f52019-10-23 13:00:00 -050066 ${auth}= Create List healthcheck zb!XztG34
Michael Mokryb4f69622019-05-13 13:09:17 -050067 Log Creating session https://${POLICY_PDPX_IP}:6969
68 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
69 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
70 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
71 Log Received response from policy ${resp.text}
72 Should Be Equal As Strings ${resp.status_code} 200
73 Should Be Equal As Strings ${resp.json()['code']} 200
74 Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 1
HOCKLA2e519f52019-10-23 13:00:00 -050075
76GetAbbreviatedDecisionResult
77 [Documentation] Get Decision with abbreviated results from Policy Xacml PDP
78 ${auth}= Create List healthcheck zb!XztG34
79 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json
80 Log Creating session https://${POLICY_PDPX_IP}:6969
81 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
82 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
83 ${params}= Create Dictionary abbrev=true
84 ${resp}= Post Request policy /policy/pdpx/v1/decision params=${params} data=${postjson} headers=${headers}
85 Log Received response from policy ${resp.text}
86 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
87 Should Be Equal As Strings ${resp.status_code} 200
88 Dictionary Should Contain Key ${policy} type
89 Dictionary Should Contain Key ${policy} metadata
90 Dictionary Should Not Contain Key ${policy} type_version
91 Dictionary Should Not Contain Key ${policy} properties
92 Dictionary Should Not Contain Key ${policy} name
93 Dictionary Should Not Contain Key ${policy} version
94
Michael Mokryb4f69622019-05-13 13:09:17 -050095GetDecision
96 [Documentation] Get Decision from Policy Xacml PDP
97 ${auth}= Create List healthcheck zb!XztG34
98 ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json
99 Log Creating session https://${POLICY_PDPX_IP}:6969
100 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
101 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
102 ${resp}= Post Request policy /policy/pdpx/v1/decision data=${postjson} headers=${headers}
103 Log Received response from policy ${resp.text}
HOCKLA2e519f52019-10-23 13:00:00 -0500104 ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca
Michael Mokryb4f69622019-05-13 13:09:17 -0500105 Should Be Equal As Strings ${resp.status_code} 200
HOCKLA2e519f52019-10-23 13:00:00 -0500106 Dictionary Should Contain Key ${policy} type
107 Dictionary Should Contain Key ${policy} metadata
108 Dictionary Should Contain Key ${policy} type_version
109 Dictionary Should Contain Key ${policy} properties
110 Dictionary Should Contain Key ${policy} name
111 Dictionary Should Contain Key ${policy} version
Michael Mokryb4f69622019-05-13 13:09:17 -0500112
113GetStatisticsAfterDecision
114 [Documentation] Runs Policy Xacml PDP Statistics after Decision request
115 ${auth}= Create List healthcheck zb!XztG34
116 Log Creating session https://${POLICY_PDPX_IP}:6969
117 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
118 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
119 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
120 Log Received response from policy ${resp.text}
121 Should Be Equal As Strings ${resp.status_code} 200
122 Should Be Equal As Strings ${resp.json()['code']} 200
123 Should Be Equal As Strings ${resp.json()['totalDecisionsCount'] 1
124
125UndeployMonitorPolicy
126 [Documentation] Runs Policy PAP to undeploy a policy
127 ${auth}= Create List healthcheck zb!XztG34
128 Log Creating session https://${POLICY_PAP_IP}:6969
129 ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth}
130 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
131 ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/onap.restart.tca headers=${headers}
132 Log Received response from policy ${resp.text}
133 Should Be Equal As Strings ${resp.status_code} 200
134
135GetStatisticsAfterUndeploy
136 [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed
137 ${auth}= Create List healthcheck zb!XztG34
138 Log Creating session https://${POLICY_PDPX_IP}:6969
139 ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth}
140 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
141 ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers}
142 Log Received response from policy ${resp.text}
143 Should Be Equal As Strings ${resp.status_code} 200
144 Should Be Equal As Strings ${resp.json()['code']} 200
145 Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 0
146
147