Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
${subscriber_id} ${subscription_id}= Check Event Location Header ${resp}
# Test
${discover_response}= Get Request Capif
... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${INVOKER_USERNAME}
Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs
# create Security Context
${request_service_security_body}= Create Service Security From Discover Response
... http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/test
... ${discover_response}
${resp}= Put Request Capif
... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']}
... json=${request_service_security_body}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${INVOKER_USERNAME}
# Check Service Security
Check Response Variable Type And Values ${resp} 201 ServiceSecurity
${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX}
${resp}= Get Request Capif
... /access-control-policy/v1/accessControlPolicyList/${service_api_id}?aef-id=${register_user_info_provider['aef_id']}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${AEF_PROVIDER_USERNAME}
Check Response Variable Type And Values ${resp} 200 AccessControlPolicyList
# Check returned values
Should Not Be Empty ${resp.json()['apiInvokerPolicies']}
Length Should Be ${resp.json()['apiInvokerPolicies']} 1
Should Be Equal As Strings
... ${resp.json()['apiInvokerPolicies'][0]['apiInvokerId']}
... ${register_user_info_invoker['api_invoker_id']}
${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']}
# Check Event Notifications
## Create check Events to ensure all notifications were received
${events_expected}= Create Expected Access Control Policy Update Event
... ${service_api_id}
... ${api_invoker_policies}
## Check Events Expected towards received notifications at mock server
Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected}
Provider receives an ACL unavailable event when invoker remove Security Context without Enhanced Event Report
[Tags] capif_api_events-19 mockserver
# Initialize Mock server
Init Mock Server
# Register APF
${register_user_info_provider}= Provider Default Registration
# Publish one api
${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api
... ${register_user_info_provider}
# Store apiId1
${serviceApiId}= Set Variable ${service_api_description_published['apiId']}
# Register INVOKER
${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding
# Subscribe to events
${events_list}= Create List ACCESS_CONTROL_POLICY_UNAVAILABLE
${request_body}= Create Events Subscription
... events=@{events_list}
... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
${resp}= Post Request Capif
... /capif-events/v1/${register_user_info_provider['amf_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}
# Test
${discover_response}= Get Request Capif
... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${INVOKER_USERNAME}
Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs
# create Security Context
${request_service_security_body}= Create Service Security From Discover Response
... http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/test
... ${discover_response}
${resp}= Put Request Capif
... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']}
... json=${request_service_security_body}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${INVOKER_USERNAME}
# Check Service Security
Check Response Variable Type And Values ${resp} 201 ServiceSecurity
${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX}
# Remove Security Context by Provider
${resp}= Delete Request Capif
... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${AEF_PROVIDER_USERNAME}
Status Should Be 204 ${resp}
# Check Event Notifications
## Create check Events to ensure all notifications were received
${events_expected}= Create Expected Access Control Policy Unavailable
... ${subscription_id}
## Check Events Expected towards received notifications at mock server
Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected}
Invoker receives an Invoker Authorization Revoked and ACL unavailable event when Provider revoke Invoker Authorization without Enhanced Event Report
[Tags] capif_api_events-20 mockserver
# Initialize Mock server
Init Mock Server
# Register APF
${register_user_info_provider}= Provider Default Registration
# Publish one api
${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api
... ${register_user_info_provider}
# Store apiId1
${serviceApiId}= Set Variable ${service_api_description_published['apiId']}
# Register INVOKER
${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding
# Subscribe to events
${events_list}= Create List ACCESS_CONTROL_POLICY_UNAVAILABLE API_INVOKER_AUTHORIZATION_REVOKED
${request_body}= Create Events Subscription
... events=@{events_list}
... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
${resp}= Post Request Capif
... /capif-events/v1/${register_user_info_provider['amf_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}
# Test
${discover_response}= Get Request Capif
... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${INVOKER_USERNAME}
Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs
${api_ids}= Get Api Ids From Discover Response ${discover_response}
# create Security Context
${request_service_security_body}= Create Service Security From Discover Response
... http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/test
... ${discover_response}
${resp}= Put Request Capif
... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']}
... json=${request_service_security_body}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${INVOKER_USERNAME}
# Check Service Security
Check Response Variable Type And Values ${resp} 201 ServiceSecurity
${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX}
# Revoke Security Context by Provider
${request_body}= Create Security Notification Body
... ${register_user_info_invoker['api_invoker_id']}
... ${api_ids}
${resp}= Post Request Capif
... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']}/delete
... json=${request_body}
... server=${CAPIF_HTTPS_URL}
... verify=ca.crt
... username=${AEF_PROVIDER_USERNAME}
# Check Results
Status Should Be 204 ${resp}
# Check Event Notifications
## Create check Events to ensure all notifications were received
${events_expected}= Create Expected Access Control Policy Unavailable ${subscription_id}
${events_expected}= Create Expected Api Invoker Authorization Revoked
... ${subscription_id}
... events_expected=${events_expected}
## 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}
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
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}
IF ${events_expected} == ${NONE}
${events_expected}= Create List
END
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
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
RETURN ${events_expected}
[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 Notification Events expected to be received for Onboard event
${event_expected}= Create Notification Event
... ${subscription_id}
... API_INVOKER_ONBOARDED
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
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
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}