aboutsummaryrefslogtreecommitdiffstats
path: root/tests/policy/drools-applications/drools-applications-test.robot
blob: a1ca5e208bff940070f25c8d14b9cf14506d4e73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
*** Settings ***
Library     Collections
Library     String
Library     RequestsLibrary
Library     OperatingSystem
Library     Process
Library     json

*** Test Cases ***
Alive
    [Documentation]    Runs Policy PDP Alive Check
    ${auth}=    Create List    demo@people.osaaf.org    demo123456!
    Log    Creating session https://${DROOLS_IP}:9696
    ${session}=    Create Session      policy  https://${DROOLS_IP}:9696   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
    ${resp}=   Get Request     policy  /policy/pdp/engine     headers=${headers}
    Log    Received response from policy ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}     200
    Should Be Equal As Strings    ${resp.json()['alive']}  True

Healthcheck
    [Documentation]    Runs Policy PDP-D Health check
    ${auth}=    Create List    demo@people.osaaf.org    demo123456!
    Log    Creating session https://${DROOLS_IP}:6969/healthcheck
    ${session}=    Create Session      policy  https://${DROOLS_IP}:6969   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
    ${resp}=   Get Request     policy  /healthcheck     headers=${headers}
    Log    Received response from policy ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}     200
    Should Be Equal As Strings    ${resp.json()['healthy']}  True

Controller
    [Documentation]    Checks controller is up
    ${auth}=    Create List    demo@people.osaaf.org    demo123456!
    Log    Creating session https://${DROOLS_IP}:9696
    ${session}=    Create Session      policy  https://${DROOLS_IP}:9696   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
    ${resp}=   Get Request     policy  /policy/pdp/engine/controllers/frankfurt/drools/facts     headers=${headers}
    Log    Received response from policy ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}     200
    Should Be Equal As Strings    ${resp.json()['frankfurt']}  0

MakeTopics
    [Documentation]    Creates the Policy topics
    ${result}=     Run Process        ${SCR2}/make_topic.sh     POLICY-PDP-PAP
    Should Be Equal As Integers        ${result.rc}    0
    ${result}=     Run Process        ${SCR2}/make_topic.sh     POLICY-CL-MGT
    Should Be Equal As Integers        ${result.rc}    0

CreateVcpeXacmlPolicy
    [Documentation]    Create VCPE Policy for Xacml
    ${auth}=    Create List    healthcheck    zb!XztG34
    ${postyaml}=  Get file  ${DATA}/vCPE.policy.monitoring.input.tosca.yaml
    Log    Creating session https://${API_IP}:6969
    ${session}=    Create Session      policy  https://${API_IP}:6969   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
    ${resp}=   Post Request   policy  /policy/api/v1/policies  data=${postyaml}   headers=${headers}
    Log    Received response from api ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}    200

CreateVcpeDroolsPolicy
    [Documentation]    Create VCPE Policy for Drools
    ${auth}=    Create List    healthcheck    zb!XztG34
    ${postyaml}=  Get file  ${DATA}/vCPE.policy.operational.input.tosca.yaml
    Log    Creating session https://${API_IP}:6969
    ${session}=    Create Session      policy  https://${API_IP}:6969   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
    ${resp}=   Post Request   policy  /policy/api/v1/policies  data=${postyaml}   headers=${headers}
    Log    Received response from api ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}    200

CreateVdnsXacmlPolicy
    [Documentation]    Create VDNS Policy for Xacml
    ${auth}=    Create List    healthcheck    zb!XztG34
    ${postyaml}=  Get file  ${DATA}/vDNS.policy.monitoring.input.tosca.yaml
    Log    Creating session https://${API_IP}:6969
    ${session}=    Create Session      policy  https://${API_IP}:6969   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
    ${resp}=   Post Request   policy  /policy/api/v1/policies  data=${postyaml}   headers=${headers}
    Log    Received response from api ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}    200

CreateVdnsDroolsPolicy
    [Documentation]    Create VDNS Policy for Drools
    ${auth}=    Create List    healthcheck    zb!XztG34
    ${postjson}=  Get file  ${DATA}/vDNS.policy.operational.input.tosca.json
    Log    Creating session https://${API_IP}:6969
    ${session}=    Create Session      policy  https://${API_IP}:6969   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
    ${resp}=   Post Request   policy  /policy/api/v1/policies  data=${postjson}   headers=${headers}
    Log    Received response from api ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}    200

CreateVfwXacmlPolicy
    [Documentation]    Create VFW Policy for Xacml
    ${auth}=    Create List    healthcheck    zb!XztG34
    ${postyaml}=  Get file  ${DATA}/vFirewall.policy.monitoring.input.tosca.yaml
    Log    Creating session https://${API_IP}:6969
    ${session}=    Create Session      policy  https://${API_IP}:6969   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/yaml    Content-Type=application/yaml
    ${resp}=   Post Request   policy  /policy/api/v1/policies  data=${postyaml}   headers=${headers}
    Log    Received response from api ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}    200

