From 8ff735480f6b20619804e7a6f425b95282cda15d Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Mon, 24 Feb 2025 18:35:53 +0100 Subject: [PATCH 01/12] New Event Filter test suite --- tests/features/Event Filter/__init__.robot | 2 + .../features/Event Filter/event_filter.robot | 248 ++++++++++++++++++ tests/libraries/api_events/bodyRequests.py | 25 +- tests/resources/common.resource | 6 +- 4 files changed, 272 insertions(+), 9 deletions(-) create mode 100644 tests/features/Event Filter/__init__.robot create mode 100644 tests/features/Event Filter/event_filter.robot diff --git a/tests/features/Event Filter/__init__.robot b/tests/features/Event Filter/__init__.robot new file mode 100644 index 00000000..2b28f206 --- /dev/null +++ b/tests/features/Event Filter/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Force Tags event_filter \ No newline at end of file diff --git a/tests/features/Event Filter/event_filter.robot b/tests/features/Event Filter/event_filter.robot new file mode 100644 index 00000000..19fb636b --- /dev/null +++ b/tests/features/Event Filter/event_filter.robot @@ -0,0 +1,248 @@ +*** 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 +Resource ../../resources/common/basicRequests.robot + +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 *** +Service API Available filtered by apiIds + [Tags] event_filter-1 mockserver + + # 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 total_aef_roles=2 + + ${aef_id_1}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} + ${aef_id_2}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} + ${aef_empty_list}= Create List + + # Publish api with 2 aefIds + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + ... service_1 + ... aef_id=${aef_ids} + ... api_status=${aef_empty_list} + ... supported_features=020 + + # Register other provider + ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_NEW + + ${aef2_id_1}= Set Variable ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} + + # Publish api with other provider + ${service_api_description_published_2} ${resource_url_2} ${request_body_2}= Publish Service Api + ... ${register_user_info_provider_2} + ... service_2 + ... aef_id=${aef2_id_1} + ... api_status=${aef2_id_1} + ... supported_features=020 + + # Discover APIs by invoker + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${aef_id_1} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + + # # Check Results + Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} + + ${api_id}= Set Variable ${resp.json()['serviceAPIDescriptions'][0]['apiId']} + + # Subscribe to events + ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE SERVICE_API_UPDATE + ${event_filter}= Create Capif Event Filter apiIds=${api_id} + ${event_filters}= Create List ${event_filter} ${event_filter} ${event_filter} + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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} + + # Update Request to published API + ${service_api_description_modified}= Create Service Api Description + ... service_1 + ... aef_id=${aef_ids} + ... supported_features=20 + ... api_status=${aef_ids} + ${resp}= Put Request Capif + ... ${resource_url.path} + ... json=${service_api_description_modified} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${APF_PROVIDER_USERNAME} + + Check Response Variable Type And Values ${resp} 200 ServiceAPIDescription + ... apiName=service_1 + Dictionary Should Contain Key ${resp.json()} apiStatus + + # 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} + + # Provider 2 Remove service_1 published API + ${resp}= Delete Request Capif + ... ${resource_url_2.path} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${APF_PROVIDER_USERNAME}_NEW + + 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} + ${events_expected}= Create Expected Events For Service API Notifications + ... subscription_id=${subscription_id} + ... service_api_available_resources=${service_api_available_resources} + ... event_detail_expected=${TRUE} + ... service_api_description_expected=${TRUE} + ... service_api_description=${service_api_description_modified} + Log List ${events_expected} + + ${events_expected}= Create Expected Service Update Event + ... subscription_id=${subscription_id} + ... service_api_resource=${resource_url} + ... service_api_descriptions=${service_api_description_modified} + ... events_expected=${events_expected} + Log List ${events_expected} + + ${service_api_unavailable_resources}= Create List ${resource_url} + ${events_expected}= Create Expected Events For Service API Notifications + ... subscription_id=${subscription_id} + ... service_api_unavailable_resources=${service_api_unavailable_resources} + ... event_detail_expected=${TRUE} + ... service_api_description_expected=${TRUE} + ... service_api_description=${service_api_description_modified} + ... events_expected=${events_expected} + Log List ${events_expected} + + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + + +Try error + [Tags] event_filter-2 mockserver + + # 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 total_aef_roles=2 + + ${aef_id_1}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} + ${aef_id_2}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} + ${aef_empty_list}= Create List + + # Publish api with 2 aefIds + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + ... service_1 + ... aef_id=${aef_ids} + ... api_status=${aef_empty_list} + ... supported_features=020 + + # Register other provider + ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_NEW + + ${aef2_id_1}= Set Variable ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} + + # Publish api with other provider + ${service_api_description_published_2} ${resource_url_2} ${request_body_2}= Publish Service Api + ... ${register_user_info_provider_2} + ... service_2 + ... aef_id=${aef2_id_1} + ... api_status=${aef2_id_1} + ... supported_features=020 + + # Discover APIs by invoker + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${aef_id_1} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + + # # Check Results + Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} + + ${api_id}= Set Variable ${resp.json()['serviceAPIDescriptions'][0]['apiId']} + + # Subscribe to events + ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE SERVICE_API_UPDATE + ${event_filter}= Create Capif Event Filter aefIds=${aef_ids} + ${event_filters}= Create List ${event_filter} ${event_filter} ${event_filter} + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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 + ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event SERVICE_API_AVAILABLE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=Bad Param + ... cause=Invalid eventFilter for event SERVICE_API_AVAILABLE + ... invalidParams=${invalid_param_list} diff --git a/tests/libraries/api_events/bodyRequests.py b/tests/libraries/api_events/bodyRequests.py index 20d82a40..1bb4604f 100644 --- a/tests/libraries/api_events/bodyRequests.py +++ b/tests/libraries/api_events/bodyRequests.py @@ -18,15 +18,24 @@ def create_events_subscription(events=["SERVICE_API_AVAILABLE", "API_INVOKER_ONB def create_capif_event_filter(aefIds=None, apiIds=None, apiInvokerIds=None): - if aefIds == None and apiIds == None and apiInvokerIds: - raise ("Error, no data present to create event filter") + # if aefIds == None and apiIds == None and apiInvokerIds: + # raise ("Error, no data present to create event filter") capif_event_filter = dict() - if aefIds != None: - capif_event_filter['aefIds'] = aefIds - if apiIds != None: - capif_event_filter['apiIds'] = apiIds - if apiInvokerIds != None: - capif_event_filter['apiInvokerIds'] = apiInvokerIds + if aefIds is not None: + if isinstance(aefIds, list): + capif_event_filter['aefIds'] = aefIds + else: + capif_event_filter['aefIds'] = [aefIds] + if apiIds is not None: + if isinstance(apiIds, list): + capif_event_filter['apiIds'] = apiIds + else: + capif_event_filter['apiIds'] = [apiIds] + if apiInvokerIds is not None: + if isinstance(apiInvokerIds, list): + capif_event_filter['apiInvokerIds'] = apiInvokerIds + else: + capif_event_filter['apiInvokerIds'] = [apiInvokerIds] return capif_event_filter diff --git a/tests/resources/common.resource b/tests/resources/common.resource index bf596b33..96b09429 100644 --- a/tests/resources/common.resource +++ b/tests/resources/common.resource @@ -84,7 +84,11 @@ Check Response Variable Type And Values Check Variable ${resp.json()} ${variable_type} FOR ${input} IN @{input_parameters} Log ${input}=${input_parameters['${input}']} - Should Match Regexp "${resp.json()['${input}']}" "${input_parameters['${input}']}" + IF "${input}"=="invalidParams" + Should Be Equal ${resp.json()['${input}']} ${input_parameters['${input}']} + ELSE + Should Match Regexp "${resp.json()['${input}']}" "${input_parameters['${input}']}" + END END Remove Keys From Object -- GitLab From 34bc690acdf17aaec95a4a28e0848353630e16a0 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 27 Feb 2025 17:37:02 +0100 Subject: [PATCH 02/12] Fix events including filter properly in eventfilter array --- tests/features/CAPIF Api Events/capif_events_api.robot | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index 9f8b4e23..06599fcf 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -167,7 +167,7 @@ Invoker receives Service API Invocation events ${events_list}= Create List SERVICE_API_INVOCATION_SUCCESS SERVICE_API_INVOCATION_FAILURE ${aef_ids}= Create List ${register_user_info['aef_id']} ${event_filter}= Create Capif Event Filter aefIds=${aef_ids} - ${event_filters}= Create List ${event_filter} + ${event_filters}= Create List ${event_filter} ${event_filter} ${request_body}= Create Events Subscription ... events=@{events_list} @@ -240,7 +240,7 @@ Invoker subscribe to Service API Available and Unavailable 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} + ${event_filters}= Create List ${event_filter} ${event_filter} ${request_body}= Create Events Subscription ... events=@{events_list} @@ -712,7 +712,7 @@ Invoker receives Service API Invocation events without Enhanced Event Report ${events_list}= Create List SERVICE_API_INVOCATION_SUCCESS SERVICE_API_INVOCATION_FAILURE ${aef_ids}= Create List ${register_user_info['aef_id']} ${event_filter}= Create Capif Event Filter aefIds=${aef_ids} - ${event_filters}= Create List ${event_filter} + ${event_filters}= Create List ${event_filter} ${event_filter} ${request_body}= Create Events Subscription ... events=@{events_list} @@ -786,7 +786,7 @@ Invoker subscribe to Service API Available and Unavailable events without Enhanc ${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} + ${event_filters}= Create List ${event_filter} ${event_filter} ${request_body}= Create Events Subscription ... events=@{events_list} -- GitLab From 404084e8c0505ad5c7a0c5c9f0b35fb4c6539456 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Mon, 3 Mar 2025 11:19:58 +0100 Subject: [PATCH 03/12] Upgrade invoker expected messages and new tests at event filter feature --- .../CAPIF Api Events/capif_events_api.robot | 28 ++-- .../features/Event Filter/event_filter.robot | 140 +++++++++++++++++- tests/resources/common/expectedMessages.robot | 74 ++++++--- 3 files changed, 208 insertions(+), 34 deletions(-) diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index 9cd68c3b..6e07c865 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -378,7 +378,7 @@ Provider subscribe to API Invoker events ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} # Register INVOKER - ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + ${register_user_info_invoker} ${invoker_url} ${request_body}= Invoker Default Onboarding # Update Invoker onboarded information ${new_notification_destination}= Set Variable @@ -387,7 +387,7 @@ Provider subscribe to API Invoker events ... ${request_body} ... notificationDestination=${new_notification_destination} ${resp}= Put Request Capif - ... ${url.path} + ... ${invoker_url.path} ... ${request_body} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt @@ -399,21 +399,24 @@ Provider subscribe to API Invoker events # Remove Invoker from CCF ${resp}= Delete Request Capif - ... ${url.path} + ... ${invoker_url.path} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} remove_capif_users_entry ${url.path} + Call Method ${CAPIF_USERS} remove_capif_users_entry ${invoker_url.path} # Check Remove Should Be Equal As Strings ${resp.status_code} 204 # Check Event Notifications ## Create check Events to ensure all notifications were received + ${invoker_urls}= Create List ${invoker_url} ${events_expected}= Create Expected Api Invoker Events ... ${subscription_id} - ... ${register_user_info_invoker['api_invoker_id']} + ... api_invoker_onboarded_resources=${invoker_urls} + ... api_invoker_updated_resources=${invoker_urls} + ... api_invoker_offboarded_resources=${invoker_urls} ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} @@ -718,7 +721,7 @@ Invoker receives Service API Invocation events without Enhanced Event Report ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing ... event_filters=${event_filters} - ... supported_features=0 + ... supported_features=4 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} @@ -925,7 +928,7 @@ Provider subscribe to API Invoker events without Enhanced Event Report ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} # Register INVOKER - ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + ${register_user_info_invoker} ${invoker_url} ${request_body}= Invoker Default Onboarding # Update Invoker onboarded information ${new_notification_destination}= Set Variable @@ -934,7 +937,7 @@ Provider subscribe to API Invoker events without Enhanced Event Report ... ${request_body} ... notificationDestination=${new_notification_destination} ${resp}= Put Request Capif - ... ${url.path} + ... ${invoker_url.path} ... ${request_body} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt @@ -946,21 +949,24 @@ Provider subscribe to API Invoker events without Enhanced Event Report # Remove Invoker from CCF ${resp}= Delete Request Capif - ... ${url.path} + ... ${invoker_url.path} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} - Call Method ${CAPIF_USERS} remove_capif_users_entry ${url.path} + Call Method ${CAPIF_USERS} remove_capif_users_entry ${invoker_url.path} # Check Remove Should Be Equal As Strings ${resp.status_code} 204 # Check Event Notifications ## Create check Events to ensure all notifications were received + ${invoker_urls}= Create List ${invoker_url} ${events_expected}= Create Expected Api Invoker Events ... ${subscription_id} - ... ${register_user_info_invoker['api_invoker_id']} + ... api_invoker_onboarded_resources=${invoker_urls} + ... api_invoker_updated_resources=${invoker_urls} + ... api_invoker_offboarded_resources=${invoker_urls} ... event_detail_expected=${FALSE} ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} diff --git a/tests/features/Event Filter/event_filter.robot b/tests/features/Event Filter/event_filter.robot index 19fb636b..7ff276c4 100644 --- a/tests/features/Event Filter/event_filter.robot +++ b/tests/features/Event Filter/event_filter.robot @@ -162,7 +162,145 @@ Service API Available filtered by apiIds Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} -Try error +Invoker events filtered by invokerIds + [Tags] event_filter-3 mockserver + + # Initialize Mock server + Init Mock Server + + # Register APF + ${register_user_info_provider}= Provider Default Registration total_aef_roles=2 + + ${aef_id_1}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} + ${aef_id_2}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} + ${aef_empty_list}= Create List + + # Publish api with 2 aefIds + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + ... service_1 + ... aef_id=${aef_ids} + ... api_status=${aef_empty_list} + ... supported_features=020 + + # Subscribe to events + ${events_list}= Create List API_INVOKER_ONBOARDED + ${event_filter}= Create Capif Event Filter + ${event_filters}= Create List ${event_filter} + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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=${AMF_PROVIDER_USERNAME} + + # Check Results + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + + # Default Invoker Registration and Onboarding + ${register_user_info_invoker_1} ${invoker_url_1} ${request_body_1}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 + ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} + + # Default Invoker Registration and Onboarding + ${register_user_info_invoker_2} ${invoker_url_2} ${request_body_2}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 + ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} + + # Subscribe to events + ${events_list}= Create List API_INVOKER_ONBOARDED API_INVOKER_OFFBOARDED API_INVOKER_UPDATED + ${event_filter_empty}= Create Capif Event Filter + ${event_filter_invoker_id_1}= Create Capif Event Filter apiInvokersIds=${api_invoker_id_1} + ${event_filters}= Create List ${event_filter_empty} ${event_filter_invoker_id_1} ${event_filter_invoker_id_1} + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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} + + # Update Invokers + ## Update Invoker 1 + ${new_notification_destination}= Set Variable + ... http://${CAPIF_CALLBACK_IP}:${CAPIF_CALLBACK_PORT}/netapp_new_callback_1 + Set To Dictionary + ... ${request_body} + ... notificationDestination=${new_notification_destination} + ${resp}= Put Request Capif + ... ${invoker_url_1.path} + ... ${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_1 + Check Response Variable Type And Values ${resp} 200 APIInvokerEnrolmentDetails + ... notificationDestination=${new_notification_destination} + + ## Update Invoker 1 + ${new_notification_destination}= Set Variable + ... http://${CAPIF_CALLBACK_IP}:${CAPIF_CALLBACK_PORT}/netapp_new_callback_2 + Set To Dictionary + ... ${request_body} + ... notificationDestination=${new_notification_destination} + ${resp}= Put Request Capif + ... ${invoker_url_2.path} + ... ${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_2 + Check Response Variable Type And Values ${resp} 200 APIInvokerEnrolmentDetails + ... notificationDestination=${new_notification_destination} + + # Remove invokers + ## Remove Invoker 1 + ${resp}= Delete Request Capif + ... ${invoker_url_1.path} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_1 + Call Method ${CAPIF_USERS} remove_capif_users_entry ${invoker_url_1.path} + Should Be Equal As Strings ${resp.status_code} 204 + + ## Remove Invoker 2 + ${resp}= Delete Request Capif + ... ${invoker_url_2.path} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME}_2 + Call Method ${CAPIF_USERS} remove_capif_users_entry ${invoker_url_2.path} + Should Be Equal As Strings ${resp.status_code} 204 + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${invoker_urls}= Create List ${invoker_url_1} + ${empty_list}= Create List + ${events_expected}= Create Expected Api Invoker Events + ... ${subscription_id} + ... api_invoker_onboarded_resources=${empty_list} + ... api_invoker_updated_resources=${invoker_url} + ... api_invoker_offboarded_resources=${invoker_url} + ... event_detail_expected=${FALSE} + Log List ${events_expected} + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + + +Service API Available filtered by aefIds [Tags] event_filter-2 mockserver # Initialize Mock server diff --git a/tests/resources/common/expectedMessages.robot b/tests/resources/common/expectedMessages.robot index 128f9831..65e6ac6f 100644 --- a/tests/resources/common/expectedMessages.robot +++ b/tests/resources/common/expectedMessages.robot @@ -113,7 +113,9 @@ Create Expected Events For Service API Notifications Create Expected Api Invoker Events [Arguments] ... ${subscription_id} - ... ${api_invoker_id} + ... ${api_invoker_onboarded_resources}=${NONE} + ... ${api_invoker_updated_resources}=${NONE} + ... ${api_invoker_offboarded_resources}=${NONE} ... ${events_expected}=${NONE} ... ${event_detail_expected}=${TRUE} @@ -121,31 +123,59 @@ Create Expected Api Invoker Events ${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} + # Create Notification Events expected to be received for Onboarded event + IF "${api_invoker_onboarded_resources}" != "${NONE}" + FOR ${api_invoker_onboarded_resource} IN @{api_invoker_onboarded_resources} + Log ${api_invoker_onboarded_resource} + ${api_invoker_id}= Fetch From Right ${api_invoker_onboarded_resource.path} / + + IF "${event_detail_expected}" != "${TRUE}" + ${api_invoker_id}= Set Variable ${NONE} + END + + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_ONBOARDED + ... apiInvokerIds=${api_invoker_id} + Append To List ${events_expected} ${event_expected} + END 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} + IF "${api_invoker_updated_resources}" != "${NONE}" + FOR ${api_invoker_updated_resource} IN @{api_invoker_updated_resources} + Log ${api_invoker_updated_resource} + ${api_invoker_id}= Fetch From Right ${api_invoker_updated_resource.path} / - # 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} + IF "${event_detail_expected}" != "${TRUE}" + ${api_invoker_id}= Set Variable ${NONE} + END + + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_UPDATED + ... apiInvokerIds=${api_invoker_id} + Append To List ${events_expected} ${event_expected} + END + END + + # Create Notification Events expected to be received for Offboarded event + IF "${api_invoker_offboarded_resources}" != "${NONE}" + FOR ${api_invoker_offboarded_resource} IN @{api_invoker_offboarded_resources} + Log ${api_invoker_offboarded_resource} + ${api_invoker_id}= Fetch From Right ${api_invoker_offboarded_resource.path} / + + IF "${event_detail_expected}" != "${TRUE}" + ${api_invoker_id}= Set Variable ${NONE} + END + + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_OFFBOARDED + ... apiInvokerIds=${api_invoker_id} + Append To List ${events_expected} ${event_expected} + END + END RETURN ${events_expected} -- GitLab From 1acd09eb8c7a845def82b71cbb2b82ddd1833e57 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Mon, 3 Mar 2025 12:17:42 +0100 Subject: [PATCH 04/12] new tests under development on event filter feature --- .../features/Event Filter/event_filter.robot | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/tests/features/Event Filter/event_filter.robot b/tests/features/Event Filter/event_filter.robot index 7ff276c4..de65c30e 100644 --- a/tests/features/Event Filter/event_filter.robot +++ b/tests/features/Event Filter/event_filter.robot @@ -203,21 +203,22 @@ Invoker events filtered by invokerIds # Check Results Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} # Default Invoker Registration and Onboarding - ${register_user_info_invoker_1} ${invoker_url_1} ${request_body_1}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 + ${register_user_info_invoker_1} ${invoker_url_1} ${invoker_request_body_1}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} # Default Invoker Registration and Onboarding - ${register_user_info_invoker_2} ${invoker_url_2} ${request_body_2}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 + ${register_user_info_invoker_2} ${invoker_url_2} ${invoker_request_body_2}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_2 ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} # Subscribe to events ${events_list}= Create List API_INVOKER_ONBOARDED API_INVOKER_OFFBOARDED API_INVOKER_UPDATED ${event_filter_empty}= Create Capif Event Filter - ${event_filter_invoker_id_1}= Create Capif Event Filter apiInvokersIds=${api_invoker_id_1} - ${event_filters}= Create List ${event_filter_empty} ${event_filter_invoker_id_1} ${event_filter_invoker_id_1} + ${event_filter_invoker_id_1}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} + ${event_filter_invoker_id_2}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_2} + ${event_filters}= Create List ${event_filter_empty} ${event_filter_invoker_id_1} ${event_filter_invoker_id_2} ${request_body}= Create Events Subscription ... events=@{events_list} @@ -229,22 +230,22 @@ Invoker events filtered by invokerIds ... json=${request_body} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt - ... username=${INVOKER_USERNAME} + ... username=${AMF_PROVIDER_USERNAME} # Check Results Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + ${subscriber_id} ${subscription_id_2}= Check Event Location Header ${resp} # Update Invokers ## Update Invoker 1 ${new_notification_destination}= Set Variable ... http://${CAPIF_CALLBACK_IP}:${CAPIF_CALLBACK_PORT}/netapp_new_callback_1 Set To Dictionary - ... ${request_body} + ... ${invoker_request_body_1} ... notificationDestination=${new_notification_destination} ${resp}= Put Request Capif ... ${invoker_url_1.path} - ... ${request_body} + ... ${invoker_request_body_1} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME}_1 @@ -255,11 +256,11 @@ Invoker events filtered by invokerIds ${new_notification_destination}= Set Variable ... http://${CAPIF_CALLBACK_IP}:${CAPIF_CALLBACK_PORT}/netapp_new_callback_2 Set To Dictionary - ... ${request_body} + ... ${invoker_request_body_2} ... notificationDestination=${new_notification_destination} ${resp}= Put Request Capif ... ${invoker_url_2.path} - ... ${request_body} + ... ${invoker_request_body_2} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME}_2 @@ -287,14 +288,20 @@ Invoker events filtered by invokerIds # Check Event Notifications ## Create check Events to ensure all notifications were received - ${invoker_urls}= Create List ${invoker_url_1} + ${invoker_urls_both}= Create List ${invoker_url_1} ${invoker_url_2} + ${invoker_urls_1}= Create List ${invoker_url_1} + ${invoker_urls_2}= Create List ${invoker_url_2} ${empty_list}= Create List ${events_expected}= Create Expected Api Invoker Events - ... ${subscription_id} - ... api_invoker_onboarded_resources=${empty_list} - ... api_invoker_updated_resources=${invoker_url} - ... api_invoker_offboarded_resources=${invoker_url} - ... event_detail_expected=${FALSE} + ... ${subscription_id_1} + ... api_invoker_onboarded_resources=${invoker_urls_both} + ... event_detail_expected=${TRUE} + ${events_expected}= Create Expected Api Invoker Events + ... ${subscription_id_2} + ... events_expected=${events_expected} + ... api_invoker_updated_resources=${invoker_urls_2} + ... api_invoker_offboarded_resources=${invoker_urls_1} + ... event_detail_expected=${TRUE} Log List ${events_expected} ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} -- GitLab From 2cc7d8e404e1c37f9c97b1ad4e1b513c84a511e6 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Tue, 4 Mar 2025 13:38:19 +0100 Subject: [PATCH 05/12] ACL UPDATE event when we update ACL using POST /update at security service --- .../capif_security/core/servicesecurity.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py b/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py index 916b2861..8be9b362 100644 --- a/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py +++ b/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py @@ -317,6 +317,7 @@ class SecurityOperations(Resource): "Service api not found with id: " + api_invoker_id) return not_found_error(detail="Service API not existing", cause="Not exist securiy information for this invoker") + update_acls=list() for service_instance in service_security.security_info: if service_instance.interface_details is not None: security_methods = service_instance.interface_details.security_methods @@ -343,14 +344,22 @@ class SecurityOperations(Resource): valid_security_methods) & set(pref_security_methods) service_instance.sel_security_method = list( valid_security_method)[0] + update_acls.append({"api_id": service_instance.api_id, "aef_id": service_instance.aef_id}) service_security = service_security.to_dict() service_security = clean_empty(service_security) result = mycol.find_one_and_update(old_object, {"$set": service_security}, projection={ '_id': 0, "api_invoker_id": 0}, return_document=ReturnDocument.AFTER, upsert=False) + current_app.logger.debug( + "Inserted security context in database") # result = clean_empty(result) + for update_acl in update_acls: + # Send service instance to ACL + current_app.logger.debug("Sending message to create ACL") + publish_ops.publish_message("acls-messages", "create-acl:"+str( + api_invoker_id)+":"+str(update_acl['api_id'])+":"+str(update_acl['aef_id'])) current_app.logger.debug("Updated security context") -- GitLab From 61abfa7e6b594add486f86900f268b4008ba249c Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Tue, 4 Mar 2025 13:39:18 +0100 Subject: [PATCH 06/12] New tests insisde event_filter features --- .../features/Event Filter/event_filter.robot | 523 ++++++++++++++++-- tests/libraries/security_api/bodyRequests.py | 31 +- 2 files changed, 515 insertions(+), 39 deletions(-) diff --git a/tests/features/Event Filter/event_filter.robot b/tests/features/Event Filter/event_filter.robot index de65c30e..48c3b1d8 100644 --- a/tests/features/Event Filter/event_filter.robot +++ b/tests/features/Event Filter/event_filter.robot @@ -18,6 +18,114 @@ ${SUBSCRIBER_ID_NOT_VALID} not-valid ${SUBSCRIPTION_ID_NOT_VALID} not-valid +*** Keywords *** +Create Security Context between ${invoker_info} and ${provider_info} + # Discover APIs by invoker + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${invoker_info['api_invoker_id']}&aef-id=${provider_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${invoker_info['management_cert']} + + Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs + + # create Security Context + ${request_service_security_body} ${api_ids}= Create Service Security From Discover Response + ... http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/test + ... ${discover_response} + ... legacy=${FALSE} + ${resp}= Put Request Capif + ... /capif-security/v1/trustedInvokers/${invoker_info['api_invoker_id']} + ... json=${request_service_security_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${invoker_info['management_cert']} + + Set To Dictionary ${invoker_info} security_body=${request_service_security_body} + # Check Service Security + Check Response Variable Type And Values ${resp} 201 ServiceSecurity + ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} + + ${api_invoker_policies_list}= Create List + + FOR ${api_id} IN @{api_ids} + Log ${api_id} + ${resp}= Get Request Capif + ... /access-control-policy/v1/accessControlPolicyList/${api_id}?aef-id=${provider_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${provider_info['aef_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']} + # ... ${invoker_info['api_invoker_id']} + + ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} + # Append To List ${api_invoker_policies_list} ${api_invoker_policies} + ${api_invoker_policies_list}= Set Variable ${api_invoker_policies} + END + + Log List ${api_invoker_policies_list} + + RETURN ${api_invoker_policies_list} + +Update Security Context between ${invoker_info} and ${provider_info} + # Discover APIs by invoker + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${invoker_info['api_invoker_id']}&aef-id=${provider_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${invoker_info['management_cert']} + + Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs + + # create Security Context + ${request_service_security_body} ${api_ids}= Update Service Security With Discover Response + ... ${invoker_info['security_body']} + ... ${discover_response} + ... legacy=${FALSE} + ${resp}= Post Request Capif + ... /capif-security/v1/trustedInvokers/${invoker_info['api_invoker_id']}/update + ... json=${request_service_security_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${invoker_info['management_cert']} + + # Check Service Security + Check Response Variable Type And Values ${resp} 200 ServiceSecurity + ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} + + ${api_invoker_policies_list}= Create List + + ${api_id}= Get From List ${api_ids} -1 + Log ${api_id} + ${resp}= Get Request Capif + ... /access-control-policy/v1/accessControlPolicyList/${api_id}?aef-id=${provider_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${provider_info['aef_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']} + # ... ${invoker_info['api_invoker_id']} + + ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} + # Append To List ${api_invoker_policies_list} ${api_invoker_policies} + ${api_invoker_policies_list}= Set Variable ${api_invoker_policies} + + Log List ${api_invoker_policies_list} + + RETURN ${api_invoker_policies_list} + + *** Test Cases *** Service API Available filtered by apiIds [Tags] event_filter-1 mockserver @@ -46,7 +154,7 @@ Service API Available filtered by apiIds # Register other provider ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_NEW - + ${aef2_id_1}= Set Variable ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} # Publish api with other provider @@ -161,6 +269,175 @@ Service API Available filtered by apiIds ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} +Service API Available filtered by not valid filters + [Tags] event_filter-2 mockserver + + # 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 total_aef_roles=2 + + ${aef_id_1}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} + ${aef_id_2}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} + ${aef_empty_list}= Create List + + # Publish api with 2 aefIds + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + ... service_1 + ... aef_id=${aef_ids} + ... api_status=${aef_empty_list} + ... supported_features=020 + + # Register other provider + ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_NEW + + ${aef2_id_1}= Set Variable ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} + + # Publish api with other provider + ${service_api_description_published_2} ${resource_url_2} ${request_body_2}= Publish Service Api + ... ${register_user_info_provider_2} + ... service_2 + ... aef_id=${aef2_id_1} + ... api_status=${aef2_id_1} + ... supported_features=020 + + # Discover APIs by invoker + ${resp}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${aef_id_1} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + + # # Check Results + Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions + Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} + Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} + + ${api_id}= Set Variable ${resp.json()['serviceAPIDescriptions'][0]['apiId']} + + # Wrong filter on SERVICE_API_AVAILABLE + ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE SERVICE_API_UPDATE + ${event_filter_empty}= Create Capif Event Filter + ${event_filter_aef_ids}= Create Capif Event Filter aefIds=${aef_ids} + ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_description_published['apiId']} + ${event_filter_api_invoker_ids}= Create Capif Event Filter apiInvokerIds=${register_user_info_invoker['api_invoker_id']} + ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_empty} ${event_filter_empty} + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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 + ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event SERVICE_API_AVAILABLE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=Bad Param + ... cause=Invalid eventFilter for event SERVICE_API_AVAILABLE + ... invalidParams=${invalid_param_list} + + # Wrong filter on SERVICE_API_UNAVAILABLE + ${event_filters}= Create List ${event_filter_empty} ${event_filter_aef_ids} ${event_filter_empty} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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 + ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event SERVICE_API_UNAVAILABLE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=Bad Param + ... cause=Invalid eventFilter for event SERVICE_API_UNAVAILABLE + ... invalidParams=${invalid_param_list} + + + # Wrong filter on SERVICE_API_UPDATE + ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_aef_ids} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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 + ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event SERVICE_API_UPDATE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=Bad Param + ... cause=Invalid eventFilter for event SERVICE_API_UPDATE + ... invalidParams=${invalid_param_list} + + # Wrong filter on SERVICE_API_UPDATE with apiIds + ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_api_invoker_ids} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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 + ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'api_invoker_ids'} for event SERVICE_API_UPDATE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=Bad Param + ... cause=Invalid eventFilter for event SERVICE_API_UPDATE + ... invalidParams=${invalid_param_list} Invoker events filtered by invokerIds [Tags] event_filter-3 mockserver @@ -306,16 +583,12 @@ Invoker events filtered by invokerIds ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} - -Service API Available filtered by aefIds - [Tags] event_filter-2 mockserver +Invoker events filtered by not valid filters + [Tags] event_filter-4 mockserver # 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 total_aef_roles=2 @@ -332,40 +605,42 @@ Service API Available filtered by aefIds ... api_status=${aef_empty_list} ... supported_features=020 - # Register other provider - ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_NEW - - ${aef2_id_1}= Set Variable ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} - - # Publish api with other provider - ${service_api_description_published_2} ${resource_url_2} ${request_body_2}= Publish Service Api - ... ${register_user_info_provider_2} - ... service_2 - ... aef_id=${aef2_id_1} - ... api_status=${aef2_id_1} - ... supported_features=020 + # Subscribe to events + ${events_list}= Create List API_INVOKER_ONBOARDED + ${event_filter}= Create Capif Event Filter + ${event_filters}= Create List ${event_filter} - # Discover APIs by invoker - ${resp}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${aef_id_1} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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} + ... username=${AMF_PROVIDER_USERNAME} - Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs + # Check Results + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} - # # Check Results - Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions - Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} - Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} + # Default Invoker Registration and Onboarding + ${register_user_info_invoker_1} ${invoker_url_1} ${invoker_request_body_1}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 + ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} - ${api_id}= Set Variable ${resp.json()['serviceAPIDescriptions'][0]['apiId']} + # Default Invoker Registration and Onboarding + ${register_user_info_invoker_2} ${invoker_url_2} ${invoker_request_body_2}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_2 + ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} # Subscribe to events - ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE SERVICE_API_UPDATE - ${event_filter}= Create Capif Event Filter aefIds=${aef_ids} - ${event_filters}= Create List ${event_filter} ${event_filter} ${event_filter} + ${events_list}= Create List API_INVOKER_ONBOARDED API_INVOKER_OFFBOARDED API_INVOKER_UPDATED + ${event_filter_empty}= Create Capif Event Filter + ${event_filter_aef_ids}= Create Capif Event Filter aefIds=${aef_ids} + ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_description_published['apiId']} + ${event_filter_invoker_id_2}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_2} + ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_empty} ${event_filter_empty} ${request_body}= Create Events Subscription ... events=@{events_list} @@ -373,14 +648,14 @@ Service API Available filtered by aefIds ... supported_features=C ... event_filters=${event_filters} ${resp}= Post Request Capif - ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions + ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt - ... username=${INVOKER_USERNAME} + ... username=${AMF_PROVIDER_USERNAME} # Check Results - ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event SERVICE_API_AVAILABLE are not applicable. + ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event API_INVOKER_ONBOARDED are not applicable. ${invalid_param_list}= Create List ${invalid_param} Check Response Variable Type And Values ... ${resp} @@ -389,5 +664,179 @@ Service API Available filtered by aefIds ... title=Bad Request ... status=400 ... detail=Bad Param - ... cause=Invalid eventFilter for event SERVICE_API_AVAILABLE + ... cause=Invalid eventFilter for event API_INVOKER_ONBOARDED + ... invalidParams=${invalid_param_list} + + # Check API_INVOKER_OFFBOARDED + ${event_filters}= Create List ${event_filter_empty} ${event_filter_aef_ids} ${event_filter_empty} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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=${AMF_PROVIDER_USERNAME} + + # Check Results + ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event API_INVOKER_OFFBOARDED are not applicable. + ${invalid_param_list}= Create List ${invalid_param} + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=Bad Param + ... cause=Invalid eventFilter for event API_INVOKER_OFFBOARDED + ... invalidParams=${invalid_param_list} + + # Check API_INVOKER_UPDATED + ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_aef_ids} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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=${AMF_PROVIDER_USERNAME} + + # Check Results + ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event API_INVOKER_UPDATED are not applicable. + ${invalid_param_list}= Create List ${invalid_param} + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=Bad Param + ... cause=Invalid eventFilter for event API_INVOKER_UPDATED ... invalidParams=${invalid_param_list} + + # Check API_INVOKER_UPDATED + ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_api_ids} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ... event_filters=${event_filters} + ${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=${AMF_PROVIDER_USERNAME} + + # Check Results + ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'api_ids'} for event API_INVOKER_UPDATED are not applicable. + ${invalid_param_list}= Create List ${invalid_param} + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=Bad Param + ... cause=Invalid eventFilter for event API_INVOKER_UPDATED + ... invalidParams=${invalid_param_list} + + +Invoker subscribed to ACL update event filtered by apiInvokerId + [Tags] event_filter-5 mockserver smoke + + # Initialize Mock server + Init Mock Server + + # Register provider 1 + ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 + + # Publish one api + ${service_api_description_published_1} ${provider_resource_url_1} ${provider_request_body_1}= Publish Service Api + ... ${register_user_info_provider_1} + ... service_name=service_1 + + # Register APF + ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_2 + + # Publish one api + ${service_api_description_published_2} ${provider_resource_url_2} ${provider_request_body_2}= Publish Service Api + ... ${register_user_info_provider_2} + ... service_name=service_2 + + # Store apiId1 and apiId2 + ${service_api_id_1}= Set Variable ${service_api_description_published_1['apiId']} + + ${service_api_id_2}= Set Variable ${service_api_description_published_2['apiId']} + + # Register INVOKER 1 + ${register_user_info_invoker_1} ${invoker_url_1} ${request_body_1}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 + ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} + + # Register INVOKER 2 + ${register_user_info_invoker_2} ${invoker_url_2} ${request_body_2}= Invoker Default Onboarding invoke_username=${INVOKER_USERNAME}_2 + ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} + + + # Subscribe to events + ${events_list}= Create List ACCESS_CONTROL_POLICY_UPDATE + + # Event filters + ${event_filter_empty}= Create Capif Event Filter + ${event_filter_api_invoker_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} + ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_id_1} + ${event_filter_api_invoker_ids_and_api_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} apiIds=${service_api_id_1} + + ${event_filters}= Create List ${event_filter_api_invoker_ids} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ... event_filters=${event_filters} + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info_provider_1['amf_username']} + + # Check Results + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} + + ${acl_provider_1}= Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1} + ${acl_provider_1}= Create Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_1} + + ${acl_provider_2}= Update Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_2} + ${acl_provider_2}= Update Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_2} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${acl_to_check}= Create List ${acl_provider_1[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_1} + ... ${service_api_id_1} + ... ${acl_to_check} + + ${acl_to_check}= Create List ${acl_provider_1[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_1} + ... ${service_api_id_1} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ${acl_to_check}= Create List ${acl_provider_2[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_1} + ... ${service_api_id_2} + ... ${acl_to_check} + ... 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} diff --git a/tests/libraries/security_api/bodyRequests.py b/tests/libraries/security_api/bodyRequests.py index dabee876..0e2f826d 100644 --- a/tests/libraries/security_api/bodyRequests.py +++ b/tests/libraries/security_api/bodyRequests.py @@ -32,7 +32,7 @@ def create_service_security_body(notification_destination, aef_id=None, api_id=N return data -def create_service_security_from_discover_response(notification_destination, discover_response): +def create_service_security_from_discover_response(notification_destination, discover_response, legacy=True): data = { "notificationDestination": notification_destination, "supportedFeatures": "fffffff", @@ -43,6 +43,7 @@ def create_service_security_from_discover_response(notification_destination, dis }, "requestTestNotification": True } + api_ids=list() service_api_descriptions = discover_response.json()['serviceAPIDescriptions'] for service_api_description in service_api_descriptions: for aef_profile in service_api_description['aefProfiles']: @@ -53,7 +54,33 @@ def create_service_security_from_discover_response(notification_destination, dis "aefId": aef_profile['aefId'], "apiId": service_api_description['apiId'] }) - return data + api_ids.append(service_api_description['apiId']) + if legacy: + return data + else: + return data, api_ids + + +def update_service_security_with_discover_response(security_body, discover_response, legacy=True): + api_ids = list() + service_api_descriptions = discover_response.json()['serviceAPIDescriptions'] + for service_api_description in service_api_descriptions: + for aef_profile in service_api_description['aefProfiles']: + security_body['securityInfo'].append({ + "authenticationInfo": "authenticationInfo", + "authorizationInfo": "authorizationInfo", + "prefSecurityMethods": ["PSK", "PKI", "OAUTH"], + "aefId": aef_profile['aefId'], + "apiId": service_api_description['apiId'] + }) + + for security_info in security_body['securityInfo']: + api_ids.append(security_info['apiId']) + + if legacy: + return security_body + else: + return security_body, api_ids def create_security_notification_body(api_invoker_id, api_ids, cause="OVERLIMIT_USAGE", aef_id=None): -- GitLab From 0e75c5548bd12aa0e6e4e2a07467aee1bd9279f6 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Tue, 4 Mar 2025 16:51:59 +0100 Subject: [PATCH 07/12] New tests related with event filter and ACL events --- .../features/Event Filter/event_filter.robot | 316 +++++++++++++++++- 1 file changed, 306 insertions(+), 10 deletions(-) diff --git a/tests/features/Event Filter/event_filter.robot b/tests/features/Event Filter/event_filter.robot index 48c3b1d8..098f8034 100644 --- a/tests/features/Event Filter/event_filter.robot +++ b/tests/features/Event Filter/event_filter.robot @@ -127,7 +127,7 @@ Update Security Context between ${invoker_info} and ${provider_info} *** Test Cases *** -Service API Available filtered by apiIds +Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE_API_UPDATE events filtered by apiIds [Tags] event_filter-1 mockserver # Initialize Mock server @@ -269,7 +269,7 @@ Service API Available filtered by apiIds ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} -Service API Available filtered by not valid filters +Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE_API_UPDATE events filtered by not valid filters [Tags] event_filter-2 mockserver # Initialize Mock server @@ -439,7 +439,7 @@ Service API Available filtered by not valid filters ... cause=Invalid eventFilter for event SERVICE_API_UPDATE ... invalidParams=${invalid_param_list} -Invoker events filtered by invokerIds +Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INVOKER_UPDATED events filtered by invokerIds [Tags] event_filter-3 mockserver # Initialize Mock server @@ -583,7 +583,7 @@ Invoker events filtered by invokerIds ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} -Invoker events filtered by not valid filters +Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INVOKER_UPDATED events filtered by not valid filters [Tags] event_filter-4 mockserver # Initialize Mock server @@ -747,9 +747,7 @@ Invoker events filtered by not valid filters ... detail=Bad Param ... cause=Invalid eventFilter for event API_INVOKER_UPDATED ... invalidParams=${invalid_param_list} - - -Invoker subscribed to ACL update event filtered by apiInvokerId +Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId, only invokerId and both [Tags] event_filter-5 mockserver smoke # Initialize Mock server @@ -792,8 +790,43 @@ Invoker subscribed to ACL update event filtered by apiInvokerId ${event_filter_empty}= Create Capif Event Filter ${event_filter_api_invoker_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_id_1} - ${event_filter_api_invoker_ids_and_api_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} apiIds=${service_api_id_1} + ${event_filter_api_invoker_ids_and_api_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_2} apiIds=${service_api_id_2} + + # Subscription to Events 1 + ${event_filters}= Create List ${event_filter_api_ids} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ... event_filters=${event_filters} + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info_provider_1['amf_username']} + + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} + # Subscription to Events 2 + ${event_filters}= Create List ${event_filter_api_invoker_ids_and_api_ids} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ... event_filters=${event_filters} + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info_provider_1['amf_username']} + + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id_2}= Check Event Location Header ${resp} + + # Subscription to Events 3 ${event_filters}= Create List ${event_filter_api_invoker_ids} ${request_body}= Create Events Subscription ... events=@{events_list} @@ -807,10 +840,232 @@ Invoker subscribed to ACL update event filtered by apiInvokerId ... verify=ca.crt ... username=${register_user_info_provider_1['amf_username']} + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id_3}= Check Event Location Header ${resp} + + + # Create Security Contexts and ACLs + ${acl_provider_1}= Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1} + ${acl_provider_1}= Create Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_1} + + ${acl_provider_2}= Update Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_2} + ${acl_provider_2}= Update Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_2} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ### Subscription 1 Checks + ${acl_to_check}= Create List ${acl_provider_1[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_1} + ... ${service_api_id_1} + ... ${acl_to_check} + + ${acl_to_check}= Create List ${acl_provider_1[1]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_1} + ... ${service_api_id_1} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ${acl_to_check}= Create List ${acl_provider_1[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_1} + ... ${service_api_id_1} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ${acl_to_check}= Create List ${acl_provider_1[1]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_1} + ... ${service_api_id_1} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ### Subscription 2 checks + ${acl_to_check}= Create List ${acl_provider_2[1]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_2} + ... ${service_api_id_2} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ### Subscription 3 checks + ${acl_to_check}= Create List ${acl_provider_1[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_3} + ... ${service_api_id_1} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ${acl_to_check}= Create List ${acl_provider_1[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_3} + ... ${service_api_id_1} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ${acl_to_check}= Create List ${acl_provider_2[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_3} + ... ${service_api_id_2} + ... ${acl_to_check} + ... events_expected=${events_expected} + + Log List ${events_expected} + + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + + +Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by aefId + [Tags] event_filter-6 smoke + + # Initialize Mock server + Init Mock Server + + # Register provider 1 + ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 + ${aef_id_1}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + + # Publish one api + ${service_api_description_published_1} ${provider_resource_url_1} ${provider_request_body_1}= Publish Service Api + ... ${register_user_info_provider_1} + ... service_name=service_1 + + # Store apiId1 and apiId2 + ${service_api_id_1}= Set Variable ${service_api_description_published_1['apiId']} + + # Subscribe to events + ${events_list}= Create List ACCESS_CONTROL_POLICY_UPDATE + + # Event filters + ${event_filter_aef_id}= Create Capif Event Filter aefIds=${aef_id_1} + + # Subscription to Events 1 + ${event_filters}= Create List ${event_filter_aef_id} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ... event_filters=${event_filters} + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info_provider_1['amf_username']} + # Check Results + ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event ACCESS_CONTROL_POLICY_UPDATE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=Bad Param + ... cause=Invalid eventFilter for event ACCESS_CONTROL_POLICY_UPDATE + ... invalidParams=${invalid_param_list} + +Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION_FAILURE filtered by apiId, invokerId, aefId and all of them + [Tags] event_filter-7 mockserver smoke + + # Initialize Mock server + Init Mock Server + + # Register provider 1 + ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 + + # Publish one api + ${service_api_description_published_1} ${provider_resource_url_1} ${provider_request_body_1}= Publish Service Api + ... ${register_user_info_provider_1} + ... service_name=service_1 + + # Register APF + ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_2 + + # Publish one api + ${service_api_description_published_2} ${provider_resource_url_2} ${provider_request_body_2}= Publish Service Api + ... ${register_user_info_provider_2} + ... service_name=service_2 + + # Store apiId1 and apiId2 + ${service_api_id_1}= Set Variable ${service_api_description_published_1['apiId']} + + ${service_api_id_2}= Set Variable ${service_api_description_published_2['apiId']} + + # Register INVOKER 1 + ${register_user_info_invoker_1} ${invoker_url_1} ${request_body_1}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 + ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} + + # Register INVOKER 2 + ${register_user_info_invoker_2} ${invoker_url_2} ${request_body_2}= Invoker Default Onboarding invoke_username=${INVOKER_USERNAME}_2 + ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} + + + # Subscribe to events + ${events_list}= Create List ACCESS_CONTROL_POLICY_UPDATE + + # Event filters + ${event_filter_empty}= Create Capif Event Filter + ${event_filter_api_invoker_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} + ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_id_1} + ${event_filter_api_invoker_ids_and_api_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_2} apiIds=${service_api_id_2} + + # Subscription to Events 1 + ${event_filters}= Create List ${event_filter_api_ids} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ... event_filters=${event_filters} + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info_provider_1['amf_username']} + Check Response Variable Type And Values ${resp} 201 EventSubscription ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} + # Subscription to Events 2 + ${event_filters}= Create List ${event_filter_api_invoker_ids_and_api_ids} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ... event_filters=${event_filters} + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info_provider_1['amf_username']} + + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id_2}= Check Event Location Header ${resp} + + # Subscription to Events 3 + ${event_filters}= Create List ${event_filter_api_invoker_ids} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ... event_filters=${event_filters} + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${register_user_info_provider_1['amf_username']} + + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id_3}= Check Event Location Header ${resp} + + + # Create Security Contexts and ACLs ${acl_provider_1}= Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1} ${acl_provider_1}= Create Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_1} @@ -819,12 +1074,20 @@ Invoker subscribed to ACL update event filtered by apiInvokerId # Check Event Notifications ## Create check Events to ensure all notifications were received + ### Subscription 1 Checks ${acl_to_check}= Create List ${acl_provider_1[0]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} ... ${service_api_id_1} ... ${acl_to_check} + ${acl_to_check}= Create List ${acl_provider_1[1]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_1} + ... ${service_api_id_1} + ... ${acl_to_check} + ... events_expected=${events_expected} + ${acl_to_check}= Create List ${acl_provider_1[0]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} @@ -832,11 +1095,44 @@ Invoker subscribed to ACL update event filtered by apiInvokerId ... ${acl_to_check} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_2[0]} + ${acl_to_check}= Create List ${acl_provider_1[1]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} + ... ${service_api_id_1} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ### Subscription 2 checks + ${acl_to_check}= Create List ${acl_provider_2[1]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_2} + ... ${service_api_id_2} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ### Subscription 3 checks + ${acl_to_check}= Create List ${acl_provider_1[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_3} + ... ${service_api_id_1} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ${acl_to_check}= Create List ${acl_provider_1[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_3} + ... ${service_api_id_1} + ... ${acl_to_check} + ... events_expected=${events_expected} + + ${acl_to_check}= Create List ${acl_provider_2[0]} + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id_3} ... ${service_api_id_2} ... ${acl_to_check} ... events_expected=${events_expected} + + Log List ${events_expected} + ## Check Events Expected towards received notifications at mock server - Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} \ No newline at end of file -- GitLab From 2d24287fbb5d91015441b054032bbaac46101e30 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Tue, 4 Mar 2025 17:37:22 +0100 Subject: [PATCH 08/12] New test for Success and failure invocation --- .../features/Event Filter/event_filter.robot | 649 ++++++++++-------- 1 file changed, 357 insertions(+), 292 deletions(-) diff --git a/tests/features/Event Filter/event_filter.robot b/tests/features/Event Filter/event_filter.robot index 098f8034..5bc3a112 100644 --- a/tests/features/Event Filter/event_filter.robot +++ b/tests/features/Event Filter/event_filter.robot @@ -18,114 +18,6 @@ ${SUBSCRIBER_ID_NOT_VALID} not-valid ${SUBSCRIPTION_ID_NOT_VALID} not-valid -*** Keywords *** -Create Security Context between ${invoker_info} and ${provider_info} - # Discover APIs by invoker - ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${invoker_info['api_invoker_id']}&aef-id=${provider_info['aef_id']} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${invoker_info['management_cert']} - - Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs - - # create Security Context - ${request_service_security_body} ${api_ids}= Create Service Security From Discover Response - ... http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/test - ... ${discover_response} - ... legacy=${FALSE} - ${resp}= Put Request Capif - ... /capif-security/v1/trustedInvokers/${invoker_info['api_invoker_id']} - ... json=${request_service_security_body} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${invoker_info['management_cert']} - - Set To Dictionary ${invoker_info} security_body=${request_service_security_body} - # Check Service Security - Check Response Variable Type And Values ${resp} 201 ServiceSecurity - ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} - - ${api_invoker_policies_list}= Create List - - FOR ${api_id} IN @{api_ids} - Log ${api_id} - ${resp}= Get Request Capif - ... /access-control-policy/v1/accessControlPolicyList/${api_id}?aef-id=${provider_info['aef_id']} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${provider_info['aef_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']} - # ... ${invoker_info['api_invoker_id']} - - ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} - # Append To List ${api_invoker_policies_list} ${api_invoker_policies} - ${api_invoker_policies_list}= Set Variable ${api_invoker_policies} - END - - Log List ${api_invoker_policies_list} - - RETURN ${api_invoker_policies_list} - -Update Security Context between ${invoker_info} and ${provider_info} - # Discover APIs by invoker - ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${invoker_info['api_invoker_id']}&aef-id=${provider_info['aef_id']} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${invoker_info['management_cert']} - - Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs - - # create Security Context - ${request_service_security_body} ${api_ids}= Update Service Security With Discover Response - ... ${invoker_info['security_body']} - ... ${discover_response} - ... legacy=${FALSE} - ${resp}= Post Request Capif - ... /capif-security/v1/trustedInvokers/${invoker_info['api_invoker_id']}/update - ... json=${request_service_security_body} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${invoker_info['management_cert']} - - # Check Service Security - Check Response Variable Type And Values ${resp} 200 ServiceSecurity - ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} - - ${api_invoker_policies_list}= Create List - - ${api_id}= Get From List ${api_ids} -1 - Log ${api_id} - ${resp}= Get Request Capif - ... /access-control-policy/v1/accessControlPolicyList/${api_id}?aef-id=${provider_info['aef_id']} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${provider_info['aef_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']} - # ... ${invoker_info['api_invoker_id']} - - ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} - # Append To List ${api_invoker_policies_list} ${api_invoker_policies} - ${api_invoker_policies_list}= Set Variable ${api_invoker_policies} - - Log List ${api_invoker_policies_list} - - RETURN ${api_invoker_policies_list} - - *** Test Cases *** Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE_API_UPDATE events filtered by apiIds [Tags] event_filter-1 mockserver @@ -155,7 +47,8 @@ Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE # Register other provider ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_NEW - ${aef2_id_1}= Set Variable ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} + ${aef2_id_1}= Set Variable + ... ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} # Publish api with other provider ${service_api_description_published_2} ${resource_url_2} ${request_body_2}= Publish Service Api @@ -297,7 +190,8 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE # Register other provider ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_NEW - ${aef2_id_1}= Set Variable ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} + ${aef2_id_1}= Set Variable + ... ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} # Publish api with other provider ${service_api_description_published_2} ${resource_url_2} ${request_body_2}= Publish Service Api @@ -326,10 +220,11 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE # Wrong filter on SERVICE_API_AVAILABLE ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE SERVICE_API_UPDATE - ${event_filter_empty}= Create Capif Event Filter + ${event_filter_empty}= Create Capif Event Filter ${event_filter_aef_ids}= Create Capif Event Filter aefIds=${aef_ids} ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_description_published['apiId']} - ${event_filter_api_invoker_ids}= Create Capif Event Filter apiInvokerIds=${register_user_info_invoker['api_invoker_id']} + ${event_filter_api_invoker_ids}= Create Capif Event Filter + ... apiInvokerIds=${register_user_info_invoker['api_invoker_id']} ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_empty} ${event_filter_empty} ${request_body}= Create Events Subscription @@ -345,8 +240,10 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... username=${INVOKER_USERNAME} # Check Results - ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event SERVICE_API_AVAILABLE are not applicable. - ${invalid_param_list}= Create List ${invalid_param} + ${invalid_param}= Create Dictionary + ... param=eventFilter + ... reason=The eventFilter {'aef_ids'} for event SERVICE_API_AVAILABLE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} Check Response Variable Type And Values ... ${resp} ... 400 @@ -372,8 +269,10 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... username=${INVOKER_USERNAME} # Check Results - ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event SERVICE_API_UNAVAILABLE are not applicable. - ${invalid_param_list}= Create List ${invalid_param} + ${invalid_param}= Create Dictionary + ... param=eventFilter + ... reason=The eventFilter {'aef_ids'} for event SERVICE_API_UNAVAILABLE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} Check Response Variable Type And Values ... ${resp} ... 400 @@ -384,7 +283,6 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... cause=Invalid eventFilter for event SERVICE_API_UNAVAILABLE ... invalidParams=${invalid_param_list} - # Wrong filter on SERVICE_API_UPDATE ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_aef_ids} ${request_body}= Create Events Subscription @@ -400,8 +298,10 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... username=${INVOKER_USERNAME} # Check Results - ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event SERVICE_API_UPDATE are not applicable. - ${invalid_param_list}= Create List ${invalid_param} + ${invalid_param}= Create Dictionary + ... param=eventFilter + ... reason=The eventFilter {'aef_ids'} for event SERVICE_API_UPDATE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} Check Response Variable Type And Values ... ${resp} ... 400 @@ -413,7 +313,10 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... invalidParams=${invalid_param_list} # Wrong filter on SERVICE_API_UPDATE with apiIds - ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_api_invoker_ids} + ${event_filters}= Create List + ... ${event_filter_empty} + ... ${event_filter_empty} + ... ${event_filter_api_invoker_ids} ${request_body}= Create Events Subscription ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing @@ -427,8 +330,10 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... username=${INVOKER_USERNAME} # Check Results - ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'api_invoker_ids'} for event SERVICE_API_UPDATE are not applicable. - ${invalid_param_list}= Create List ${invalid_param} + ${invalid_param}= Create Dictionary + ... param=eventFilter + ... reason=The eventFilter {'api_invoker_ids'} for event SERVICE_API_UPDATE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} Check Response Variable Type And Values ... ${resp} ... 400 @@ -483,19 +388,24 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} # Default Invoker Registration and Onboarding - ${register_user_info_invoker_1} ${invoker_url_1} ${invoker_request_body_1}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 - ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} + ${register_user_info_invoker_1} ${invoker_url_1} ${invoker_request_body_1}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_1 + ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} # Default Invoker Registration and Onboarding - ${register_user_info_invoker_2} ${invoker_url_2} ${invoker_request_body_2}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_2 - ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} + ${register_user_info_invoker_2} ${invoker_url_2} ${invoker_request_body_2}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_2 + ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} # Subscribe to events - ${events_list}= Create List API_INVOKER_ONBOARDED API_INVOKER_OFFBOARDED API_INVOKER_UPDATED + ${events_list}= Create List API_INVOKER_ONBOARDED API_INVOKER_OFFBOARDED API_INVOKER_UPDATED ${event_filter_empty}= Create Capif Event Filter ${event_filter_invoker_id_1}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} ${event_filter_invoker_id_2}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_2} - ${event_filters}= Create List ${event_filter_empty} ${event_filter_invoker_id_1} ${event_filter_invoker_id_2} + ${event_filters}= Create List + ... ${event_filter_empty} + ... ${event_filter_invoker_id_1} + ... ${event_filter_invoker_id_2} ${request_body}= Create Events Subscription ... events=@{events_list} @@ -565,7 +475,7 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV # Check Event Notifications ## Create check Events to ensure all notifications were received - ${invoker_urls_both}= Create List ${invoker_url_1} ${invoker_url_2} + ${invoker_urls_both}= Create List ${invoker_url_1} ${invoker_url_2} ${invoker_urls_1}= Create List ${invoker_url_1} ${invoker_urls_2}= Create List ${invoker_url_2} ${empty_list}= Create List @@ -627,15 +537,17 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} # Default Invoker Registration and Onboarding - ${register_user_info_invoker_1} ${invoker_url_1} ${invoker_request_body_1}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 - ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} + ${register_user_info_invoker_1} ${invoker_url_1} ${invoker_request_body_1}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_1 + ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} # Default Invoker Registration and Onboarding - ${register_user_info_invoker_2} ${invoker_url_2} ${invoker_request_body_2}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_2 - ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} + ${register_user_info_invoker_2} ${invoker_url_2} ${invoker_request_body_2}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_2 + ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} # Subscribe to events - ${events_list}= Create List API_INVOKER_ONBOARDED API_INVOKER_OFFBOARDED API_INVOKER_UPDATED + ${events_list}= Create List API_INVOKER_ONBOARDED API_INVOKER_OFFBOARDED API_INVOKER_UPDATED ${event_filter_empty}= Create Capif Event Filter ${event_filter_aef_ids}= Create Capif Event Filter aefIds=${aef_ids} ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_description_published['apiId']} @@ -655,8 +567,10 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ... username=${AMF_PROVIDER_USERNAME} # Check Results - ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event API_INVOKER_ONBOARDED are not applicable. - ${invalid_param_list}= Create List ${invalid_param} + ${invalid_param}= Create Dictionary + ... param=eventFilter + ... reason=The eventFilter {'aef_ids'} for event API_INVOKER_ONBOARDED are not applicable. + ${invalid_param_list}= Create List ${invalid_param} Check Response Variable Type And Values ... ${resp} ... 400 @@ -681,9 +595,11 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ... verify=ca.crt ... username=${AMF_PROVIDER_USERNAME} - # Check Results - ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event API_INVOKER_OFFBOARDED are not applicable. - ${invalid_param_list}= Create List ${invalid_param} + # Check Results + ${invalid_param}= Create Dictionary + ... param=eventFilter + ... reason=The eventFilter {'aef_ids'} for event API_INVOKER_OFFBOARDED are not applicable. + ${invalid_param_list}= Create List ${invalid_param} Check Response Variable Type And Values ... ${resp} ... 400 @@ -708,9 +624,11 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ... verify=ca.crt ... username=${AMF_PROVIDER_USERNAME} - # Check Results - ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event API_INVOKER_UPDATED are not applicable. - ${invalid_param_list}= Create List ${invalid_param} + # Check Results + ${invalid_param}= Create Dictionary + ... param=eventFilter + ... reason=The eventFilter {'aef_ids'} for event API_INVOKER_UPDATED are not applicable. + ${invalid_param_list}= Create List ${invalid_param} Check Response Variable Type And Values ... ${resp} ... 400 @@ -735,9 +653,11 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ... verify=ca.crt ... username=${AMF_PROVIDER_USERNAME} - # Check Results - ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'api_ids'} for event API_INVOKER_UPDATED are not applicable. - ${invalid_param_list}= Create List ${invalid_param} + # Check Results + ${invalid_param}= Create Dictionary + ... param=eventFilter + ... reason=The eventFilter {'api_ids'} for event API_INVOKER_UPDATED are not applicable. + ${invalid_param_list}= Create List ${invalid_param} Check Response Variable Type And Values ... ${resp} ... 400 @@ -747,6 +667,7 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ... detail=Bad Param ... cause=Invalid eventFilter for event API_INVOKER_UPDATED ... invalidParams=${invalid_param_list} + Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId, only invokerId and both [Tags] event_filter-5 mockserver smoke @@ -754,18 +675,24 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId Init Mock Server # Register provider 1 - ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 + ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 # Publish one api - ${service_api_description_published_1} ${provider_resource_url_1} ${provider_request_body_1}= Publish Service Api + ${service_api_description_published_1} + ... ${provider_resource_url_1} + ... ${provider_request_body_1}= + ... Publish Service Api ... ${register_user_info_provider_1} ... service_name=service_1 # Register APF - ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_2 + ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_2 # Publish one api - ${service_api_description_published_2} ${provider_resource_url_2} ${provider_request_body_2}= Publish Service Api + ${service_api_description_published_2} + ... ${provider_resource_url_2} + ... ${provider_request_body_2}= + ... Publish Service Api ... ${register_user_info_provider_2} ... service_name=service_2 @@ -775,106 +702,72 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId ${service_api_id_2}= Set Variable ${service_api_description_published_2['apiId']} # Register INVOKER 1 - ${register_user_info_invoker_1} ${invoker_url_1} ${request_body_1}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 + ${register_user_info_invoker_1} ${invoker_url_1} ${request_body_1}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_1 ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} # Register INVOKER 2 - ${register_user_info_invoker_2} ${invoker_url_2} ${request_body_2}= Invoker Default Onboarding invoke_username=${INVOKER_USERNAME}_2 + ${register_user_info_invoker_2} ${invoker_url_2} ${request_body_2}= Invoker Default Onboarding + ... invoke_username=${INVOKER_USERNAME}_2 ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} - # Subscribe to events ${events_list}= Create List ACCESS_CONTROL_POLICY_UPDATE - # Event filters - ${event_filter_empty}= Create Capif Event Filter + # Create Event filters ${event_filter_api_invoker_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} - ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_id_1} - ${event_filter_api_invoker_ids_and_api_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_2} apiIds=${service_api_id_2} + ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_id_1} + ${event_filter_api_invoker_ids_and_api_ids}= Create Capif Event Filter + ... apiInvokerIds=${api_invoker_id_2} + ... apiIds=${service_api_id_2} # Subscription to Events 1 - ${event_filters}= Create List ${event_filter_api_ids} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 - ... event_filters=${event_filters} - ${resp}= Post Request Capif - ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions - ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${register_user_info_provider_1['amf_username']} - - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} + ${event_filters}= Create List ${event_filter_api_ids} + ${subscription_id_1}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} # Subscription to Events 2 - ${event_filters}= Create List ${event_filter_api_invoker_ids_and_api_ids} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 - ... event_filters=${event_filters} - ${resp}= Post Request Capif - ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions - ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${register_user_info_provider_1['amf_username']} - - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id_2}= Check Event Location Header ${resp} + ${event_filters}= Create List ${event_filter_api_invoker_ids} + ${subscription_id_2}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} # Subscription to Events 3 - ${event_filters}= Create List ${event_filter_api_invoker_ids} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 - ... event_filters=${event_filters} - ${resp}= Post Request Capif - ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions - ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${register_user_info_provider_1['amf_username']} - - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id_3}= Check Event Location Header ${resp} - + ${event_filters}= Create List ${event_filter_api_invoker_ids_and_api_ids} + ${subscription_id_3}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} # Create Security Contexts and ACLs - ${acl_provider_1}= Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1} - ${acl_provider_1}= Create Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_1} + ${acl_provider_1}= + ... Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1} + ${acl_provider_1}= + ... Create Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_1} - ${acl_provider_2}= Update Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_2} - ${acl_provider_2}= Update Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_2} + ${acl_provider_2}= + ... Update Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_2} + ${acl_provider_2}= + ... Update Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_2} # Check Event Notifications ## Create check Events to ensure all notifications were received ### Subscription 1 Checks - ${acl_to_check}= Create List ${acl_provider_1[0]} + ${acl_to_check}= Create List ${acl_provider_1[0]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} ... ${service_api_id_1} ... ${acl_to_check} - ${acl_to_check}= Create List ${acl_provider_1[1]} + ${acl_to_check}= Create List ${acl_provider_1[1]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} ... ${service_api_id_1} ... ${acl_to_check} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_1[0]} + ${acl_to_check}= Create List ${acl_provider_1[0]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} ... ${service_api_id_1} ... ${acl_to_check} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_1[1]} + ${acl_to_check}= Create List ${acl_provider_1[1]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} ... ${service_api_id_1} @@ -882,29 +775,29 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId ... events_expected=${events_expected} ### Subscription 2 checks - ${acl_to_check}= Create List ${acl_provider_2[1]} + ${acl_to_check}= Create List ${acl_provider_1[0]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_2} - ... ${service_api_id_2} + ... ${service_api_id_1} ... ${acl_to_check} ... events_expected=${events_expected} - ### Subscription 3 checks - ${acl_to_check}= Create List ${acl_provider_1[0]} + ${acl_to_check}= Create List ${acl_provider_1[0]} ${events_expected}= Create Expected Access Control Policy Update Event - ... ${subscription_id_3} + ... ${subscription_id_2} ... ${service_api_id_1} ... ${acl_to_check} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_1[0]} + ${acl_to_check}= Create List ${acl_provider_2[0]} ${events_expected}= Create Expected Access Control Policy Update Event - ... ${subscription_id_3} - ... ${service_api_id_1} + ... ${subscription_id_2} + ... ${service_api_id_2} ... ${acl_to_check} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_2[0]} + ### Subscription 3 checks + ${acl_to_check}= Create List ${acl_provider_2[1]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_3} ... ${service_api_id_2} @@ -916,19 +809,22 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} - Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by aefId - [Tags] event_filter-6 smoke + [Tags] event_filter-6 smoke # Initialize Mock server Init Mock Server # Register provider 1 - ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 - ${aef_id_1}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 + ${aef_id_1}= Set Variable + ... ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} # Publish one api - ${service_api_description_published_1} ${provider_resource_url_1} ${provider_request_body_1}= Publish Service Api + ${service_api_description_published_1} + ... ${provider_resource_url_1} + ... ${provider_request_body_1}= + ... Publish Service Api ... ${register_user_info_provider_1} ... service_name=service_1 @@ -939,10 +835,10 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by aefId ${events_list}= Create List ACCESS_CONTROL_POLICY_UPDATE # Event filters - ${event_filter_aef_id}= Create Capif Event Filter aefIds=${aef_id_1} + ${event_filter_aef_id}= Create Capif Event Filter aefIds=${aef_id_1} # Subscription to Events 1 - ${event_filters}= Create List ${event_filter_aef_id} + ${event_filters}= Create List ${event_filter_aef_id} ${request_body}= Create Events Subscription ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing @@ -956,8 +852,10 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by aefId ... username=${register_user_info_provider_1['amf_username']} # Check Results - ${invalid_param}= Create Dictionary param=eventFilter reason=The eventFilter {'aef_ids'} for event ACCESS_CONTROL_POLICY_UPDATE are not applicable. - ${invalid_param_list}= Create List ${invalid_param} + ${invalid_param}= Create Dictionary + ... param=eventFilter + ... reason=The eventFilter {'aef_ids'} for event ACCESS_CONTROL_POLICY_UPDATE are not applicable. + ${invalid_param_list}= Create List ${invalid_param} Check Response Variable Type And Values ... ${resp} ... 400 @@ -975,18 +873,28 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION Init Mock Server # Register provider 1 - ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 + ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 + ${aef_id_1}= Set Variable + ... ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} # Publish one api - ${service_api_description_published_1} ${provider_resource_url_1} ${provider_request_body_1}= Publish Service Api + ${service_api_description_published_1} + ... ${provider_resource_url_1} + ... ${provider_request_body_1}= + ... Publish Service Api ... ${register_user_info_provider_1} ... service_name=service_1 # Register APF - ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_2 + ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_2 + ${aef_id_2}= Set Variable + ... ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_2']['aef_id']} # Publish one api - ${service_api_description_published_2} ${provider_resource_url_2} ${provider_request_body_2}= Publish Service Api + ${service_api_description_published_2} + ... ${provider_resource_url_2} + ... ${provider_request_body_2}= + ... Publish Service Api ... ${register_user_info_provider_2} ... service_name=service_2 @@ -996,106 +904,136 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION ${service_api_id_2}= Set Variable ${service_api_description_published_2['apiId']} # Register INVOKER 1 - ${register_user_info_invoker_1} ${invoker_url_1} ${request_body_1}= Invoker Default Onboarding invoker_username=${INVOKER_USERNAME}_1 + ${register_user_info_invoker_1} ${invoker_url_1} ${request_body_1}= Invoker Default Onboarding + ... invoker_username=${INVOKER_USERNAME}_1 ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} # Register INVOKER 2 - ${register_user_info_invoker_2} ${invoker_url_2} ${request_body_2}= Invoker Default Onboarding invoke_username=${INVOKER_USERNAME}_2 + ${register_user_info_invoker_2} ${invoker_url_2} ${request_body_2}= Invoker Default Onboarding + ... invoke_username=${INVOKER_USERNAME}_2 ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} - # Subscribe to events - ${events_list}= Create List ACCESS_CONTROL_POLICY_UPDATE + ## Event lists + ${events_list}= Create List SERVICE_API_INVOCATION_SUCCESS SERVICE_API_INVOCATION_FAILURE - # Event filters + ## Event filters ${event_filter_empty}= Create Capif Event Filter ${event_filter_api_invoker_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} - ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_id_1} - ${event_filter_api_invoker_ids_and_api_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_2} apiIds=${service_api_id_2} + ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_id_1} + ${event_filter_aef_ids}= Create Capif Event Filter aefIds=${aef_id_1} + ${event_filter_api_ids_and_aef_ids}= Create Capif Event Filter + ... apiIds=${service_api_id_2} + ... aefIds=${aef_id_2} + ${event_filter_api_ids_and_api_invoker_ids}= Create Capif Event Filter + ... apiInvokerIds=${api_invoker_id_2} + ... apiIds=${service_api_id_2} + ${event_filter_aef_ids_and_api_invoker_ids}= Create Capif Event Filter + ... apiInvokerIds=${api_invoker_id_2} + ... aefIds=${aef_id_2} + ${event_filter_api_ids_aef_ids_and_api_invoker_ids}= Create Capif Event Filter + ... apiInvokerIds=${api_invoker_id_2} + ... aefIds=${aef_id_2} + ... apiIds=${service_api_id_2} + + ## Subscription to Events 1 + ${event_filters}= Create List ${event_filter_api_ids} + ${subscription_id_1}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + + ## Subscription to Events 2 + ${event_filters}= Create List ${event_filter_aef_ids} + ${subscription_id_2}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + + ## Subscription to Events 3 + ${event_filters}= Create List ${event_filter_api_invoker_ids} + ${subscription_id_3}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + + ## Subscription to Events 4 + ${event_filters}= Create List ${event_filter_api_ids_and_aef_ids} + ${subscription_id_4}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + + ## Subscription to Events 5 + ${event_filters}= Create List ${event_filter_api_ids_and_api_invoker_ids} + ${subscription_id_5}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + + ## Subscription to Events 6 + ${event_filters}= Create List ${event_filter_aef_ids_and_api_invoker_ids} + ${subscription_id_6}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + + ## Subscription to Events 7 + ${event_filters}= Create List ${event_filter_api_ids_aef_ids_and_api_invoker_ids} + ${subscription_id_7}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - # Subscription to Events 1 - ${event_filters}= Create List ${event_filter_api_ids} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 - ... event_filters=${event_filters} - ${resp}= Post Request Capif - ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions - ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${register_user_info_provider_1['amf_username']} + # Create Security Contexts and ACLs + ${acl_provider_1}= + ... Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1} + ${acl_provider_1}= + ... Create Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_1} - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} + ${acl_provider_2}= + ... Update Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_2} + ${acl_provider_2}= + ... Update Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_2} - # Subscription to Events 2 - ${event_filters}= Create List ${event_filter_api_invoker_ids_and_api_ids} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 - ... event_filters=${event_filters} - ${resp}= Post Request Capif - ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions - ... json=${request_body} + # Create Log Entry, emulate success and failure api invocation + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker_1['api_invoker_id']} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt - ... username=${register_user_info_provider_1['amf_username']} + ... username=${register_user_info_invoker_1['management_cert']} - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id_2}= Check Event Location Header ${resp} + ${api_ids} ${api_names}= Get Api Ids And Names From Discover Response ${discover_response} - # Subscription to Events 3 - ${event_filters}= Create List ${event_filter_api_invoker_ids} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 - ... event_filters=${event_filters} + ${results}= Create List 200 400 + ${request_body}= Create Log Entry + ... ${register_user_info_provider_1['aef_id']} + ... ${register_user_info_invoker_1['api_invoker_id']} + ... ${api_ids} + ... ${api_names} + ... results=${results} ${resp}= Post Request Capif - ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions + ... /api-invocation-logs/v1/${register_user_info_provider_1['aef_id']}/logs ... json=${request_body} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${register_user_info_provider_1['amf_username']} - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id_3}= Check Event Location Header ${resp} - + Check Response Variable Type And Values ${resp} 201 InvocationLog + ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} - # Create Security Contexts and ACLs - ${acl_provider_1}= Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1} - ${acl_provider_1}= Create Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_1} + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id_1} + ... ${request_body} + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} - ${acl_provider_2}= Update Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_2} - ${acl_provider_2}= Update Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_2} # Check Event Notifications ## Create check Events to ensure all notifications were received ### Subscription 1 Checks - ${acl_to_check}= Create List ${acl_provider_1[0]} + ${acl_to_check}= Create List ${acl_provider_1[0]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} ... ${service_api_id_1} ... ${acl_to_check} - ${acl_to_check}= Create List ${acl_provider_1[1]} + ${acl_to_check}= Create List ${acl_provider_1[1]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} ... ${service_api_id_1} ... ${acl_to_check} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_1[0]} + ${acl_to_check}= Create List ${acl_provider_1[0]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} ... ${service_api_id_1} ... ${acl_to_check} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_1[1]} + ${acl_to_check}= Create List ${acl_provider_1[1]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_1} ... ${service_api_id_1} @@ -1103,7 +1041,7 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION ... events_expected=${events_expected} ### Subscription 2 checks - ${acl_to_check}= Create List ${acl_provider_2[1]} + ${acl_to_check}= Create List ${acl_provider_2[1]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_2} ... ${service_api_id_2} @@ -1111,21 +1049,21 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION ... events_expected=${events_expected} ### Subscription 3 checks - ${acl_to_check}= Create List ${acl_provider_1[0]} + ${acl_to_check}= Create List ${acl_provider_1[0]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_3} ... ${service_api_id_1} ... ${acl_to_check} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_1[0]} + ${acl_to_check}= Create List ${acl_provider_1[0]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_3} ... ${service_api_id_1} ... ${acl_to_check} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_2[0]} + ${acl_to_check}= Create List ${acl_provider_2[0]} ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id_3} ... ${service_api_id_2} @@ -1135,4 +1073,131 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION Log List ${events_expected} ## Check Events Expected towards received notifications at mock server - Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} \ No newline at end of file + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + + +*** Keywords *** +Create Security Context between ${invoker_info} and ${provider_info} + # Discover APIs by invoker + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${invoker_info['api_invoker_id']}&aef-id=${provider_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${invoker_info['management_cert']} + + Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs + + # create Security Context + ${request_service_security_body} ${api_ids}= Create Service Security From Discover Response + ... http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/test + ... ${discover_response} + ... legacy=${FALSE} + ${resp}= Put Request Capif + ... /capif-security/v1/trustedInvokers/${invoker_info['api_invoker_id']} + ... json=${request_service_security_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${invoker_info['management_cert']} + + Set To Dictionary ${invoker_info} security_body=${request_service_security_body} + # Check Service Security + Check Response Variable Type And Values ${resp} 201 ServiceSecurity + ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} + + ${api_invoker_policies_list}= Create List + + FOR ${api_id} IN @{api_ids} + Log ${api_id} + ${resp}= Get Request Capif + ... /access-control-policy/v1/accessControlPolicyList/${api_id}?aef-id=${provider_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${provider_info['aef_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']} + # ... ${invoker_info['api_invoker_id']} + + ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} + # Append To List ${api_invoker_policies_list} ${api_invoker_policies} + ${api_invoker_policies_list}= Set Variable ${api_invoker_policies} + END + + Log List ${api_invoker_policies_list} + + RETURN ${api_invoker_policies_list} + +Update Security Context between ${invoker_info} and ${provider_info} + # Discover APIs by invoker + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${invoker_info['api_invoker_id']}&aef-id=${provider_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${invoker_info['management_cert']} + + Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs + + # create Security Context + ${request_service_security_body} ${api_ids}= Update Service Security With Discover Response + ... ${invoker_info['security_body']} + ... ${discover_response} + ... legacy=${FALSE} + ${resp}= Post Request Capif + ... /capif-security/v1/trustedInvokers/${invoker_info['api_invoker_id']}/update + ... json=${request_service_security_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${invoker_info['management_cert']} + + # Check Service Security + Check Response Variable Type And Values ${resp} 200 ServiceSecurity + ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} + + ${api_invoker_policies_list}= Create List + + ${api_id}= Get From List ${api_ids} -1 + Log ${api_id} + ${resp}= Get Request Capif + ... /access-control-policy/v1/accessControlPolicyList/${api_id}?aef-id=${provider_info['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${provider_info['aef_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']} + # ... ${invoker_info['api_invoker_id']} + + ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} + # Append To List ${api_invoker_policies_list} ${api_invoker_policies} + ${api_invoker_policies_list}= Set Variable ${api_invoker_policies} + + Log List ${api_invoker_policies_list} + + RETURN ${api_invoker_policies_list} + +Subscribe provider ${provider_info} to events ${events_list} with event filters ${event_filters} + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ... event_filters=${event_filters} + ${resp}= Post Request Capif + ... /capif-events/v1/${provider_info['amf_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${provider_info['amf_username']} + + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + + RETURN ${subscription_id} + -- GitLab From 59d7c7f12d890f70389cffd2d3abd0dbac400915 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Wed, 5 Mar 2025 13:04:08 +0100 Subject: [PATCH 09/12] New test for event filters and INVOCATION events --- .../features/Event Filter/event_filter.robot | 214 +++++++++--------- tests/resources/common/expectedMessages.robot | 1 + 2 files changed, 108 insertions(+), 107 deletions(-) diff --git a/tests/features/Event Filter/event_filter.robot b/tests/features/Event Filter/event_filter.robot index 5bc3a112..2172d74a 100644 --- a/tests/features/Event Filter/event_filter.robot +++ b/tests/features/Event Filter/event_filter.robot @@ -723,15 +723,18 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId # Subscription to Events 1 ${event_filters}= Create List ${event_filter_api_ids} - ${subscription_id_1}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + ${subscription_id_1}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} # Subscription to Events 2 ${event_filters}= Create List ${event_filter_api_invoker_ids} - ${subscription_id_2}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + ${subscription_id_2}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} # Subscription to Events 3 ${event_filters}= Create List ${event_filter_api_invoker_ids_and_api_ids} - ${subscription_id_3}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + ${subscription_id_3}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} # Create Security Contexts and ACLs ${acl_provider_1}= @@ -915,13 +918,13 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION # Subscribe to events ## Event lists - ${events_list}= Create List SERVICE_API_INVOCATION_SUCCESS SERVICE_API_INVOCATION_FAILURE + ${events_list}= Create List SERVICE_API_INVOCATION_SUCCESS SERVICE_API_INVOCATION_FAILURE ## Event filters ${event_filter_empty}= Create Capif Event Filter ${event_filter_api_invoker_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_id_1} - ${event_filter_aef_ids}= Create Capif Event Filter aefIds=${aef_id_1} + ${event_filter_aef_ids}= Create Capif Event Filter aefIds=${aef_id_2} ${event_filter_api_ids_and_aef_ids}= Create Capif Event Filter ... apiIds=${service_api_id_2} ... aefIds=${aef_id_2} @@ -930,152 +933,129 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION ... apiIds=${service_api_id_2} ${event_filter_aef_ids_and_api_invoker_ids}= Create Capif Event Filter ... apiInvokerIds=${api_invoker_id_2} - ... aefIds=${aef_id_2} + ... aefIds=${aef_id_1} ${event_filter_api_ids_aef_ids_and_api_invoker_ids}= Create Capif Event Filter ... apiInvokerIds=${api_invoker_id_2} ... aefIds=${aef_id_2} ... apiIds=${service_api_id_2} ## Subscription to Events 1 - ${event_filters}= Create List ${event_filter_api_ids} - ${subscription_id_1}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + ${event_filters}= Create List ${event_filter_api_ids} ${event_filter_api_ids} + ${subscription_id_1}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - ## Subscription to Events 2 - ${event_filters}= Create List ${event_filter_aef_ids} - ${subscription_id_2}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + # ## Subscription to Events 2 + ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_aef_ids} + ${subscription_id_2}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} ## Subscription to Events 3 - ${event_filters}= Create List ${event_filter_api_invoker_ids} - ${subscription_id_3}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + ${event_filters}= Create List ${event_filter_api_invoker_ids} ${event_filter_api_invoker_ids} + ${subscription_id_3}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - ## Subscription to Events 4 - ${event_filters}= Create List ${event_filter_api_ids_and_aef_ids} - ${subscription_id_4}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + # ## Subscription to Events 4 + ${event_filters}= Create List ${event_filter_api_ids_and_aef_ids} ${event_filter_api_ids_and_aef_ids} + ${subscription_id_4}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - ## Subscription to Events 5 - ${event_filters}= Create List ${event_filter_api_ids_and_api_invoker_ids} - ${subscription_id_5}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + # ## Subscription to Events 5 + ${event_filters}= Create List ${event_filter_api_ids_and_api_invoker_ids} ${event_filter_api_ids_and_api_invoker_ids} + ${subscription_id_5}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - ## Subscription to Events 6 - ${event_filters}= Create List ${event_filter_aef_ids_and_api_invoker_ids} - ${subscription_id_6}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + # ## Subscription to Events 6 + ${event_filters}= Create List ${event_filter_aef_ids_and_api_invoker_ids} ${event_filter_aef_ids_and_api_invoker_ids} + ${subscription_id_6}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - ## Subscription to Events 7 - ${event_filters}= Create List ${event_filter_api_ids_aef_ids_and_api_invoker_ids} - ${subscription_id_7}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + # ## Subscription to Events 7 + ${event_filters}= Create List ${event_filter_api_ids_aef_ids_and_api_invoker_ids} ${event_filter_api_ids_aef_ids_and_api_invoker_ids} + ${subscription_id_7}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - # Create Security Contexts and ACLs - ${acl_provider_1}= - ... Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1} - ${acl_provider_1}= - ... Create Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_1} + # 1.Log entry for service_1 and invoker_1 + ${request_body_log_1}= Send Log Message to CAPIF ${service_api_id_1} service_1 ${register_user_info_invoker_1} ${register_user_info_provider_1} 200 400 - ${acl_provider_2}= - ... Update Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_2} - ${acl_provider_2}= - ... Update Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_2} + # 2.Log entry for service_2 and invoker_1 + ${request_body_log_2}= Send Log Message to CAPIF ${service_api_id_2} service_2 ${register_user_info_invoker_1} ${register_user_info_provider_2} 200 - # Create Log Entry, emulate success and failure api invocation - ${discover_response}= Get Request Capif - ... ${DISCOVER_URL}${register_user_info_invoker_1['api_invoker_id']} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${register_user_info_invoker_1['management_cert']} - - ${api_ids} ${api_names}= Get Api Ids And Names From Discover Response ${discover_response} + # 3.Log entry for service_2 and invoker_2 + ${request_body_log_3}= Send Log Message to CAPIF ${service_api_id_2} service_2 ${register_user_info_invoker_2} ${register_user_info_provider_2} 200 - ${results}= Create List 200 400 - ${request_body}= Create Log Entry - ... ${register_user_info_provider_1['aef_id']} - ... ${register_user_info_invoker_1['api_invoker_id']} - ... ${api_ids} - ... ${api_names} - ... results=${results} - ${resp}= Post Request Capif - ... /api-invocation-logs/v1/${register_user_info_provider_1['aef_id']}/logs - ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${register_user_info_provider_1['amf_username']} - - Check Response Variable Type And Values ${resp} 201 InvocationLog - ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} + # 4.Log entry for service_1 and invoker_2 + ${request_body_log_4}= Send Log Message to CAPIF ${service_api_id_1} service_1 ${register_user_info_invoker_2} ${register_user_info_provider_1} 400 # Check Event Notifications ## Create check Events to ensure all notifications were received + ### Subscription 1 Checks ${events_expected}= Create Events From InvocationLogs ... ${subscription_id_1} - ... ${request_body} - ## Check Events Expected towards received notifications at mock server - Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} - + ... ${request_body_log_1} - # Check Event Notifications - ## Create check Events to ensure all notifications were received - ### Subscription 1 Checks - ${acl_to_check}= Create List ${acl_provider_1[0]} - ${events_expected}= Create Expected Access Control Policy Update Event + ${events_expected}= Create Events From InvocationLogs ... ${subscription_id_1} - ... ${service_api_id_1} - ... ${acl_to_check} + ... ${request_body_log_4} + ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_1[1]} - ${events_expected}= Create Expected Access Control Policy Update Event - ... ${subscription_id_1} - ... ${service_api_id_1} - ... ${acl_to_check} + ### Subcription 2 Checks + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id_2} + ... ${request_body_log_2} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_1[0]} - ${events_expected}= Create Expected Access Control Policy Update Event - ... ${subscription_id_1} - ... ${service_api_id_1} - ... ${acl_to_check} + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id_2} + ... ${request_body_log_3} + ... events_expected=${events_expected} + + # Subscription 3 Checks + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id_3} + ... ${request_body_log_1} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_1[1]} - ${events_expected}= Create Expected Access Control Policy Update Event - ... ${subscription_id_1} - ... ${service_api_id_1} - ... ${acl_to_check} + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id_3} + ... ${request_body_log_2} ... events_expected=${events_expected} - ### Subscription 2 checks - ${acl_to_check}= Create List ${acl_provider_2[1]} - ${events_expected}= Create Expected Access Control Policy Update Event - ... ${subscription_id_2} - ... ${service_api_id_2} - ... ${acl_to_check} + # Subscription 4 Checks + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id_4} + ... ${request_body_log_2} ... events_expected=${events_expected} - ### Subscription 3 checks - ${acl_to_check}= Create List ${acl_provider_1[0]} - ${events_expected}= Create Expected Access Control Policy Update Event - ... ${subscription_id_3} - ... ${service_api_id_1} - ... ${acl_to_check} + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id_4} + ... ${request_body_log_3} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_1[0]} - ${events_expected}= Create Expected Access Control Policy Update Event - ... ${subscription_id_3} - ... ${service_api_id_1} - ... ${acl_to_check} + # Subscription 5 Checks + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id_5} + ... ${request_body_log_3} ... events_expected=${events_expected} - ${acl_to_check}= Create List ${acl_provider_2[0]} - ${events_expected}= Create Expected Access Control Policy Update Event - ... ${subscription_id_3} - ... ${service_api_id_2} - ... ${acl_to_check} + # Subscription 6 Checks + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id_6} + ... ${request_body_log_4} + ... events_expected=${events_expected} + + # Subscription 7 Checks + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id_7} + ... ${request_body_log_3} ... events_expected=${events_expected} - Log List ${events_expected} + Log List ${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 Security Context between ${invoker_info} and ${provider_info} # Discover APIs by invoker @@ -1200,4 +1180,24 @@ Subscribe provider ${provider_info} to events ${events_list} with event filters ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} RETURN ${subscription_id} +Send Log Message to CAPIF + [Arguments] ${api_id} ${service_name} ${invoker_info} ${provider_info} @{results} + ${api_ids}= Create List ${api_id} + ${api_names}= Create List ${service_name} + ${request_body}= Create Log Entry + ... ${provider_info['aef_id']} + ... ${invoker_info['api_invoker_id']} + ... ${api_ids} + ... ${api_names} + ... results=@{results} + ${resp}= Post Request Capif + ... /api-invocation-logs/v1/${provider_info['aef_id']}/logs + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${provider_info['amf_username']} + + Check Response Variable Type And Values ${resp} 201 InvocationLog + ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} + RETURN ${request_body} diff --git a/tests/resources/common/expectedMessages.robot b/tests/resources/common/expectedMessages.robot index 65e6ac6f..346dfd76 100644 --- a/tests/resources/common/expectedMessages.robot +++ b/tests/resources/common/expectedMessages.robot @@ -12,6 +12,7 @@ Create Events From InvocationLogs ... ${invocation_log} ... ${events_expected}=${NONE} ... ${event_detail_expected}=${TRUE} + IF ${events_expected} == ${NONE} ${events_expected}= Create List END -- GitLab From e273685c4ee6449d7510e60873d6348322cadeca Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 6 Mar 2025 08:43:56 +0100 Subject: [PATCH 10/12] Setup transient version on OCF --- services/variables.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/variables.sh b/services/variables.sh index 748c8c0a..1fa65aa2 100755 --- a/services/variables.sh +++ b/services/variables.sh @@ -9,7 +9,7 @@ export ROBOT_DOCKER_FILE_FOLDER=$CAPIF_BASE_DIR/tools/robot # Image URL and version export REGISTRY_BASE_URL="labs.etsi.org:5050/ocf/capif/prod" -export OCF_VERSION="v2.0.0-release" +export OCF_VERSION="v2.x.x-release" # Capif hostname export CAPIF_HOSTNAME=capifcore -- GitLab From 8ccfed03a1880813d87277a61cd5c66bc8f18d3e Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 6 Mar 2025 10:56:03 +0100 Subject: [PATCH 11/12] Rewrite new tests in order to clarify steps on event filter test suite --- .../features/Event Filter/event_filter.robot | 644 ++++++------------ 1 file changed, 224 insertions(+), 420 deletions(-) diff --git a/tests/features/Event Filter/event_filter.robot b/tests/features/Event Filter/event_filter.robot index 2172d74a..b6718ce2 100644 --- a/tests/features/Event Filter/event_filter.robot +++ b/tests/features/Event Filter/event_filter.robot @@ -28,29 +28,28 @@ Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - # Register APF - ${register_user_info_provider}= Provider Default Registration total_aef_roles=2 - - ${aef_id_1}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} - ${aef_id_2}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + # Create Provider1 with 2 AEF roles and publish API + ${register_user_info_provider_1}= Provider Default Registration total_aef_roles=2 + ${aef_id_1}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} + ${aef_id_2}= Set Variable + ... ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} ${aef_empty_list}= Create List - # Publish api with 2 aefIds - ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api - ... ${register_user_info_provider} + ## Publish API service_1 with 2 aefIds + ${service_api_description_published_1} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info_provider_1} ... service_1 ... aef_id=${aef_ids} ... api_status=${aef_empty_list} ... supported_features=020 - # Register other provider + # Create Provider2 with 1 AEF role and publish API ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_NEW - ${aef2_id_1}= Set Variable ... ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} - # Publish api with other provider + ## Publish API service_2 with Provider2 ${service_api_description_published_2} ${resource_url_2} ${request_body_2}= Publish Service Api ... ${register_user_info_provider_2} ... service_2 @@ -58,7 +57,7 @@ Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... api_status=${aef2_id_1} ... supported_features=020 - # Discover APIs by invoker + # Discover APIs by Invoker filtering by aefId1 of Provider1 ${resp}= Get Request Capif ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${aef_id_1} ... server=${CAPIF_HTTPS_URL} @@ -66,35 +65,20 @@ Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... username=${INVOKER_USERNAME} Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs - - # # Check Results Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 - List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} + List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published_1} + ## Store apiId for further use ${api_id}= Set Variable ${resp.json()['serviceAPIDescriptions'][0]['apiId']} - # Subscribe to events + # Subscribe to events and setup event filter with api_id ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE SERVICE_API_UPDATE ${event_filter}= Create Capif Event Filter apiIds=${api_id} ${event_filters}= Create List ${event_filter} ${event_filter} ${event_filter} - - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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} + ${subscription_id}= + ... Subscribe invoker ${register_user_info_invoker} to events ${events_list} with event filters ${event_filters} # Update Request to published API ${service_api_description_modified}= Create Service Api Description @@ -113,26 +97,25 @@ Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... apiName=service_1 Dictionary Should Contain Key ${resp.json()} apiStatus - # Provider Remove service_1 published API + # Remove Providers + ## Remove Provider1 ${resp}= Delete Request Capif ... ${resource_url.path} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${APF_PROVIDER_USERNAME} - Status Should Be 204 ${resp} - # Provider 2 Remove service_1 published API + ## Remove Provider2 ${resp}= Delete Request Capif ... ${resource_url_2.path} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${APF_PROVIDER_USERNAME}_NEW - Status Should Be 204 ${resp} - # Check Event Notifications - ## Create check Events to ensure all notifications were received + # Create check Events to ensure all notifications were received + ## Service API Available event ${service_api_available_resources}= Create List ${resource_url} ${events_expected}= Create Expected Events For Service API Notifications ... subscription_id=${subscription_id} @@ -142,6 +125,7 @@ Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... service_api_description=${service_api_description_modified} Log List ${events_expected} + ## Service API Update event ${events_expected}= Create Expected Service Update Event ... subscription_id=${subscription_id} ... service_api_resource=${resource_url} @@ -149,6 +133,7 @@ Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... events_expected=${events_expected} Log List ${events_expected} + ## Service API Unavailable event ${service_api_unavailable_resources}= Create List ${resource_url} ${events_expected}= Create Expected Events For Service API Notifications ... subscription_id=${subscription_id} @@ -159,41 +144,36 @@ Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... events_expected=${events_expected} Log List ${events_expected} - ## Check Events Expected towards received notifications at mock server + # Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE_API_UPDATE events filtered by not valid filters - [Tags] event_filter-2 mockserver - - # Initialize Mock server - Init Mock Server + [Tags] event_filter-2 # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - # Register APF - ${register_user_info_provider}= Provider Default Registration total_aef_roles=2 - - ${aef_id_1}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} - ${aef_id_2}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + # Create Provider1 with 2 AEF roles and publish API + ${register_user_info_provider_1}= Provider Default Registration total_aef_roles=2 + ${aef_id_1}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} + ${aef_id_2}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} ${aef_empty_list}= Create List - # Publish api with 2 aefIds + ## Publish API service_1 with 2 aefIds ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api - ... ${register_user_info_provider} + ... ${register_user_info_provider_1} ... service_1 ... aef_id=${aef_ids} ... api_status=${aef_empty_list} ... supported_features=020 - # Register other provider + # Create Provider2 and publish API ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_NEW - ${aef2_id_1}= Set Variable ... ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']} - # Publish api with other provider + ## Publish API service_2 ${service_api_description_published_2} ${resource_url_2} ${request_body_2}= Publish Service Api ... ${register_user_info_provider_2} ... service_2 @@ -207,142 +187,61 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${INVOKER_USERNAME} - Check Response Variable Type And Values ${resp} 200 DiscoveredAPIs - - # # Check Results Dictionary Should Contain Key ${resp.json()} serviceAPIDescriptions Should Not Be Empty ${resp.json()['serviceAPIDescriptions']} Length Should Be ${resp.json()['serviceAPIDescriptions']} 1 List Should Contain Value ${resp.json()['serviceAPIDescriptions']} ${service_api_description_published} + ## Store apiId for further use ${api_id}= Set Variable ${resp.json()['serviceAPIDescriptions'][0]['apiId']} - # Wrong filter on SERVICE_API_AVAILABLE + # Event Subscription + ## Events list ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE SERVICE_API_UPDATE + + ## Event filters ${event_filter_empty}= Create Capif Event Filter ${event_filter_aef_ids}= Create Capif Event Filter aefIds=${aef_ids} ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_description_published['apiId']} ${event_filter_api_invoker_ids}= Create Capif Event Filter ... apiInvokerIds=${register_user_info_invoker['api_invoker_id']} - ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_empty} ${event_filter_empty} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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} + ## Subscription to Events filtering by aefIds SERVICE_API_AVAILABLE event + ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_empty} ${event_filter_empty} + ${resp}= + ... Subscribe ${register_user_info_invoker['api_invoker_id']} with ${register_user_info_invoker['management_cert']} to ${events_list} with ${event_filters} - # Check Results - ${invalid_param}= Create Dictionary - ... param=eventFilter - ... reason=The eventFilter {'aef_ids'} for event SERVICE_API_AVAILABLE are not applicable. - ${invalid_param_list}= Create List ${invalid_param} - Check Response Variable Type And Values - ... ${resp} - ... 400 - ... ProblemDetails - ... title=Bad Request - ... status=400 - ... detail=Bad Param - ... cause=Invalid eventFilter for event SERVICE_API_AVAILABLE - ... invalidParams=${invalid_param_list} + ### Check Error Response + Check not valid ${resp} with event filter aef_ids for event SERVICE_API_AVAILABLE - # Wrong filter on SERVICE_API_UNAVAILABLE + ## Subscription to Events filtering by aefIds SERVICE_API_UNAVAILABLE event ${event_filters}= Create List ${event_filter_empty} ${event_filter_aef_ids} ${event_filter_empty} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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} + ${resp}= + ... Subscribe ${register_user_info_invoker['api_invoker_id']} with ${register_user_info_invoker['management_cert']} to ${events_list} with ${event_filters} - # Check Results - ${invalid_param}= Create Dictionary - ... param=eventFilter - ... reason=The eventFilter {'aef_ids'} for event SERVICE_API_UNAVAILABLE are not applicable. - ${invalid_param_list}= Create List ${invalid_param} - Check Response Variable Type And Values - ... ${resp} - ... 400 - ... ProblemDetails - ... title=Bad Request - ... status=400 - ... detail=Bad Param - ... cause=Invalid eventFilter for event SERVICE_API_UNAVAILABLE - ... invalidParams=${invalid_param_list} + ### Check Error Response + Check not valid ${resp} with event filter aef_ids for event SERVICE_API_UNAVAILABLE - # Wrong filter on SERVICE_API_UPDATE + ## Subscription to Events filtering by aefIds SERVICE_API_UPDATE event ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_aef_ids} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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} + ${resp}= + ... Subscribe ${register_user_info_invoker['api_invoker_id']} with ${register_user_info_invoker['management_cert']} to ${events_list} with ${event_filters} - # Check Results - ${invalid_param}= Create Dictionary - ... param=eventFilter - ... reason=The eventFilter {'aef_ids'} for event SERVICE_API_UPDATE are not applicable. - ${invalid_param_list}= Create List ${invalid_param} - Check Response Variable Type And Values - ... ${resp} - ... 400 - ... ProblemDetails - ... title=Bad Request - ... status=400 - ... detail=Bad Param - ... cause=Invalid eventFilter for event SERVICE_API_UPDATE - ... invalidParams=${invalid_param_list} + ### Check Error Response + Check not valid ${resp} with event filter aef_ids for event SERVICE_API_UPDATE - # Wrong filter on SERVICE_API_UPDATE with apiIds + ## Subscription to Events filtering by api invoker ids SERVICE_API_UPDATE event ${event_filters}= Create List ... ${event_filter_empty} ... ${event_filter_empty} ... ${event_filter_api_invoker_ids} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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} + ${resp}= + ... Subscribe ${register_user_info_invoker['api_invoker_id']} with ${register_user_info_invoker['management_cert']} to ${events_list} with ${event_filters} + + ### Check Error Response + Check not valid ${resp} with event filter api_invoker_ids for event SERVICE_API_UPDATE - # Check Results - ${invalid_param}= Create Dictionary - ... param=eventFilter - ... reason=The eventFilter {'api_invoker_ids'} for event SERVICE_API_UPDATE are not applicable. - ${invalid_param_list}= Create List ${invalid_param} - Check Response Variable Type And Values - ... ${resp} - ... 400 - ... ProblemDetails - ... title=Bad Request - ... status=400 - ... detail=Bad Param - ... cause=Invalid eventFilter for event SERVICE_API_UPDATE - ... invalidParams=${invalid_param_list} Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INVOKER_UPDATED events filtered by invokerIds [Tags] event_filter-3 mockserver @@ -350,78 +249,56 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV # Initialize Mock server Init Mock Server - # Register APF - ${register_user_info_provider}= Provider Default Registration total_aef_roles=2 - - ${aef_id_1}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} - ${aef_id_2}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + # Create Provider1 with 2 AEF roles and publish API + ## Create Provider with 2 AEF roles + ${register_user_info_provider_1}= Provider Default Registration total_aef_roles=2 + ${aef_id_1}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} + ${aef_id_2}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} ${aef_empty_list}= Create List - # Publish api with 2 aefIds + ## Publish service_1 API ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api - ... ${register_user_info_provider} + ... ${register_user_info_provider_1} ... service_1 ... aef_id=${aef_ids} ... api_status=${aef_empty_list} ... supported_features=020 - # Subscribe to events + # Event Subscription + ## Event list ${events_list}= Create List API_INVOKER_ONBOARDED + ## Event filters ${event_filter}= Create Capif Event Filter + ## Subscribe API_INVOKER_ONBOARDED event without filters ${event_filters}= Create List ${event_filter} + ${subscription_id_1}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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=${AMF_PROVIDER_USERNAME} - - # Check Results - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} - - # Default Invoker Registration and Onboarding + # Default Invokers Registration and Onboarding + # Default Invoker 1 Registration and Onboarding ${register_user_info_invoker_1} ${invoker_url_1} ${invoker_request_body_1}= Invoker Default Onboarding ... invoker_username=${INVOKER_USERNAME}_1 ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} - # Default Invoker Registration and Onboarding + # Default Invoker 2 Registration and Onboarding ${register_user_info_invoker_2} ${invoker_url_2} ${invoker_request_body_2}= Invoker Default Onboarding ... invoker_username=${INVOKER_USERNAME}_2 ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} - # Subscribe to events + # Subscribe to events and setup event filter with api_invoker_id + ## Events list ${events_list}= Create List API_INVOKER_ONBOARDED API_INVOKER_OFFBOARDED API_INVOKER_UPDATED + ## Event filters ${event_filter_empty}= Create Capif Event Filter ${event_filter_invoker_id_1}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} ${event_filter_invoker_id_2}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_2} + + ## Subscribe to Invoker events. API_INVOKER_ONBOARDED event can be filtered by apiInvokerId but is not possible to get it before the invoker is registered ${event_filters}= Create List ... ${event_filter_empty} ... ${event_filter_invoker_id_1} ... ${event_filter_invoker_id_2} - - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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=${AMF_PROVIDER_USERNAME} - - # Check Results - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id_2}= Check Event Location Header ${resp} + ${subscription_id_2}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} # Update Invokers ## Update Invoker 1 @@ -478,7 +355,6 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ${invoker_urls_both}= Create List ${invoker_url_1} ${invoker_url_2} ${invoker_urls_1}= Create List ${invoker_url_1} ${invoker_urls_2}= Create List ${invoker_url_2} - ${empty_list}= Create List ${events_expected}= Create Expected Api Invoker Events ... ${subscription_id_1} ... api_invoker_onboarded_resources=${invoker_urls_both} @@ -500,42 +376,21 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV Init Mock Server # Register APF - ${register_user_info_provider}= Provider Default Registration total_aef_roles=2 + ${register_user_info_provider_1}= Provider Default Registration total_aef_roles=2 - ${aef_id_1}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} - ${aef_id_2}= Set Variable ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + ${aef_id_1}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} + ${aef_id_2}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} ${aef_empty_list}= Create List # Publish api with 2 aefIds ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api - ... ${register_user_info_provider} + ... ${register_user_info_provider_1} ... service_1 ... aef_id=${aef_ids} ... api_status=${aef_empty_list} ... supported_features=020 - # Subscribe to events - ${events_list}= Create List API_INVOKER_ONBOARDED - ${event_filter}= Create Capif Event Filter - ${event_filters}= Create List ${event_filter} - - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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=${AMF_PROVIDER_USERNAME} - - # Check Results - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id_1}= Check Event Location Header ${resp} - # Default Invoker Registration and Onboarding ${register_user_info_invoker_1} ${invoker_url_1} ${invoker_request_body_1}= Invoker Default Onboarding ... invoker_username=${INVOKER_USERNAME}_1 @@ -552,121 +407,34 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ${event_filter_aef_ids}= Create Capif Event Filter aefIds=${aef_ids} ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_description_published['apiId']} ${event_filter_invoker_id_2}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_2} - ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_empty} ${event_filter_empty} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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=${AMF_PROVIDER_USERNAME} + ## Event subscription with event filters by aef_ids + ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_empty} ${event_filter_empty} + ${resp}= Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} - # Check Results - ${invalid_param}= Create Dictionary - ... param=eventFilter - ... reason=The eventFilter {'aef_ids'} for event API_INVOKER_ONBOARDED are not applicable. - ${invalid_param_list}= Create List ${invalid_param} - Check Response Variable Type And Values - ... ${resp} - ... 400 - ... ProblemDetails - ... title=Bad Request - ... status=400 - ... detail=Bad Param - ... cause=Invalid eventFilter for event API_INVOKER_ONBOARDED - ... invalidParams=${invalid_param_list} + ### Check Results + Check not valid ${resp} with event filter aef_ids for event API_INVOKER_ONBOARDED - # Check API_INVOKER_OFFBOARDED + ## Event subcription API_INVOKER_OFFBOARDED filtered by aef_ids ${event_filters}= Create List ${event_filter_empty} ${event_filter_aef_ids} ${event_filter_empty} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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=${AMF_PROVIDER_USERNAME} + ${resp}= Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} - # Check Results - ${invalid_param}= Create Dictionary - ... param=eventFilter - ... reason=The eventFilter {'aef_ids'} for event API_INVOKER_OFFBOARDED are not applicable. - ${invalid_param_list}= Create List ${invalid_param} - Check Response Variable Type And Values - ... ${resp} - ... 400 - ... ProblemDetails - ... title=Bad Request - ... status=400 - ... detail=Bad Param - ... cause=Invalid eventFilter for event API_INVOKER_OFFBOARDED - ... invalidParams=${invalid_param_list} + ### Check Results + Check not valid ${resp} with event filter aef_ids for event API_INVOKER_OFFBOARDED - # Check API_INVOKER_UPDATED + ## Event subcription API_INVOKER_UPDATED filtered by aef_ids ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_aef_ids} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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=${AMF_PROVIDER_USERNAME} + ${resp}= Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} - # Check Results - ${invalid_param}= Create Dictionary - ... param=eventFilter - ... reason=The eventFilter {'aef_ids'} for event API_INVOKER_UPDATED are not applicable. - ${invalid_param_list}= Create List ${invalid_param} - Check Response Variable Type And Values - ... ${resp} - ... 400 - ... ProblemDetails - ... title=Bad Request - ... status=400 - ... detail=Bad Param - ... cause=Invalid eventFilter for event API_INVOKER_UPDATED - ... invalidParams=${invalid_param_list} + ### Check Results + Check not valid ${resp} with event filter aef_ids for event API_INVOKER_UPDATED - # Check API_INVOKER_UPDATED + ## Event subcription API_INVOKER_UPDATED filtered by api_ids ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_api_ids} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=C - ... event_filters=${event_filters} - ${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=${AMF_PROVIDER_USERNAME} + ${resp}= Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} - # Check Results - ${invalid_param}= Create Dictionary - ... param=eventFilter - ... reason=The eventFilter {'api_ids'} for event API_INVOKER_UPDATED are not applicable. - ${invalid_param_list}= Create List ${invalid_param} - Check Response Variable Type And Values - ... ${resp} - ... 400 - ... ProblemDetails - ... title=Bad Request - ... status=400 - ... detail=Bad Param - ... cause=Invalid eventFilter for event API_INVOKER_UPDATED - ... invalidParams=${invalid_param_list} + ### Check Results + Check not valid ${resp} with event filter api_ids for event API_INVOKER_UPDATED Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId, only invokerId and both [Tags] event_filter-5 mockserver smoke @@ -674,10 +442,11 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId # Initialize Mock server Init Mock Server - # Register provider 1 + # Create Providers + ## Default Provider 1 Registration ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 - # Publish one api + ## Publish service_1 API ${service_api_description_published_1} ... ${provider_resource_url_1} ... ${provider_request_body_1}= @@ -685,10 +454,10 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId ... ${register_user_info_provider_1} ... service_name=service_1 - # Register APF + ## Default Provider 2 Registration ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_2 - # Publish one api + ## Publish service_2 API ${service_api_description_published_2} ... ${provider_resource_url_2} ... ${provider_request_body_2}= @@ -696,47 +465,50 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId ... ${register_user_info_provider_2} ... service_name=service_2 - # Store apiId1 and apiId2 + ## Store apiId1 and apiId2 for further use ${service_api_id_1}= Set Variable ${service_api_description_published_1['apiId']} - ${service_api_id_2}= Set Variable ${service_api_description_published_2['apiId']} - # Register INVOKER 1 + # Register Invokers + ## Default Invoker1 onboarding ${register_user_info_invoker_1} ${invoker_url_1} ${request_body_1}= Invoker Default Onboarding ... invoker_username=${INVOKER_USERNAME}_1 - ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} - # Register INVOKER 2 + ## Default Invoker1 onboarding ${register_user_info_invoker_2} ${invoker_url_2} ${request_body_2}= Invoker Default Onboarding ... invoke_username=${INVOKER_USERNAME}_2 + + ## Store apiInvokerIds for further use + ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} # Subscribe to events + ## Events list ${events_list}= Create List ACCESS_CONTROL_POLICY_UPDATE - # Create Event filters + ## Create Event filters ${event_filter_api_invoker_ids}= Create Capif Event Filter apiInvokerIds=${api_invoker_id_1} ${event_filter_api_ids}= Create Capif Event Filter apiIds=${service_api_id_1} ${event_filter_api_invoker_ids_and_api_ids}= Create Capif Event Filter ... apiInvokerIds=${api_invoker_id_2} ... apiIds=${service_api_id_2} - # Subscription to Events 1 + ## Subscription to Events 1 ${event_filters}= Create List ${event_filter_api_ids} ${subscription_id_1}= ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - # Subscription to Events 2 + ## Subscription to Events 2 ${event_filters}= Create List ${event_filter_api_invoker_ids} ${subscription_id_2}= ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - # Subscription to Events 3 + ## Subscription to Events 3 ${event_filters}= Create List ${event_filter_api_invoker_ids_and_api_ids} ${subscription_id_3}= ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - # Create Security Contexts and ACLs + ## Create Security Contexts and ACLs ${acl_provider_1}= ... Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1} ${acl_provider_1}= @@ -818,7 +590,8 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by aefId # Initialize Mock server Init Mock Server - # Register provider 1 + # Create Provider + ## Default Provider 1 Registration ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 ${aef_id_1}= Set Variable ... ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} @@ -831,43 +604,22 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by aefId ... ${register_user_info_provider_1} ... service_name=service_1 - # Store apiId1 and apiId2 + # Store apiId1 ${service_api_id_1}= Set Variable ${service_api_description_published_1['apiId']} # Subscribe to events + ## Event lists ${events_list}= Create List ACCESS_CONTROL_POLICY_UPDATE - # Event filters + ## Event filters ${event_filter_aef_id}= Create Capif Event Filter aefIds=${aef_id_1} - # Subscription to Events 1 + ## Subscription to Events 1 ${event_filters}= Create List ${event_filter_aef_id} - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 - ... event_filters=${event_filters} - ${resp}= Post Request Capif - ... /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions - ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${register_user_info_provider_1['amf_username']} + ${resp}= Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} - # Check Results - ${invalid_param}= Create Dictionary - ... param=eventFilter - ... reason=The eventFilter {'aef_ids'} for event ACCESS_CONTROL_POLICY_UPDATE are not applicable. - ${invalid_param_list}= Create List ${invalid_param} - Check Response Variable Type And Values - ... ${resp} - ... 400 - ... ProblemDetails - ... title=Bad Request - ... status=400 - ... detail=Bad Param - ... cause=Invalid eventFilter for event ACCESS_CONTROL_POLICY_UPDATE - ... invalidParams=${invalid_param_list} + ### Check Error Response + Check not valid ${resp} with event filter aef_ids for event ACCESS_CONTROL_POLICY_UPDATE Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION_FAILURE filtered by apiId, invokerId, aefId and all of them [Tags] event_filter-7 mockserver smoke @@ -875,12 +627,13 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION # Initialize Mock server Init Mock Server - # Register provider 1 + # Register Providers + ## Default Provider 1 Registration ${register_user_info_provider_1}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_1 ${aef_id_1}= Set Variable ... ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} - # Publish one api + ## Publish service_1 API ${service_api_description_published_1} ... ${provider_resource_url_1} ... ${provider_request_body_1}= @@ -888,12 +641,12 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION ... ${register_user_info_provider_1} ... service_name=service_1 - # Register APF + ## Default Provider 2 Registration ${register_user_info_provider_2}= Provider Default Registration provider_username=${PROVIDER_USERNAME}_2 ${aef_id_2}= Set Variable ... ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_2']['aef_id']} - # Publish one api + ## Publish service_2 API ${service_api_description_published_2} ... ${provider_resource_url_2} ... ${provider_request_body_2}= @@ -901,19 +654,21 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION ... ${register_user_info_provider_2} ... service_name=service_2 - # Store apiId1 and apiId2 + ## Store apiId1 and apiId2 for further use ${service_api_id_1}= Set Variable ${service_api_description_published_1['apiId']} - ${service_api_id_2}= Set Variable ${service_api_description_published_2['apiId']} - # Register INVOKER 1 + # Register Invokers + ## Default Invoker 1 Registration and Onboarding ${register_user_info_invoker_1} ${invoker_url_1} ${request_body_1}= Invoker Default Onboarding ... invoker_username=${INVOKER_USERNAME}_1 - ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} - # Register INVOKER 2 + ## Default Invoker 2 Registration and Onboarding ${register_user_info_invoker_2} ${invoker_url_2} ${request_body_2}= Invoker Default Onboarding ... invoke_username=${INVOKER_USERNAME}_2 + + ## Store apiInvokerIds for further use + ${api_invoker_id_1}= Set Variable ${register_user_info_invoker_1['api_invoker_id']} ${api_invoker_id_2}= Set Variable ${register_user_info_invoker_2['api_invoker_id']} # Subscribe to events @@ -940,51 +695,78 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION ... apiIds=${service_api_id_2} ## Subscription to Events 1 - ${event_filters}= Create List ${event_filter_api_ids} ${event_filter_api_ids} + ${event_filters}= Create List ${event_filter_api_ids} ${event_filter_api_ids} ${subscription_id_1}= ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - # ## Subscription to Events 2 - ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_aef_ids} + ## Subscription to Events 2 + ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_aef_ids} ${subscription_id_2}= ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} ## Subscription to Events 3 - ${event_filters}= Create List ${event_filter_api_invoker_ids} ${event_filter_api_invoker_ids} + ${event_filters}= Create List ${event_filter_api_invoker_ids} ${event_filter_api_invoker_ids} ${subscription_id_3}= ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - # ## Subscription to Events 4 - ${event_filters}= Create List ${event_filter_api_ids_and_aef_ids} ${event_filter_api_ids_and_aef_ids} + ## Subscription to Events 4 + ${event_filters}= Create List ${event_filter_api_ids_and_aef_ids} ${event_filter_api_ids_and_aef_ids} ${subscription_id_4}= ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - # ## Subscription to Events 5 - ${event_filters}= Create List ${event_filter_api_ids_and_api_invoker_ids} ${event_filter_api_ids_and_api_invoker_ids} + ## Subscription to Events 5 + ${event_filters}= Create List + ... ${event_filter_api_ids_and_api_invoker_ids} + ... ${event_filter_api_ids_and_api_invoker_ids} ${subscription_id_5}= ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - # ## Subscription to Events 6 - ${event_filters}= Create List ${event_filter_aef_ids_and_api_invoker_ids} ${event_filter_aef_ids_and_api_invoker_ids} + ## Subscription to Events 6 + ${event_filters}= Create List + ... ${event_filter_aef_ids_and_api_invoker_ids} + ... ${event_filter_aef_ids_and_api_invoker_ids} ${subscription_id_6}= ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} - # ## Subscription to Events 7 - ${event_filters}= Create List ${event_filter_api_ids_aef_ids_and_api_invoker_ids} ${event_filter_api_ids_aef_ids_and_api_invoker_ids} + ## Subscription to Events 7 + ${event_filters}= Create List + ... ${event_filter_api_ids_aef_ids_and_api_invoker_ids} + ... ${event_filter_api_ids_aef_ids_and_api_invoker_ids} ${subscription_id_7}= ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} # 1.Log entry for service_1 and invoker_1 - ${request_body_log_1}= Send Log Message to CAPIF ${service_api_id_1} service_1 ${register_user_info_invoker_1} ${register_user_info_provider_1} 200 400 + ${request_body_log_1}= Send Log Message to CAPIF + ... ${service_api_id_1} + ... service_1 + ... ${register_user_info_invoker_1} + ... ${register_user_info_provider_1} + ... 200 + ... 400 # 2.Log entry for service_2 and invoker_1 - ${request_body_log_2}= Send Log Message to CAPIF ${service_api_id_2} service_2 ${register_user_info_invoker_1} ${register_user_info_provider_2} 200 + ${request_body_log_2}= Send Log Message to CAPIF + ... ${service_api_id_2} + ... service_2 + ... ${register_user_info_invoker_1} + ... ${register_user_info_provider_2} + ... 200 # 3.Log entry for service_2 and invoker_2 - ${request_body_log_3}= Send Log Message to CAPIF ${service_api_id_2} service_2 ${register_user_info_invoker_2} ${register_user_info_provider_2} 200 + ${request_body_log_3}= Send Log Message to CAPIF + ... ${service_api_id_2} + ... service_2 + ... ${register_user_info_invoker_2} + ... ${register_user_info_provider_2} + ... 200 # 4.Log entry for service_1 and invoker_2 - ${request_body_log_4}= Send Log Message to CAPIF ${service_api_id_1} service_1 ${register_user_info_invoker_2} ${register_user_info_provider_1} 400 + ${request_body_log_4}= Send Log Message to CAPIF + ... ${service_api_id_1} + ... service_1 + ... ${register_user_info_invoker_2} + ... ${register_user_info_provider_1} + ... 400 # Check Event Notifications ## Create check Events to ensure all notifications were received @@ -1008,7 +790,7 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION ... ${subscription_id_2} ... ${request_body_log_3} ... events_expected=${events_expected} - + # Subscription 3 Checks ${events_expected}= Create Events From InvocationLogs ... ${subscription_id_3} @@ -1049,13 +831,11 @@ Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION ... ${request_body_log_3} ... events_expected=${events_expected} - Log List ${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 Security Context between ${invoker_info} and ${provider_info} # Discover APIs by invoker @@ -1093,17 +873,9 @@ Create Security Context between ${invoker_info} and ${provider_info} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${provider_info['aef_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']} - # ... ${invoker_info['api_invoker_id']} - ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} - # Append To List ${api_invoker_policies_list} ${api_invoker_policies} ${api_invoker_policies_list}= Set Variable ${api_invoker_policies} END @@ -1164,24 +936,40 @@ Update Security Context between ${invoker_info} and ${provider_info} RETURN ${api_invoker_policies_list} Subscribe provider ${provider_info} to events ${events_list} with event filters ${event_filters} + ${resp}= + ... Subscribe ${provider_info['amf_id']} with ${provider_info['amf_username']} to ${events_list} with ${event_filters} + + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + + RETURN ${subscription_id} + +Subscribe invoker ${invoker_info} to events ${events_list} with event filters ${event_filters} + ${resp}= + ... Subscribe ${invoker_info['api_invoker_id']} with ${invoker_info['management_cert']} to ${events_list} with ${event_filters} + + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + + RETURN ${subscription_id} + +Subscribe ${subscriber_id} with ${username} to ${events_list} with ${event_filters} ${request_body}= Create Events Subscription ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 + ... supported_features=C ... event_filters=${event_filters} ${resp}= Post Request Capif - ... /capif-events/v1/${provider_info['amf_id']}/subscriptions + ... /capif-events/v1/${subscriber_id}/subscriptions ... json=${request_body} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt - ... username=${provider_info['amf_username']} + ... username=${username} - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + RETURN ${resp} - RETURN ${subscription_id} Send Log Message to CAPIF - [Arguments] ${api_id} ${service_name} ${invoker_info} ${provider_info} @{results} + [Arguments] ${api_id} ${service_name} ${invoker_info} ${provider_info} @{results} ${api_ids}= Create List ${api_id} ${api_names}= Create List ${service_name} ${request_body}= Create Log Entry @@ -1201,3 +989,19 @@ Send Log Message to CAPIF ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} RETURN ${request_body} + +Check not valid ${resp} with event filter ${attribute_snake_case} for event ${event} + # Check Results + ${invalid_param}= Create Dictionary + ... param=eventFilter + ... reason=The eventFilter {'${attribute_snake_case}'} for event ${event} are not applicable. + ${invalid_param_list}= Create List ${invalid_param} + Check Response Variable Type And Values + ... ${resp} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=Bad Param + ... cause=Invalid eventFilter for event ${event} + ... invalidParams=${invalid_param_list} -- GitLab From 5bbbb14cb4a1b0314f675b858b974e5e1f84d779 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 6 Mar 2025 11:40:27 +0100 Subject: [PATCH 12/12] Move smoke from event_filter-6 to event_filter-2 --- .../features/Event Filter/event_filter.robot | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/tests/features/Event Filter/event_filter.robot b/tests/features/Event Filter/event_filter.robot index b6718ce2..0ecee3be 100644 --- a/tests/features/Event Filter/event_filter.robot +++ b/tests/features/Event Filter/event_filter.robot @@ -148,7 +148,7 @@ Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE_API_UPDATE events filtered by not valid filters - [Tags] event_filter-2 + [Tags] event_filter-2 smoke # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding @@ -156,7 +156,8 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE # Create Provider1 with 2 AEF roles and publish API ${register_user_info_provider_1}= Provider Default Registration total_aef_roles=2 ${aef_id_1}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} - ${aef_id_2}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + ${aef_id_2}= Set Variable + ... ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} ${aef_empty_list}= Create List @@ -242,7 +243,6 @@ Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE ### Check Error Response Check not valid ${resp} with event filter api_invoker_ids for event SERVICE_API_UPDATE - Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INVOKER_UPDATED events filtered by invokerIds [Tags] event_filter-3 mockserver @@ -253,7 +253,8 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ## Create Provider with 2 AEF roles ${register_user_info_provider_1}= Provider Default Registration total_aef_roles=2 ${aef_id_1}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} - ${aef_id_2}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + ${aef_id_2}= Set Variable + ... ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} ${aef_empty_list}= Create List @@ -272,7 +273,8 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ${event_filter}= Create Capif Event Filter ## Subscribe API_INVOKER_ONBOARDED event without filters ${event_filters}= Create List ${event_filter} - ${subscription_id_1}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + ${subscription_id_1}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} # Default Invokers Registration and Onboarding # Default Invoker 1 Registration and Onboarding @@ -298,7 +300,8 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ... ${event_filter_empty} ... ${event_filter_invoker_id_1} ... ${event_filter_invoker_id_2} - ${subscription_id_2}= Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} + ${subscription_id_2}= + ... Subscribe provider ${register_user_info_provider_1} to events ${events_list} with event filters ${event_filters} # Update Invokers ## Update Invoker 1 @@ -379,7 +382,8 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ${register_user_info_provider_1}= Provider Default Registration total_aef_roles=2 ${aef_id_1}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']} - ${aef_id_2}= Set Variable ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} + ${aef_id_2}= Set Variable + ... ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']} ${aef_ids}= Create List ${aef_id_1} ${aef_id_2} ${aef_empty_list}= Create List @@ -410,28 +414,32 @@ Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INV ## Event subscription with event filters by aef_ids ${event_filters}= Create List ${event_filter_aef_ids} ${event_filter_empty} ${event_filter_empty} - ${resp}= Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} + ${resp}= + ... Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} ### Check Results Check not valid ${resp} with event filter aef_ids for event API_INVOKER_ONBOARDED ## Event subcription API_INVOKER_OFFBOARDED filtered by aef_ids ${event_filters}= Create List ${event_filter_empty} ${event_filter_aef_ids} ${event_filter_empty} - ${resp}= Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} + ${resp}= + ... Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} ### Check Results Check not valid ${resp} with event filter aef_ids for event API_INVOKER_OFFBOARDED ## Event subcription API_INVOKER_UPDATED filtered by aef_ids ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_aef_ids} - ${resp}= Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} + ${resp}= + ... Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} ### Check Results Check not valid ${resp} with event filter aef_ids for event API_INVOKER_UPDATED ## Event subcription API_INVOKER_UPDATED filtered by api_ids ${event_filters}= Create List ${event_filter_empty} ${event_filter_empty} ${event_filter_api_ids} - ${resp}= Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} + ${resp}= + ... Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} ### Check Results Check not valid ${resp} with event filter api_ids for event API_INVOKER_UPDATED @@ -585,7 +593,7 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by aefId - [Tags] event_filter-6 smoke + [Tags] event_filter-6 # Initialize Mock server Init Mock Server @@ -616,7 +624,8 @@ Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by aefId ## Subscription to Events 1 ${event_filters}= Create List ${event_filter_aef_id} - ${resp}= Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} + ${resp}= + ... Subscribe ${register_user_info_provider_1['amf_id']} with ${register_user_info_provider_1['amf_username']} to ${events_list} with ${event_filters} ### Check Error Response Check not valid ${resp} with event filter aef_ids for event ACCESS_CONTROL_POLICY_UPDATE @@ -922,10 +931,6 @@ Update Security Context between ${invoker_info} and ${provider_info} 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']} - # ... ${invoker_info['api_invoker_id']} ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} # Append To List ${api_invoker_policies_list} ${api_invoker_policies} -- GitLab