Newer
Older
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
276
277
278
279
280
281
282
283
284
285
286
*** Settings ***
Resource /opt/robot-tests/tests/resources/common.resource
Library /opt/robot-tests/tests/libraries/bodyRequests.py
Library XML
Library String
Resource /opt/robot-tests/tests/resources/common/basicRequests.robot
Resource ../../resources/common.resource
Suite Teardown Reset Testing Environment
Test Setup Reset Testing Environment
Test Teardown Reset Testing Environment
*** Variables ***
${API_INVOKER_NOT_REGISTERED} not-valid
${SUBSCRIBER_ID_NOT_VALID} not-valid
${SUBSCRIPTION_ID_NOT_VALID} not-valid
*** Test Cases ***
Invoker receives Service API Invocation events
[Tags] api_status-1 mockserver smoke
# Initialize Mock server
Init Mock Server
# Default Invoker Registration and Onboarding
${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding
# Register APF
${register_user_info_provider}= Provider Default Registration
${aef_id}= Set Variable ${register_user_info_provider['aef_id']}
# Subscribe to events
${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE
${aef_ids}= Create List ${register_user_info_provider['aef_id']}
${event_filter}= Create Capif Event Filter aefIds=${aef_ids}
${event_filters}= Create List ${event_filter}
${request_body}= Create Events Subscription
... events=@{events_list}
... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
... event_filters=${event_filters}
... supported_features=4
${resp}= Post Request Capif
... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions
... json=${request_body}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${INVOKER_USERNAME}
# Check Results
Check Response Variable Type And Values ${resp} 201 EventSubscription
${subscriber_id} ${subscription_id}= Check Event Location Header ${resp}
# Publish one api
${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api
... ${register_user_info_provider}
... service_1
# Provider Remove service_1 published API
${resp}= Delete Request Capif
... ${resource_url.path}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${APF_PROVIDER_USERNAME}
Status Should Be 204 ${resp}
# Check Event Notifications
## Create check Events to ensure all notifications were received
${service_api_available_resources}= Create List ${resource_url}
${service_api_unavailable_resources}= Create List ${resource_url}
${events_expected}= Create Expected Events For Service API Notifications
... subscription_id=${subscription_id}
... service_api_available_resources=${service_api_available_resources}
... service_api_unavailable_resources=${service_api_unavailable_resources}
## Check Events Expected towards received notifications at mock server
Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected}
*** Keywords ***
Create Events From InvocationLogs
[Arguments]
... ${subscription_id}
... ${invocation_log}
... ${events_expected}=${NONE}
... ${event_detail_expected}=${TRUE}
IF ${events_expected} == ${NONE}
${events_expected}= Create List
END
# Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present.
${invocation_log_base}= Copy Dictionary ${invocation_log} deepcopy=True
# Store log array because each log will be notified in one Event Notification
${invocation_log_logs}= Copy List ${invocation_log_base['logs']}
# Remove logs array from invocationLog data
Remove From Dictionary ${invocation_log_base} logs
FOR ${log} IN @{invocation_log_logs}
Log Dictionary ${log}
${invocation_logs}= Copy Dictionary ${invocation_log_base} deepcopy=True
# Get Event Enum for this result
${event_enum}= Set Variable
IF ${log['result']} >= 200 and ${log['result']} < 300
${event_enum}= Set Variable SERVICE_API_INVOCATION_SUCCESS
ELSE
${event_enum}= Set Variable SERVICE_API_INVOCATION_FAILURE
END
# Create a log array with only one component
${log_list}= Create List ${log}
# Setup logs array with previously created list
Set To Dictionary ${invocation_logs} logs=${log_list}
IF "${event_detail_expected}" != "${TRUE}"
${invocation_logs}= Set Variable ${NONE}
END
${event_expected}= Create Notification Event
... ${subscription_id}
... ${event_enum}
... invocationLogs=${invocation_logs}
Append To List ${events_expected} ${event_expected}
END
RETURN ${events_expected}
Create Expected Events For Service API Notifications
[Arguments]
... ${subscription_id}
... ${service_api_available_resources}=${NONE}
... ${service_api_unavailable_resources}=${NONE}
... ${events_expected}=${NONE}
... ${event_detail_expected}=${TRUE}
IF ${events_expected} == ${NONE}
${events_expected}= Create List
END
IF "${service_api_available_resources}" != "${NONE}"
FOR ${service_api_available_resource} IN @{service_api_available_resources}
Log ${service_api_available_resource}
${api_id}= Fetch From Right ${service_api_available_resource.path} /
IF "${event_detail_expected}" != "${TRUE}"
${api_id}= Set Variable ${NONE}
END
${event_expected}= Create Notification Event
... ${subscription_id}
... SERVICE_API_AVAILABLE
... apiIds=${api_id}
Append To List ${events_expected} ${event_expected}
END
END
IF "${service_api_unavailable_resources}" != "${NONE}"
FOR ${service_api_unavailable_resource} IN @{service_api_unavailable_resources}
Log ${service_api_unavailable_resource}
${api_id}= Fetch From Right ${service_api_unavailable_resource.path} /
IF "${event_detail_expected}" != "${TRUE}"
${api_id}= Set Variable ${NONE}
END
${event_expected}= Create Notification Event
... ${subscription_id}
... SERVICE_API_UNAVAILABLE
... apiIds=${api_id}
Append To List ${events_expected} ${event_expected}
END
END
RETURN ${events_expected}
Create Expected Api Invoker Events
[Arguments]
... ${subscription_id}
... ${api_invoker_id}
... ${events_expected}=${NONE}
... ${event_detail_expected}=${TRUE}
IF ${events_expected} == ${NONE}
${events_expected}= Create List
END
${api_invoker_id_used}= Set Variable ${api_invoker_id}
IF "${event_detail_expected}" != "${TRUE}"
${api_invoker_id_used}= Set Variable ${NONE}
END
## Create events expected
# Create Notification Events expected to be received for Onboard event
${event_expected}= Create Notification Event
... ${subscription_id}
... API_INVOKER_ONBOARDED
... apiInvokerIds=${api_invoker_id_used}
Append To List ${events_expected} ${event_expected}
# Create Notification Events expected to be received for Updated event
${event_expected}= Create Notification Event
... ${subscription_id}
... API_INVOKER_UPDATED
... apiInvokerIds=${api_invoker_id_used}
Append To List ${events_expected} ${event_expected}
# Create Notification Events expected to be received for Offboard event
${event_expected}= Create Notification Event
... ${subscription_id}
... API_INVOKER_OFFBOARDED
... apiInvokerIds=${api_invoker_id_used}
Append To List ${events_expected} ${event_expected}
RETURN ${events_expected}
Create Expected Access Control Policy Update Event
[Arguments]
... ${subscription_id}
... ${service_api_id}
... ${api_invoker_policies}
... ${events_expected}=${NONE}
... ${event_detail_expected}=${TRUE}
IF ${events_expected} == ${NONE}
${events_expected}= Create List
END
${acc_ctrl_pol_list}= Create Dictionary apiId=${service_api_id} apiInvokerPolicies=${api_invoker_policies}
Check Variable ${acc_ctrl_pol_list} AccessControlPolicyListExt
IF "${event_detail_expected}" != "${TRUE}"
${acc_ctrl_pol_list}= Set Variable ${NONE}
END
${event_expected}= Create Notification Event
... ${subscription_id}
... ACCESS_CONTROL_POLICY_UPDATE
... accCtrlPolList=${acc_ctrl_pol_list}
Append To List ${events_expected} ${event_expected}
RETURN ${events_expected}
Create Expected Access Control Policy Unavailable
[Arguments] ${subscription_id}
... ${events_expected}=${NONE}
IF ${events_expected} == ${NONE}
${events_expected}= Create List
END
${event_expected}= Create Notification Event
... ${subscription_id}
... ACCESS_CONTROL_POLICY_UNAVAILABLE
Append To List ${events_expected} ${event_expected}
RETURN ${events_expected}
Create Expected Api Invoker Authorization Revoked
[Arguments] ${subscription_id} ${events_expected}=${NONE}
IF ${events_expected} == ${NONE}
${events_expected}= Create List
END
${event_expected}= Create Notification Event
... ${subscription_id}
... API_INVOKER_AUTHORIZATION_REVOKED
Append To List ${events_expected} ${event_expected}
RETURN ${events_expected}
Create Expected Service Update Event
[Arguments]
... ${subscription_id}
... ${service_api_resource}
... ${service_api_descriptions}
... ${events_expected}=${NONE}
... ${event_detail_expected}=${TRUE}
IF ${events_expected} == ${NONE}
${events_expected}= Create List
END
${api_id}= Fetch From Right ${service_api_resource.path} /
Set To Dictionary ${service_api_descriptions} apiId=${api_id}
IF "${event_detail_expected}" != "${TRUE}"
${service_api_descriptions}= Set Variable ${NONE}
END
${events_expected}= Create List
${event_expected}= Create Notification Event
... ${subscription_id}
... SERVICE_API_UPDATE
... serviceAPIDescriptions=${service_api_descriptions}
Append To List ${events_expected} ${event_expected}
RETURN ${events_expected}