CreateVfwDroolsPolicy
    [Documentation]    Create VFW Policy for Drools
    ${auth}=    Create List    healthcheck    zb!XztG34
    ${postjson}=  Get file  ${DATA}/vFirewall.policy.operational.input.tosca.json
    Log    Creating session https://${API_IP}:6969
    ${session}=    Create Session      policy  https://${API_IP}:6969   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
    ${resp}=   Post Request   policy  /policy/api/v1/policies  data=${postjson}   headers=${headers}
    Log    Received response from api ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}    200

DeployXacmlPolicies
    [Documentation]    Deploys the Policies to Xacml
    ${auth}=    Create List    healthcheck    zb!XztG34
    Log    Creating session https://${PAP_IP}:6969
    ${postjson}=  Get file  ${SCR2}/deploy.xacml.policies.json
    ${session}=    Create Session      policy  https://${PAP_IP}:6969   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
    ${resp}=   Post Request     policy  /policy/pap/v1/pdps/deployments/batch    data=${postjson}     headers=${headers}
    Log    Received response from pap ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}     200
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-PDP-PAP
    ...            responseTo    xacml    ACTIVE    restart
    Log    Received status ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    onap.restart.tca
    Should Contain    ${result.stdout}    onap.scaleout.tca
    Should Contain    ${result.stdout}    onap.vfirewall.tca

DeployDroolsPolicies
    [Documentation]    Deploys the Policies to Drools
    ${auth}=    Create List    healthcheck    zb!XztG34
    Log    Creating session https://${PAP_IP}:6969
    ${postjson}=  Get file  ${SCR2}/deploy.drools.policies.json
    ${session}=    Create Session      policy  https://${PAP_IP}:6969   auth=${auth}
    ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
    ${resp}=   Post Request     policy  /policy/pap/v1/pdps/deployments/batch    data=${postjson}     headers=${headers}
    Log    Received response from pap ${resp.text}
    Should Be Equal As Strings    ${resp.status_code}     200
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-PDP-PAP
    ...            responseTo    drools    ACTIVE
    Log    Received status ${result.stdout}
    Sleep    3s
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    operational.restart
    Should Contain    ${result.stdout}    operational.scaleout
    Should Contain    ${result.stdout}    operational.modifyconfig

VcpeExecute
    [Documentation]    Executes VCPE Policy
    ${result}=     Run Process        ${SCR2}/onset.sh     ${SCR2}/vcpeOnset.json
    Should Be Equal As Integers        ${result.rc}    0
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    ACTIVE
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION
    Should Contain    ${result.stdout}    Sending guard query for APPC Restart
    Should Be Equal As Integers        ${result.rc}    0
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION
    Should Contain    ${result.stdout}    Guard result for APPC Restart is Permit
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION
    Should Contain    ${result.stdout}    actor=APPC,operation=Restart
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION: SUCCESS
    Should Contain    ${result.stdout}    actor=APPC,operation=Restart
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    FINAL: SUCCESS
    Should Contain    ${result.stdout}    APPC
    Should Contain    ${result.stdout}    Restart

VdnsExecute
    [Documentation]    Executes VDNS Policy
    ${result}=     Run Process        ${SCR2}/onset.sh     ${SCR2}/vdnsOnset.json
    Should Be Equal As Integers        ${result.rc}    0
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    ACTIVE
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION
    Should Contain    ${result.stdout}    Sending guard query for SO VF Module Create
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION
    Should Contain    ${result.stdout}    Guard result for SO VF Module Create is Permit
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION
    Should Contain    ${result.stdout}    actor=SO,operation=VF Module Create
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION: SUCCESS
    Should Contain    ${result.stdout}    actor=SO,operation=VF Module Create
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    FINAL: SUCCESS
    Should Contain    ${result.stdout}    SO
    Should Contain    ${result.stdout}    VF Module Create

VfwExecute
    [Documentation]    Executes VFW Policy
    ${result}=     Run Process        ${SCR2}/onset.sh     ${SCR2}/vfwOnset.json
    Should Be Equal As Integers        ${result.rc}    0
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    ACTIVE
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION
    Should Contain    ${result.stdout}    Sending guard query for APPC ModifyConfig
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION
    Should Contain    ${result.stdout}    Guard result for APPC ModifyConfig is Permit
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION
    Should Contain    ${result.stdout}    actor=APPC,operation=ModifyConfig
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    OPERATION: SUCCESS
    Should Contain    ${result.stdout}    actor=APPC,operation=ModifyConfig
    ${result}=     Run Process        ${SCR2}/wait_topic.sh     POLICY-CL-MGT
    ...            ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a
    Log    Received notification ${result.stdout}
    Should Be Equal As Integers        ${result.rc}    0
    Should Contain    ${result.stdout}    FINAL: SUCCESS
    Should Contain    ${result.stdout}    APPC
    Should Contain    ${result.stdout}    ModifyConfig