From 85d3e1af08b2d94bbd6ebf3e9c3611294bc2e8f4 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Mon, 2 Dec 2024 16:01:50 +0100 Subject: [PATCH 1/9] New test and changes on libraries parameter names --- .../CAPIF Api Events/capif_events_api.robot | 46 ++++++++++++++----- tests/libraries/api_events/bodyRequests.py | 24 +++++----- 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index ce01444..3b52365 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -171,8 +171,8 @@ Invoker receives Service API Invocation events ${request_body}= Create Events Subscription ... events=@{events_list} - ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing - ... eventFilters=${event_filters} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... event_filters=${event_filters} ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} @@ -243,8 +243,8 @@ Invoker subscribe to Service API Available and Unavailable events ${request_body}= Create Events Subscription ... events=@{events_list} - ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing - ... eventFilters=${event_filters} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... event_filters=${event_filters} ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} @@ -313,8 +313,8 @@ Invoker subscribe to Service API Update ${request_body}= Create Events Subscription ... events=@{events_list} - ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing - ... eventFilters=${event_filters} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... event_filters=${event_filters} ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} @@ -357,7 +357,7 @@ Provider subscribe to API Invoker events ${events_list}= Create List API_INVOKER_ONBOARDED API_INVOKER_UPDATED API_INVOKER_OFFBOARDED ${request_body}= Create Events Subscription ... events=@{events_list} - ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -377,7 +377,7 @@ Provider subscribe to API Invoker events ... http://${CAPIF_CALLBACK_IP}:${CAPIF_CALLBACK_PORT}/netapp_new_callback Set To Dictionary ... ${request_body} - ... notificationDestination=${new_notification_destination} + ... notification_destination=${new_notification_destination} ${resp}= Put Request Capif ... ${url.path} ... ${request_body} @@ -387,7 +387,7 @@ Provider subscribe to API Invoker events # Check Update Check Response Variable Type And Values ${resp} 200 APIInvokerEnrolmentDetails - ... notificationDestination=${new_notification_destination} + ... notification_destination=${new_notification_destination} # Remove Invoker from CCF ${resp}= Delete Request Capif @@ -432,7 +432,7 @@ Invoker subscribed to ACL update event ${events_list}= Create List ACCESS_CONTROL_POLICY_UPDATE ${request_body}= Create Events Subscription ... events=@{events_list} - ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -516,7 +516,7 @@ Provider receives an ACL unavailable event when invoker remove Security Context. ${events_list}= Create List ACCESS_CONTROL_POLICY_UNAVAILABLE ${request_body}= Create Events Subscription ... events=@{events_list} - ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -590,7 +590,7 @@ Invoker receives an Invoker Authorization Revoked and ACL unavailable event when ${events_list}= Create List ACCESS_CONTROL_POLICY_UNAVAILABLE API_INVOKER_AUTHORIZATION_REVOKED ${request_body}= Create Events Subscription ... events=@{events_list} - ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -651,6 +651,28 @@ Invoker receives an Invoker Authorization Revoked and ACL unavailable event when ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} +Creates a new individual CAPIF Event Subscription without supported features attribute + [Tags] capif_api_events-13 smoke + # Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + ${request_body}= Create Events Subscription supported_features=${NONE} + ${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} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=supportedFeatures not present in request + ... cause=supportedFeatures not present *** Keywords *** Create Events From InvocationLogs diff --git a/tests/libraries/api_events/bodyRequests.py b/tests/libraries/api_events/bodyRequests.py index 17fd1b5..20d82a4 100644 --- a/tests/libraries/api_events/bodyRequests.py +++ b/tests/libraries/api_events/bodyRequests.py @@ -1,18 +1,18 @@ -def create_events_subscription(events=["SERVICE_API_AVAILABLE", "API_INVOKER_ONBOARDED"], notificationDestination="http://robot.testing", eventFilters=None, eventReq=None, requestTestNotification=None, supportedFeatures=None, websockNotifConfig=None): +def create_events_subscription(events=["SERVICE_API_AVAILABLE", "API_INVOKER_ONBOARDED"], notification_destination="http://robot.testing", event_filters=None, event_req=None, request_test_notification=None, supported_features="0", websock_notif_config=None): event_subscription = { "events": events, - "notificationDestination": notificationDestination, + "notificationDestination": notification_destination, } - if eventFilters != None: - event_subscription['eventFilters'] = eventFilters - if eventReq != None: - event_subscription['eventReq'] = eventReq - if requestTestNotification != None: - event_subscription['requestTestNotification'] = requestTestNotification - if supportedFeatures != None: - event_subscription['supportedFeatures'] = supportedFeatures - if websockNotifConfig != None: - event_subscription['websockNotifConfig'] = websockNotifConfig + if event_filters != None: + event_subscription['eventFilters'] = event_filters + if event_req != None: + event_subscription['eventReq'] = event_req + if request_test_notification != None: + event_subscription['requestTestNotification'] = request_test_notification + if supported_features != None: + event_subscription['supportedFeatures'] = supported_features + if websock_notif_config != None: + event_subscription['websockNotifConfig'] = websock_notif_config return event_subscription -- GitLab From 9cfbccc6f898b50e712325d28ea4cd7585e16cb9 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Mon, 2 Dec 2024 16:32:45 +0100 Subject: [PATCH 2/9] Fixed events test suite with enhanced feature --- tests/features/CAPIF Api Events/capif_events_api.robot | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index 3b52365..18a9758 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -173,6 +173,7 @@ Invoker receives Service API Invocation events ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing ... event_filters=${event_filters} + ... supported_features=4 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} @@ -245,6 +246,7 @@ Invoker subscribe to Service API Available and Unavailable events ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing ... event_filters=${event_filters} + ... supported_features=4 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} @@ -315,6 +317,7 @@ Invoker subscribe to Service API Update ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing ... event_filters=${event_filters} + ... supported_features=4 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions ... json=${request_body} @@ -358,6 +361,7 @@ Provider subscribe to API Invoker events ${request_body}= Create Events Subscription ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -377,7 +381,7 @@ Provider subscribe to API Invoker events ... http://${CAPIF_CALLBACK_IP}:${CAPIF_CALLBACK_PORT}/netapp_new_callback Set To Dictionary ... ${request_body} - ... notification_destination=${new_notification_destination} + ... notificationDestination=${new_notification_destination} ${resp}= Put Request Capif ... ${url.path} ... ${request_body} @@ -387,7 +391,7 @@ Provider subscribe to API Invoker events # Check Update Check Response Variable Type And Values ${resp} 200 APIInvokerEnrolmentDetails - ... notification_destination=${new_notification_destination} + ... notificationDestination=${new_notification_destination} # Remove Invoker from CCF ${resp}= Delete Request Capif @@ -433,6 +437,7 @@ Invoker subscribed to ACL update event ${request_body}= Create Events Subscription ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -517,6 +522,7 @@ Provider receives an ACL unavailable event when invoker remove Security Context. ${request_body}= Create Events Subscription ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} -- GitLab From c0a0c706a4bb2c3a6019cd242630a1b95fe350ac Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Wed, 4 Dec 2024 10:32:23 +0100 Subject: [PATCH 3/9] Added new test Suite --- tests/features/Api Status/__init__.robot | 2 + tests/features/Api Status/api_status.robot | 286 ++++++++ .../CAPIF Api Events/capif_events_api.robot | 691 ++++++++++++++++-- 3 files changed, 925 insertions(+), 54 deletions(-) create mode 100644 tests/features/Api Status/__init__.robot create mode 100644 tests/features/Api Status/api_status.robot diff --git a/tests/features/Api Status/__init__.robot b/tests/features/Api Status/__init__.robot new file mode 100644 index 0000000..9ac8f7a --- /dev/null +++ b/tests/features/Api Status/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Force Tags api_status \ No newline at end of file diff --git a/tests/features/Api Status/api_status.robot b/tests/features/Api Status/api_status.robot new file mode 100644 index 0000000..fd67ace --- /dev/null +++ b/tests/features/Api Status/api_status.robot @@ -0,0 +1,286 @@ +*** Settings *** +Resource /opt/robot-tests/tests/resources/common.resource +Library /opt/robot-tests/tests/libraries/bodyRequests.py +Library XML +Library String +Resource /opt/robot-tests/tests/resources/common/basicRequests.robot +Resource ../../resources/common.resource + +Suite Teardown Reset Testing Environment +Test Setup Reset Testing Environment +Test Teardown Reset Testing Environment + + +*** Variables *** +${API_INVOKER_NOT_REGISTERED} not-valid +${SUBSCRIBER_ID_NOT_VALID} not-valid +${SUBSCRIPTION_ID_NOT_VALID} not-valid + + +*** Test Cases *** +Invoker receives Service API Invocation events + [Tags] api_status-1 mockserver smoke + + # Initialize Mock server + Init Mock Server + + # Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Register APF + ${register_user_info_provider}= Provider Default Registration + + ${aef_id}= Set Variable ${register_user_info_provider['aef_id']} + + # Subscribe to events + ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE + ${aef_ids}= Create List ${register_user_info_provider['aef_id']} + ${event_filter}= Create Capif Event Filter aefIds=${aef_ids} + ${event_filters}= Create List ${event_filter} + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... event_filters=${event_filters} + ... supported_features=4 + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + # Check Results + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + ... service_1 + + # Provider Remove service_1 published API + ${resp}= Delete Request Capif + ... ${resource_url.path} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${APF_PROVIDER_USERNAME} + + Status Should Be 204 ${resp} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${service_api_available_resources}= Create List ${resource_url} + ${service_api_unavailable_resources}= Create List ${resource_url} + ${events_expected}= Create Expected Events For Service API Notifications + ... subscription_id=${subscription_id} + ... service_api_available_resources=${service_api_available_resources} + ... service_api_unavailable_resources=${service_api_unavailable_resources} + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + + + +*** Keywords *** +Create Events From InvocationLogs + [Arguments] + ... ${subscription_id} + ... ${invocation_log} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + + # Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present. + ${invocation_log_base}= Copy Dictionary ${invocation_log} deepcopy=True + # Store log array because each log will be notified in one Event Notification + ${invocation_log_logs}= Copy List ${invocation_log_base['logs']} + # Remove logs array from invocationLog data + Remove From Dictionary ${invocation_log_base} logs + + FOR ${log} IN @{invocation_log_logs} + Log Dictionary ${log} + ${invocation_logs}= Copy Dictionary ${invocation_log_base} deepcopy=True + + # Get Event Enum for this result + ${event_enum}= Set Variable + IF ${log['result']} >= 200 and ${log['result']} < 300 + ${event_enum}= Set Variable SERVICE_API_INVOCATION_SUCCESS + ELSE + ${event_enum}= Set Variable SERVICE_API_INVOCATION_FAILURE + END + # Create a log array with only one component + ${log_list}= Create List ${log} + # Setup logs array with previously created list + Set To Dictionary ${invocation_logs} logs=${log_list} + IF "${event_detail_expected}" != "${TRUE}" + ${invocation_logs}= Set Variable ${NONE} + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... ${event_enum} + ... invocationLogs=${invocation_logs} + Append To List ${events_expected} ${event_expected} + END + + RETURN ${events_expected} + +Create Expected Events For Service API Notifications + [Arguments] + ... ${subscription_id} + ... ${service_api_available_resources}=${NONE} + ... ${service_api_unavailable_resources}=${NONE} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + IF "${service_api_available_resources}" != "${NONE}" + FOR ${service_api_available_resource} IN @{service_api_available_resources} + Log ${service_api_available_resource} + ${api_id}= Fetch From Right ${service_api_available_resource.path} / + + IF "${event_detail_expected}" != "${TRUE}" + ${api_id}= Set Variable ${NONE} + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... SERVICE_API_AVAILABLE + ... apiIds=${api_id} + Append To List ${events_expected} ${event_expected} + END + END + + IF "${service_api_unavailable_resources}" != "${NONE}" + FOR ${service_api_unavailable_resource} IN @{service_api_unavailable_resources} + Log ${service_api_unavailable_resource} + ${api_id}= Fetch From Right ${service_api_unavailable_resource.path} / + IF "${event_detail_expected}" != "${TRUE}" + ${api_id}= Set Variable ${NONE} + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... SERVICE_API_UNAVAILABLE + ... apiIds=${api_id} + Append To List ${events_expected} ${event_expected} + END + END + + RETURN ${events_expected} + +Create Expected Api Invoker Events + [Arguments] + ... ${subscription_id} + ... ${api_invoker_id} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + + ${api_invoker_id_used}= Set Variable ${api_invoker_id} + IF "${event_detail_expected}" != "${TRUE}" + ${api_invoker_id_used}= Set Variable ${NONE} + END + ## Create events expected + # Create Notification Events expected to be received for Onboard event + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_ONBOARDED + ... apiInvokerIds=${api_invoker_id_used} + Append To List ${events_expected} ${event_expected} + + # Create Notification Events expected to be received for Updated event + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_UPDATED + ... apiInvokerIds=${api_invoker_id_used} + Append To List ${events_expected} ${event_expected} + + # Create Notification Events expected to be received for Offboard event + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_OFFBOARDED + ... apiInvokerIds=${api_invoker_id_used} + Append To List ${events_expected} ${event_expected} + + RETURN ${events_expected} + +Create Expected Access Control Policy Update Event + [Arguments] + ... ${subscription_id} + ... ${service_api_id} + ... ${api_invoker_policies} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + ${acc_ctrl_pol_list}= Create Dictionary apiId=${service_api_id} apiInvokerPolicies=${api_invoker_policies} + Check Variable ${acc_ctrl_pol_list} AccessControlPolicyListExt + + IF "${event_detail_expected}" != "${TRUE}" + ${acc_ctrl_pol_list}= Set Variable ${NONE} + END + + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... ACCESS_CONTROL_POLICY_UPDATE + ... accCtrlPolList=${acc_ctrl_pol_list} + Append To List ${events_expected} ${event_expected} + + RETURN ${events_expected} + +Create Expected Access Control Policy Unavailable + [Arguments] ${subscription_id} + ... ${events_expected}=${NONE} + + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... ACCESS_CONTROL_POLICY_UNAVAILABLE + Append To List ${events_expected} ${event_expected} + + RETURN ${events_expected} + +Create Expected Api Invoker Authorization Revoked + [Arguments] ${subscription_id} ${events_expected}=${NONE} + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_AUTHORIZATION_REVOKED + Append To List ${events_expected} ${event_expected} + RETURN ${events_expected} + +Create Expected Service Update Event + [Arguments] + ... ${subscription_id} + ... ${service_api_resource} + ... ${service_api_descriptions} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + ${api_id}= Fetch From Right ${service_api_resource.path} / + Set To Dictionary ${service_api_descriptions} apiId=${api_id} + + IF "${event_detail_expected}" != "${TRUE}" + ${service_api_descriptions}= Set Variable ${NONE} + END + ${events_expected}= Create List + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... SERVICE_API_UPDATE + ... serviceAPIDescriptions=${service_api_descriptions} + Append To List ${events_expected} ${event_expected} + RETURN ${events_expected} diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index 18a9758..9e5795f 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -19,7 +19,7 @@ ${SUBSCRIPTION_ID_NOT_VALID} not-valid *** Test Cases *** Creates a new individual CAPIF Event Subscription - [Tags] capif_api_events-1 smoke + [Tags] capif_api_events-1 smoke # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding @@ -141,7 +141,7 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriptionId ... cause=You are not the owner of this resource Invoker receives Service API Invocation events - [Tags] capif_api_events-6 mockserver smoke + [Tags] capif_api_events-6 mockserver smoke # Initialize Mock server Init Mock Server @@ -210,7 +210,7 @@ Invoker receives Service API Invocation events ... ${subscription_id} ... ${request_body} ## 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} Invoker subscribe to Service API Available and Unavailable events [Tags] capif_api_events-7 mockserver @@ -281,7 +281,7 @@ Invoker subscribe to Service API Available and Unavailable events ... service_api_available_resources=${service_api_available_resources} ... service_api_unavailable_resources=${service_api_unavailable_resources} ## Check Events Expected towards received notifications at mock server - Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} Invoker subscribe to Service API Update [Tags] capif_api_events-8 mockserver @@ -343,12 +343,562 @@ Invoker subscribe to Service API Update # Check Event Notifications ## Create check Events to ensure all notifications were received - ${events_expected}= Create Expected Service Update Event ${subscription_id} ${resource_url} ${service_api_description_modified} + ${events_expected}= Create Expected Service Update Event + ... ${subscription_id} + ... ${resource_url} + ... ${service_api_description_modified} + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + +Provider subscribe to API Invoker events + [Tags] capif_api_events-9 mockserver + + # Initialize Mock server + Init Mock Server + + # Register APF + ${register_user_info_provider}= Provider Default Registration + + # Subscribe to events + ${events_list}= Create List API_INVOKER_ONBOARDED API_INVOKER_UPDATED API_INVOKER_OFFBOARDED + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ${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} + + # Register INVOKER + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Update Invoker onboarded information + ${new_notification_destination}= Set Variable + ... http://${CAPIF_CALLBACK_IP}:${CAPIF_CALLBACK_PORT}/netapp_new_callback + Set To Dictionary + ... ${request_body} + ... notificationDestination=${new_notification_destination} + ${resp}= Put Request Capif + ... ${url.path} + ... ${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + # Check Update + Check Response Variable Type And Values ${resp} 200 APIInvokerEnrolmentDetails + ... notificationDestination=${new_notification_destination} + + # Remove Invoker from CCF + ${resp}= Delete Request Capif + ... ${url.path} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Call Method ${CAPIF_USERS} remove_capif_users_entry ${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 + ${events_expected}= Create Expected Api Invoker Events + ... ${subscription_id} + ... ${register_user_info_invoker['api_invoker_id']} + ## 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 ACL update event + [Tags] capif_api_events-10 mockserver smoke + + # Initialize Mock server + Init Mock Server + + # Register APF + ${register_user_info_provider}= Provider Default Registration + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + + # Store apiId1 + ${service_api_id}= Set Variable ${service_api_description_published['apiId']} + + # Register INVOKER + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Subscribe to events + ${events_list}= Create List ACCESS_CONTROL_POLICY_UPDATE + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ${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} + + # Test + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs + + # create Security Context + ${request_service_security_body}= Create Service Security From Discover Response + ... http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/test + ... ${discover_response} + ${resp}= Put Request Capif + ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} + ... json=${request_service_security_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + # Check Service Security + Check Response Variable Type And Values ${resp} 201 ServiceSecurity + ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} + + ${resp}= Get Request Capif + ... /access-control-policy/v1/accessControlPolicyList/${service_api_id}?aef-id=${register_user_info_provider['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${AEF_PROVIDER_USERNAME} + + Check Response Variable Type And Values ${resp} 200 AccessControlPolicyList + # Check returned values + Should Not Be Empty ${resp.json()['apiInvokerPolicies']} + Length Should Be ${resp.json()['apiInvokerPolicies']} 1 + Should Be Equal As Strings + ... ${resp.json()['apiInvokerPolicies'][0]['apiInvokerId']} + ... ${register_user_info_invoker['api_invoker_id']} + + ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${events_expected}= Create Expected Access Control Policy Update Event + ... ${subscription_id} + ... ${service_api_id} + ... ${api_invoker_policies} + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + +Provider receives an ACL unavailable event when invoker remove Security Context. + [Tags] capif_api_events-11 mockserver + + # Initialize Mock server + Init Mock Server + + # Register APF + ${register_user_info_provider}= Provider Default Registration + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + + # Store apiId1 + ${serviceApiId}= Set Variable ${service_api_description_published['apiId']} + + # Register INVOKER + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Subscribe to events + ${events_list}= Create List ACCESS_CONTROL_POLICY_UNAVAILABLE + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + # Check Results + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + + # Test + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs + + # create Security Context + ${request_service_security_body}= Create Service Security From Discover Response + ... http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/test + ... ${discover_response} + ${resp}= Put Request Capif + ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} + ... json=${request_service_security_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + # Check Service Security + Check Response Variable Type And Values ${resp} 201 ServiceSecurity + ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} + + # Remove Security Context by Provider + ${resp}= Delete Request Capif + ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${AEF_PROVIDER_USERNAME} + + Status Should Be 204 ${resp} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${events_expected}= Create Expected Access Control Policy Unavailable ${subscription_id} + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + +Invoker receives an Invoker Authorization Revoked and ACL unavailable event when Provider revoke Invoker Authorization. + [Tags] capif_api_events-12 mockserver smoke + + # Initialize Mock server + Init Mock Server + + # Register APF + ${register_user_info_provider}= Provider Default Registration + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + + # Store apiId1 + ${serviceApiId}= Set Variable ${service_api_description_published['apiId']} + + # Register INVOKER + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Subscribe to events + ${events_list}= Create List ACCESS_CONTROL_POLICY_UNAVAILABLE API_INVOKER_AUTHORIZATION_REVOKED + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + # Check Results + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + + # Test + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${register_user_info_provider['aef_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + Check Response Variable Type And Values ${discover_response} 200 DiscoveredAPIs + + ${api_ids}= Get Api Ids From Discover Response ${discover_response} + + # create Security Context + ${request_service_security_body}= Create Service Security From Discover Response + ... http://${CAPIF_HOSTNAME}:${CAPIF_HTTP_PORT}/test + ... ${discover_response} + ${resp}= Put Request Capif + ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} + ... json=${request_service_security_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + # Check Service Security + Check Response Variable Type And Values ${resp} 201 ServiceSecurity + ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} + + # Revoke Security Context by Provider + ${request_body}= Create Security Notification Body + ... ${register_user_info_invoker['api_invoker_id']} + ... ${api_ids} + ${resp}= Post Request Capif + ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']}/delete + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${AEF_PROVIDER_USERNAME} + + # Check Results + Status Should Be 204 ${resp} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${events_expected}= Create Expected Access Control Policy Unavailable ${subscription_id} + ${events_expected}= Create Expected Api Invoker Authorization Revoked + ... ${subscription_id} + ... events_expected=${events_expected} + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + +Creates a new individual CAPIF Event Subscription without supported features attribute + [Tags] capif_api_events-13 smoke + # Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + ${request_body}= Create Events Subscription supported_features=${NONE} + ${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} + ... 400 + ... ProblemDetails + ... title=Bad Request + ... status=400 + ... detail=supportedFeatures not present in request + ... cause=supportedFeatures not present + +Invoker receives Service API Invocation events without Enhanced Event Report + [Tags] capif_api_events-14 mockserver smoke + + # Initialize Mock server + Init Mock Server + + # Register APF + ${register_user_info}= Provider Default Registration + + # Publish one api + Publish Service Api ${register_user_info} + + # Register INVOKER + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + ${api_ids} ${api_names}= Get Api Ids And Names From Discover Response ${discover_response} + + # Subscribe to 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} + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... event_filters=${event_filters} + ... supported_features=0 + ${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} + + # Create Log Entry, emulate success and failure api invocation + ${results}= Create List 200 400 + ${request_body}= Create Log Entry + ... ${register_user_info['aef_id']} + ... ${register_user_info_invoker['api_invoker_id']} + ... ${api_ids} + ... ${api_names} + ... results=${results} + ${resp}= Post Request Capif + ... /api-invocation-logs/v1/${register_user_info['aef_id']}/logs + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${AEF_PROVIDER_USERNAME} + + # Check Results + Check Response Variable Type And Values ${resp} 201 InvocationLog + ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${events_expected}= Create Events From InvocationLogs + ... ${subscription_id} + ... ${request_body} + ... 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} + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} -Provider subscribe to API Invoker events - [Tags] capif_api_events-9 mockserver +Invoker subscribe to Service API Available and Unavailable events without Enhanced Event Report + [Tags] capif_api_events-15 mockserver + + # Initialize Mock server + Init Mock Server + + # Register APF + ${register_user_info_provider}= Provider Default Registration + + # Publish one api + ${service_api_description_published_1} ${resource_url_1} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + + # Register INVOKER + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + ${api_ids} ${api_names}= Get Api Ids And Names From Discover Response ${discover_response} + + # Subscribe to events + ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE + ${aef_ids}= Create List ${register_user_info_provider['aef_id']} + ${event_filter}= Create Capif Event Filter aefIds=${aef_ids} + ${event_filters}= Create List ${event_filter} + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... event_filters=${event_filters} + ... supported_features=0 + ${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} + + # Provider publish new API + ${service_api_description_published_2} ${resource_url_2} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + ... service_2 + + # Provider Remove service_1 published API + ${resp}= Delete Request Capif + ... ${resource_url_1.path} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${APF_PROVIDER_USERNAME} + + Status Should Be 204 ${resp} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${service_api_available_resources}= Create List ${resource_url_2} + ${service_api_unavailable_resources}= Create List ${resource_url_1} + ${events_expected}= Create Expected Events For Service API Notifications + ... subscription_id=${subscription_id} + ... service_api_available_resources=${service_api_available_resources} + ... service_api_unavailable_resources=${service_api_unavailable_resources} + ... 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} + +Invoker subscribe to Service API Update without Enhanced Event Report + [Tags] capif_api_events-16 mockserver + + # Initialize Mock server + Init Mock Server + + # Register APF + ${register_user_info_provider}= Provider Default Registration + + # Publish one api + ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api + ... ${register_user_info_provider} + + # Register INVOKER + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + ${discover_response}= Get Request Capif + ... ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + ${api_ids} ${api_names}= Get Api Ids And Names From Discover Response ${discover_response} + + # Subscribe to events + ${events_list}= Create List SERVICE_API_UPDATE + ${aef_ids}= Create List ${register_user_info_provider['aef_id']} + ${event_filter}= Create Capif Event Filter aefIds=${aef_ids} + ${event_filters}= Create List ${event_filter} + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... event_filters=${event_filters} + ... supported_features=0 + ${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 Service API + ${service_api_description_modified}= Create Service Api Description service_1_modified + ${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_modified + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${events_expected}= Create Expected Service Update Event + ... ${subscription_id} + ... ${resource_url} + ... ${service_api_description_modified} + ... 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} + +Provider subscribe to API Invoker events without Enhanced Event Report + [Tags] capif_api_events-17 mockserver # Initialize Mock server Init Mock Server @@ -361,7 +911,7 @@ Provider subscribe to API Invoker events ${request_body}= Create Events Subscription ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 + ... supported_features=0 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -410,11 +960,12 @@ Provider subscribe to API Invoker events ${events_expected}= Create Expected Api Invoker Events ... ${subscription_id} ... ${register_user_info_invoker['api_invoker_id']} + ... 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} + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} -Invoker subscribed to ACL update event - [Tags] capif_api_events-10 mockserver smoke +Invoker subscribed to ACL update event without Enhanced Event Report + [Tags] capif_api_events-18 mockserver # Initialize Mock server Init Mock Server @@ -437,7 +988,7 @@ Invoker subscribed to ACL update event ${request_body}= Create Events Subscription ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 + ... supported_features=0 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -495,11 +1046,12 @@ Invoker subscribed to ACL update event ... ${subscription_id} ... ${service_api_id} ... ${api_invoker_policies} + ... 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} + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} -Provider receives an ACL unavailable event when invoker remove Security Context. - [Tags] capif_api_events-11 mockserver +Provider receives an ACL unavailable event when invoker remove Security Context without Enhanced Event Report + [Tags] capif_api_events-19 mockserver # Initialize Mock server Init Mock Server @@ -522,7 +1074,7 @@ Provider receives an ACL unavailable event when invoker remove Security Context. ${request_body}= Create Events Subscription ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... supported_features=4 + ... supported_features=0 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -569,12 +1121,13 @@ Provider receives an ACL unavailable event when invoker remove Security Context. # Check Event Notifications ## Create check Events to ensure all notifications were received - ${events_expected}= Create Expected Access Control Policy Unavailable ${subscription_id} + ${events_expected}= Create Expected Access Control Policy Unavailable + ... ${subscription_id} ## Check Events Expected towards received notifications at mock server - Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} -Invoker receives an Invoker Authorization Revoked and ACL unavailable event when Provider revoke Invoker Authorization. - [Tags] capif_api_events-12 mockserver smoke +Invoker receives an Invoker Authorization Revoked and ACL unavailable event when Provider revoke Invoker Authorization without Enhanced Event Report + [Tags] capif_api_events-20 mockserver # Initialize Mock server Init Mock Server @@ -597,6 +1150,7 @@ Invoker receives an Invoker Authorization Revoked and ACL unavailable event when ${request_body}= Create Events Subscription ... events=@{events_list} ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=0 ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -655,34 +1209,16 @@ Invoker receives an Invoker Authorization Revoked and ACL unavailable event when ... ${subscription_id} ... events_expected=${events_expected} ## Check Events Expected towards received notifications at mock server - Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} - -Creates a new individual CAPIF Event Subscription without supported features attribute - [Tags] capif_api_events-13 smoke - # Default Invoker Registration and Onboarding - ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - - ${request_body}= Create Events Subscription supported_features=${NONE} - ${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} + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} - # Check Results - Check Response Variable Type And Values - ... ${resp} - ... 400 - ... ProblemDetails - ... title=Bad Request - ... status=400 - ... detail=supportedFeatures not present in request - ... cause=supportedFeatures not present *** Keywords *** Create Events From InvocationLogs - [Arguments] ${subscription_id} ${invocation_log} ${events_expected}=${NONE} + [Arguments] + ... ${subscription_id} + ... ${invocation_log} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} IF ${events_expected} == ${NONE} ${events_expected}= Create List END @@ -709,17 +1245,25 @@ Create Events From InvocationLogs ${log_list}= Create List ${log} # Setup logs array with previously created list Set To Dictionary ${invocation_logs} logs=${log_list} - ${event_expected}= Create Notification Event ${subscription_id} ${event_enum} invocationLogs=${invocation_logs} + IF "${event_detail_expected}" != "${TRUE}" + ${invocation_logs}= Set Variable ${NONE} + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... ${event_enum} + ... invocationLogs=${invocation_logs} Append To List ${events_expected} ${event_expected} END RETURN ${events_expected} + Create Expected Events For Service API Notifications [Arguments] ... ${subscription_id} ... ${service_api_available_resources}=${NONE} ... ${service_api_unavailable_resources}=${NONE} ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} IF ${events_expected} == ${NONE} ${events_expected}= Create List @@ -728,6 +1272,10 @@ Create Expected Events For Service API Notifications FOR ${service_api_available_resource} IN @{service_api_available_resources} Log ${service_api_available_resource} ${api_id}= Fetch From Right ${service_api_available_resource.path} / + + IF "${event_detail_expected}" != "${TRUE}" + ${api_id}= Set Variable ${NONE} + END ${event_expected}= Create Notification Event ... ${subscription_id} ... SERVICE_API_AVAILABLE @@ -738,6 +1286,9 @@ Create Expected Events For Service API Notifications FOR ${service_api_unavailable_resource} IN @{service_api_unavailable_resources} Log ${service_api_unavailable_resource} ${api_id}= Fetch From Right ${service_api_unavailable_resource.path} / + IF "${event_detail_expected}" != "${TRUE}" + ${api_id}= Set Variable ${NONE} + END ${event_expected}= Create Notification Event ... ${subscription_id} ... SERVICE_API_UNAVAILABLE @@ -748,42 +1299,62 @@ Create Expected Events For Service API Notifications RETURN ${events_expected} Create Expected Api Invoker Events - [Arguments] ${subscription_id} ${api_invoker_id} ${events_expected}=${NONE} + [Arguments] + ... ${subscription_id} + ... ${api_invoker_id} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + IF ${events_expected} == ${NONE} ${events_expected}= Create List END + + ${api_invoker_id_used}= Set Variable ${api_invoker_id} + IF "${event_detail_expected}" != "${TRUE}" + ${api_invoker_id_used}= Set Variable ${NONE} + END ## Create events expected # Create Notification Events expected to be received for Onboard event ${event_expected}= Create Notification Event ... ${subscription_id} ... API_INVOKER_ONBOARDED - ... apiInvokerIds=${api_invoker_id} + ... 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} + ... apiInvokerIds=${api_invoker_id_used} Append To List ${events_expected} ${event_expected} # Create Notification Events expected to be received for Offboard event ${event_expected}= Create Notification Event ... ${subscription_id} ... API_INVOKER_OFFBOARDED - ... apiInvokerIds=${api_invoker_id} + ... apiInvokerIds=${api_invoker_id_used} Append To List ${events_expected} ${event_expected} RETURN ${events_expected} Create Expected Access Control Policy Update Event - [Arguments] ${subscription_id} ${service_api_id} ${api_invoker_policies} ${events_expected}=${NONE} + [Arguments] + ... ${subscription_id} + ... ${service_api_id} + ... ${api_invoker_policies} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + IF ${events_expected} == ${NONE} ${events_expected}= Create List END ${acc_ctrl_pol_list}= Create Dictionary apiId=${service_api_id} apiInvokerPolicies=${api_invoker_policies} Check Variable ${acc_ctrl_pol_list} AccessControlPolicyListExt + IF "${event_detail_expected}" != "${TRUE}" + ${acc_ctrl_pol_list}= Set Variable ${NONE} + END + ${event_expected}= Create Notification Event ... ${subscription_id} ... ACCESS_CONTROL_POLICY_UPDATE @@ -793,7 +1364,9 @@ Create Expected Access Control Policy Update Event RETURN ${events_expected} Create Expected Access Control Policy Unavailable - [Arguments] ${subscription_id} ${events_expected}=${NONE} + [Arguments] ${subscription_id} + ... ${events_expected}=${NONE} + IF ${events_expected} == ${NONE} ${events_expected}= Create List END @@ -816,16 +1389,26 @@ Create Expected Api Invoker Authorization Revoked RETURN ${events_expected} Create Expected Service Update Event - [Arguments] ${subscription_id} ${service_api_resource} ${service_api_descriptions} ${events_expected}=${NONE} + [Arguments] + ... ${subscription_id} + ... ${service_api_resource} + ... ${service_api_descriptions} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + IF ${events_expected} == ${NONE} ${events_expected}= Create List END ${api_id}= Fetch From Right ${service_api_resource.path} / Set To Dictionary ${service_api_descriptions} apiId=${api_id} + + IF "${event_detail_expected}" != "${TRUE}" + ${service_api_descriptions}= Set Variable ${NONE} + END ${events_expected}= Create List ${event_expected}= Create Notification Event ... ${subscription_id} ... SERVICE_API_UPDATE ... serviceAPIDescriptions=${service_api_descriptions} Append To List ${events_expected} ${event_expected} - RETURN ${events_expected} \ No newline at end of file + RETURN ${events_expected} -- GitLab From 1673d44f5577eb8ca7f441c5f446771c2754a035 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Wed, 4 Dec 2024 12:41:04 +0100 Subject: [PATCH 4/9] commented code removing provider by superadmin --- .../capif_api_publish_service.robot | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot b/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot index 8808e7d..adc7f57 100644 --- a/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot +++ b/tests/features/CAPIF Api Publish Service/capif_api_publish_service.robot @@ -381,15 +381,15 @@ Check Two Published APIs with different APFs are removed when Provider is delete Run Keyword And Continue On Failure Should Be Equal "${services_removed}" "2" msg=Not all services removed after delete provider (removed) vs (expected) - # Remove service API by superadmin - ${resp}= Delete Request Capif - ... /published-apis/v1/${register_user_info['apf_roles']['${APF_PROVIDER_USERNAME}_1']['apf_id']}/service-apis/${serviceApiId2} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${SUPERADMIN_USERNAME} + # # Remove service API by superadmin + # ${resp}= Delete Request Capif + # ... /published-apis/v1/${register_user_info['apf_roles']['${APF_PROVIDER_USERNAME}_1']['apf_id']}/service-apis/${serviceApiId2} + # ... server=${CAPIF_HTTPS_URL} + # ... verify=ca.crt + # ... username=${SUPERADMIN_USERNAME} - ${services_present_on_ccf_after_provider_deletion_superadmin}= Get Number Of Services + # ${services_present_on_ccf_after_provider_deletion_superadmin}= Get Number Of Services - ${services_removed}= Evaluate ${services_present_on_ccf_after_publish} - ${services_present_on_ccf_after_provider_deletion_superadmin} + # ${services_removed}= Evaluate ${services_present_on_ccf_after_publish} - ${services_present_on_ccf_after_provider_deletion_superadmin} - Run Keyword And Continue On Failure Should Be Equal "${services_removed}" "2" msg=Not all services removed after delete provider (removed) vs (expected) + # Run Keyword And Continue On Failure Should Be Equal "${services_removed}" "2" msg=Not all services removed after delete provider (removed) vs (expected) -- GitLab From 08691b96fb1ef53f45238afb7a2a91e3a85b05db Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Wed, 4 Dec 2024 16:22:10 +0100 Subject: [PATCH 5/9] Change tag name for testing --- tests/features/Api Status/api_status.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/features/Api Status/api_status.robot b/tests/features/Api Status/api_status.robot index fd67ace..0b76c9d 100644 --- a/tests/features/Api Status/api_status.robot +++ b/tests/features/Api Status/api_status.robot @@ -19,7 +19,7 @@ ${SUBSCRIPTION_ID_NOT_VALID} not-valid *** Test Cases *** Invoker receives Service API Invocation events - [Tags] api_status-1 mockserver smoke + [Tags] api_status-X mockserver smoke # Initialize Mock server Init Mock Server -- GitLab From ee5055662affb09ea3048c2b441abb41fbcd806d Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 12 Dec 2024 09:27:01 +0100 Subject: [PATCH 6/9] Code Refactor on expected Messages Keywords --- tests/features/Api Status/api_status.robot | 210 +----------------- .../CAPIF Api Events/capif_events_api.robot | 202 ----------------- tests/libraries/common/bodyRequests.py | 21 +- tests/libraries/helpers.py | 19 -- tests/resources/common.resource | 1 + tests/resources/common/expectedMessages.robot | 207 +++++++++++++++++ tests/resources/common/httpServer.robot | 2 - tests/resources/common/httpServerCtrl.robot | 3 - 8 files changed, 211 insertions(+), 454 deletions(-) create mode 100644 tests/resources/common/expectedMessages.robot delete mode 100644 tests/resources/common/httpServer.robot delete mode 100644 tests/resources/common/httpServerCtrl.robot diff --git a/tests/features/Api Status/api_status.robot b/tests/features/Api Status/api_status.robot index 0b76c9d..3c2a872 100644 --- a/tests/features/Api Status/api_status.robot +++ b/tests/features/Api Status/api_status.robot @@ -19,7 +19,7 @@ ${SUBSCRIPTION_ID_NOT_VALID} not-valid *** Test Cases *** Invoker receives Service API Invocation events - [Tags] api_status-X mockserver smoke + [Tags] api_status-x mockserver smoke # Initialize Mock server Init Mock Server @@ -30,7 +30,7 @@ Invoker receives Service API Invocation events # Register APF ${register_user_info_provider}= Provider Default Registration - ${aef_id}= Set Variable ${register_user_info_provider['aef_id']} + ${aef_id}= Set Variable ${register_user_info_provider['aef_id']} # Subscribe to events ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE @@ -78,209 +78,3 @@ Invoker receives Service API Invocation events ... service_api_unavailable_resources=${service_api_unavailable_resources} ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} - - - -*** Keywords *** -Create Events From InvocationLogs - [Arguments] - ... ${subscription_id} - ... ${invocation_log} - ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - - # Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present. - ${invocation_log_base}= Copy Dictionary ${invocation_log} deepcopy=True - # Store log array because each log will be notified in one Event Notification - ${invocation_log_logs}= Copy List ${invocation_log_base['logs']} - # Remove logs array from invocationLog data - Remove From Dictionary ${invocation_log_base} logs - - FOR ${log} IN @{invocation_log_logs} - Log Dictionary ${log} - ${invocation_logs}= Copy Dictionary ${invocation_log_base} deepcopy=True - - # Get Event Enum for this result - ${event_enum}= Set Variable - IF ${log['result']} >= 200 and ${log['result']} < 300 - ${event_enum}= Set Variable SERVICE_API_INVOCATION_SUCCESS - ELSE - ${event_enum}= Set Variable SERVICE_API_INVOCATION_FAILURE - END - # Create a log array with only one component - ${log_list}= Create List ${log} - # Setup logs array with previously created list - Set To Dictionary ${invocation_logs} logs=${log_list} - IF "${event_detail_expected}" != "${TRUE}" - ${invocation_logs}= Set Variable ${NONE} - END - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... ${event_enum} - ... invocationLogs=${invocation_logs} - Append To List ${events_expected} ${event_expected} - END - - RETURN ${events_expected} - -Create Expected Events For Service API Notifications - [Arguments] - ... ${subscription_id} - ... ${service_api_available_resources}=${NONE} - ... ${service_api_unavailable_resources}=${NONE} - ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} - - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - IF "${service_api_available_resources}" != "${NONE}" - FOR ${service_api_available_resource} IN @{service_api_available_resources} - Log ${service_api_available_resource} - ${api_id}= Fetch From Right ${service_api_available_resource.path} / - - IF "${event_detail_expected}" != "${TRUE}" - ${api_id}= Set Variable ${NONE} - END - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... SERVICE_API_AVAILABLE - ... apiIds=${api_id} - Append To List ${events_expected} ${event_expected} - END - END - - IF "${service_api_unavailable_resources}" != "${NONE}" - FOR ${service_api_unavailable_resource} IN @{service_api_unavailable_resources} - Log ${service_api_unavailable_resource} - ${api_id}= Fetch From Right ${service_api_unavailable_resource.path} / - IF "${event_detail_expected}" != "${TRUE}" - ${api_id}= Set Variable ${NONE} - END - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... SERVICE_API_UNAVAILABLE - ... apiIds=${api_id} - Append To List ${events_expected} ${event_expected} - END - END - - RETURN ${events_expected} - -Create Expected Api Invoker Events - [Arguments] - ... ${subscription_id} - ... ${api_invoker_id} - ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} - - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - - ${api_invoker_id_used}= Set Variable ${api_invoker_id} - IF "${event_detail_expected}" != "${TRUE}" - ${api_invoker_id_used}= Set Variable ${NONE} - END - ## Create events expected - # Create Notification Events expected to be received for Onboard event - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... API_INVOKER_ONBOARDED - ... apiInvokerIds=${api_invoker_id_used} - Append To List ${events_expected} ${event_expected} - - # Create Notification Events expected to be received for Updated event - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... API_INVOKER_UPDATED - ... apiInvokerIds=${api_invoker_id_used} - Append To List ${events_expected} ${event_expected} - - # Create Notification Events expected to be received for Offboard event - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... API_INVOKER_OFFBOARDED - ... apiInvokerIds=${api_invoker_id_used} - Append To List ${events_expected} ${event_expected} - - RETURN ${events_expected} - -Create Expected Access Control Policy Update Event - [Arguments] - ... ${subscription_id} - ... ${service_api_id} - ... ${api_invoker_policies} - ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} - - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - ${acc_ctrl_pol_list}= Create Dictionary apiId=${service_api_id} apiInvokerPolicies=${api_invoker_policies} - Check Variable ${acc_ctrl_pol_list} AccessControlPolicyListExt - - IF "${event_detail_expected}" != "${TRUE}" - ${acc_ctrl_pol_list}= Set Variable ${NONE} - END - - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... ACCESS_CONTROL_POLICY_UPDATE - ... accCtrlPolList=${acc_ctrl_pol_list} - Append To List ${events_expected} ${event_expected} - - RETURN ${events_expected} - -Create Expected Access Control Policy Unavailable - [Arguments] ${subscription_id} - ... ${events_expected}=${NONE} - - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... ACCESS_CONTROL_POLICY_UNAVAILABLE - Append To List ${events_expected} ${event_expected} - - RETURN ${events_expected} - -Create Expected Api Invoker Authorization Revoked - [Arguments] ${subscription_id} ${events_expected}=${NONE} - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... API_INVOKER_AUTHORIZATION_REVOKED - Append To List ${events_expected} ${event_expected} - RETURN ${events_expected} - -Create Expected Service Update Event - [Arguments] - ... ${subscription_id} - ... ${service_api_resource} - ... ${service_api_descriptions} - ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} - - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - ${api_id}= Fetch From Right ${service_api_resource.path} / - Set To Dictionary ${service_api_descriptions} apiId=${api_id} - - IF "${event_detail_expected}" != "${TRUE}" - ${service_api_descriptions}= Set Variable ${NONE} - END - ${events_expected}= Create List - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... SERVICE_API_UPDATE - ... serviceAPIDescriptions=${service_api_descriptions} - Append To List ${events_expected} ${event_expected} - RETURN ${events_expected} diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index 9e5795f..116549f 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -1210,205 +1210,3 @@ Invoker receives an Invoker Authorization Revoked and ACL unavailable event when ... events_expected=${events_expected} ## Check Events Expected towards received notifications at mock server Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} - - -*** Keywords *** -Create Events From InvocationLogs - [Arguments] - ... ${subscription_id} - ... ${invocation_log} - ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - - # Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present. - ${invocation_log_base}= Copy Dictionary ${invocation_log} deepcopy=True - # Store log array because each log will be notified in one Event Notification - ${invocation_log_logs}= Copy List ${invocation_log_base['logs']} - # Remove logs array from invocationLog data - Remove From Dictionary ${invocation_log_base} logs - - FOR ${log} IN @{invocation_log_logs} - Log Dictionary ${log} - ${invocation_logs}= Copy Dictionary ${invocation_log_base} deepcopy=True - - # Get Event Enum for this result - ${event_enum}= Set Variable - IF ${log['result']} >= 200 and ${log['result']} < 300 - ${event_enum}= Set Variable SERVICE_API_INVOCATION_SUCCESS - ELSE - ${event_enum}= Set Variable SERVICE_API_INVOCATION_FAILURE - END - # Create a log array with only one component - ${log_list}= Create List ${log} - # Setup logs array with previously created list - Set To Dictionary ${invocation_logs} logs=${log_list} - IF "${event_detail_expected}" != "${TRUE}" - ${invocation_logs}= Set Variable ${NONE} - END - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... ${event_enum} - ... invocationLogs=${invocation_logs} - Append To List ${events_expected} ${event_expected} - END - - RETURN ${events_expected} - -Create Expected Events For Service API Notifications - [Arguments] - ... ${subscription_id} - ... ${service_api_available_resources}=${NONE} - ... ${service_api_unavailable_resources}=${NONE} - ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} - - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - - FOR ${service_api_available_resource} IN @{service_api_available_resources} - Log ${service_api_available_resource} - ${api_id}= Fetch From Right ${service_api_available_resource.path} / - - IF "${event_detail_expected}" != "${TRUE}" - ${api_id}= Set Variable ${NONE} - END - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... SERVICE_API_AVAILABLE - ... apiIds=${api_id} - Append To List ${events_expected} ${event_expected} - END - - FOR ${service_api_unavailable_resource} IN @{service_api_unavailable_resources} - Log ${service_api_unavailable_resource} - ${api_id}= Fetch From Right ${service_api_unavailable_resource.path} / - IF "${event_detail_expected}" != "${TRUE}" - ${api_id}= Set Variable ${NONE} - END - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... SERVICE_API_UNAVAILABLE - ... apiIds=${api_id} - Append To List ${events_expected} ${event_expected} - END - - RETURN ${events_expected} - -Create Expected Api Invoker Events - [Arguments] - ... ${subscription_id} - ... ${api_invoker_id} - ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} - - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - - ${api_invoker_id_used}= Set Variable ${api_invoker_id} - IF "${event_detail_expected}" != "${TRUE}" - ${api_invoker_id_used}= Set Variable ${NONE} - END - ## Create events expected - # Create Notification Events expected to be received for Onboard event - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... API_INVOKER_ONBOARDED - ... apiInvokerIds=${api_invoker_id_used} - Append To List ${events_expected} ${event_expected} - - # Create Notification Events expected to be received for Updated event - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... API_INVOKER_UPDATED - ... apiInvokerIds=${api_invoker_id_used} - Append To List ${events_expected} ${event_expected} - - # Create Notification Events expected to be received for Offboard event - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... API_INVOKER_OFFBOARDED - ... apiInvokerIds=${api_invoker_id_used} - Append To List ${events_expected} ${event_expected} - - RETURN ${events_expected} - -Create Expected Access Control Policy Update Event - [Arguments] - ... ${subscription_id} - ... ${service_api_id} - ... ${api_invoker_policies} - ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} - - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - ${acc_ctrl_pol_list}= Create Dictionary apiId=${service_api_id} apiInvokerPolicies=${api_invoker_policies} - Check Variable ${acc_ctrl_pol_list} AccessControlPolicyListExt - - IF "${event_detail_expected}" != "${TRUE}" - ${acc_ctrl_pol_list}= Set Variable ${NONE} - END - - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... ACCESS_CONTROL_POLICY_UPDATE - ... accCtrlPolList=${acc_ctrl_pol_list} - Append To List ${events_expected} ${event_expected} - - RETURN ${events_expected} - -Create Expected Access Control Policy Unavailable - [Arguments] ${subscription_id} - ... ${events_expected}=${NONE} - - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... ACCESS_CONTROL_POLICY_UNAVAILABLE - Append To List ${events_expected} ${event_expected} - - RETURN ${events_expected} - -Create Expected Api Invoker Authorization Revoked - [Arguments] ${subscription_id} ${events_expected}=${NONE} - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... API_INVOKER_AUTHORIZATION_REVOKED - Append To List ${events_expected} ${event_expected} - RETURN ${events_expected} - -Create Expected Service Update Event - [Arguments] - ... ${subscription_id} - ... ${service_api_resource} - ... ${service_api_descriptions} - ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} - - IF ${events_expected} == ${NONE} - ${events_expected}= Create List - END - ${api_id}= Fetch From Right ${service_api_resource.path} / - Set To Dictionary ${service_api_descriptions} apiId=${api_id} - - IF "${event_detail_expected}" != "${TRUE}" - ${service_api_descriptions}= Set Variable ${NONE} - END - ${events_expected}= Create List - ${event_expected}= Create Notification Event - ... ${subscription_id} - ... SERVICE_API_UPDATE - ... serviceAPIDescriptions=${service_api_descriptions} - Append To List ${events_expected} ${event_expected} - RETURN ${events_expected} diff --git a/tests/libraries/common/bodyRequests.py b/tests/libraries/common/bodyRequests.py index e87f349..87228cf 100644 --- a/tests/libraries/common/bodyRequests.py +++ b/tests/libraries/common/bodyRequests.py @@ -69,7 +69,7 @@ def check_variable(input, data_type): def check_attributes_dict(body, data_type): mandatory_attributes = capif_types[data_type]["mandatory_attributes"] optional_parameters = capif_types[data_type]["optional_attributes"] - regex_attributes = capif_types[data_type].get("regex_attributes",{}) + regex_attributes = capif_types[data_type].get("regex_attributes", {}) all_attributes = mandatory_attributes | optional_parameters # Check if body has not allowed attributes @@ -116,15 +116,6 @@ def check_attributes_dict(body, data_type): return all_attributes -def sign_csr_body(username, public_key): - data = { - "csr": public_key.decode("utf-8"), - "mode": "client", - "filename": username - } - return data - - def check_uri(input, rule): if rfc3987.match(input, rule=rule) is not None: return input @@ -140,13 +131,3 @@ def check_regex(input, regex): return True else: raise Exception("Input(" + input + ") not match regex (" + regex + ")") - - -def vault_sign_superadmin_certificate_body(csr_request): - data = { - 'format': 'pem_bundle', - 'ttl': '43000h', - 'csr': csr_request, - 'common_name': "superadmin" - } - return data diff --git a/tests/libraries/helpers.py b/tests/libraries/helpers.py index 1b974f2..ae63373 100644 --- a/tests/libraries/helpers.py +++ b/tests/libraries/helpers.py @@ -162,22 +162,3 @@ def filter_users_by_prefix_username(users, prefix): if user['username'].startswith(prefix): filtered_users.append(user['username']) return filtered_users - - -def sign_csr_body(username, public_key): - data = { - "csr": public_key.decode("utf-8"), - "mode": "client", - "filename": username - } - return data - - -def vault_sign_superadmin_certificate_body(csr_request): - data = { - "format": "pem_bundle", - "ttl": "43000h", - "csr": csr_request.decode("utf-8"), - "common_name": "superadmin" - } - return data diff --git a/tests/resources/common.resource b/tests/resources/common.resource index d5cc35e..d80b3a3 100644 --- a/tests/resources/common.resource +++ b/tests/resources/common.resource @@ -5,6 +5,7 @@ Library Process Library Collections Variables /opt/robot-tests/tests/libraries/environment.py Resource /opt/robot-tests/tests/resources/common/basicRequests.robot +Resource /opt/robot-tests/tests/resources/common/expectedMessages.robot *** Variables *** diff --git a/tests/resources/common/expectedMessages.robot b/tests/resources/common/expectedMessages.robot new file mode 100644 index 0000000..d2bf2d6 --- /dev/null +++ b/tests/resources/common/expectedMessages.robot @@ -0,0 +1,207 @@ +*** Settings *** +Documentation This resource file contains the basic requests used by Capif. NGINX_HOSTNAME and CAPIF_AUTH can be set as global variables, depends on environment used + +Library Collections +Library String +Library /opt/robot-tests/tests/libraries/bodyRequests.py + +*** Keywords *** +Create Events From InvocationLogs + [Arguments] + ... ${subscription_id} + ... ${invocation_log} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + + # Now we create the expected events received at notification server according to logs sent to loggin service in order to check if all are present. + ${invocation_log_base}= Copy Dictionary ${invocation_log} deepcopy=True + # Store log array because each log will be notified in one Event Notification + ${invocation_log_logs}= Copy List ${invocation_log_base['logs']} + # Remove logs array from invocationLog data + Remove From Dictionary ${invocation_log_base} logs + + FOR ${log} IN @{invocation_log_logs} + Log Dictionary ${log} + ${invocation_logs}= Copy Dictionary ${invocation_log_base} deepcopy=True + + # Get Event Enum for this result + ${event_enum}= Set Variable + IF ${log['result']} >= 200 and ${log['result']} < 300 + ${event_enum}= Set Variable SERVICE_API_INVOCATION_SUCCESS + ELSE + ${event_enum}= Set Variable SERVICE_API_INVOCATION_FAILURE + END + # Create a log array with only one component + ${log_list}= Create List ${log} + # Setup logs array with previously created list + Set To Dictionary ${invocation_logs} logs=${log_list} + IF "${event_detail_expected}" != "${TRUE}" + ${invocation_logs}= Set Variable ${NONE} + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... ${event_enum} + ... invocationLogs=${invocation_logs} + Append To List ${events_expected} ${event_expected} + END + + RETURN ${events_expected} + +Create Expected Events For Service API Notifications + [Arguments] + ... ${subscription_id} + ... ${service_api_available_resources}=${NONE} + ... ${service_api_unavailable_resources}=${NONE} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + + FOR ${service_api_available_resource} IN @{service_api_available_resources} + Log ${service_api_available_resource} + ${api_id}= Fetch From Right ${service_api_available_resource.path} / + + IF "${event_detail_expected}" != "${TRUE}" + ${api_id}= Set Variable ${NONE} + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... SERVICE_API_AVAILABLE + ... apiIds=${api_id} + Append To List ${events_expected} ${event_expected} + END + + FOR ${service_api_unavailable_resource} IN @{service_api_unavailable_resources} + Log ${service_api_unavailable_resource} + ${api_id}= Fetch From Right ${service_api_unavailable_resource.path} / + IF "${event_detail_expected}" != "${TRUE}" + ${api_id}= Set Variable ${NONE} + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... SERVICE_API_UNAVAILABLE + ... apiIds=${api_id} + Append To List ${events_expected} ${event_expected} + END + + RETURN ${events_expected} + +Create Expected Api Invoker Events + [Arguments] + ... ${subscription_id} + ... ${api_invoker_id} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + + ${api_invoker_id_used}= Set Variable ${api_invoker_id} + IF "${event_detail_expected}" != "${TRUE}" + ${api_invoker_id_used}= Set Variable ${NONE} + END + ## Create events expected + # Create Notification Events expected to be received for Onboard event + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_ONBOARDED + ... apiInvokerIds=${api_invoker_id_used} + Append To List ${events_expected} ${event_expected} + + # Create Notification Events expected to be received for Updated event + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_UPDATED + ... apiInvokerIds=${api_invoker_id_used} + Append To List ${events_expected} ${event_expected} + + # Create Notification Events expected to be received for Offboard event + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_OFFBOARDED + ... apiInvokerIds=${api_invoker_id_used} + Append To List ${events_expected} ${event_expected} + + RETURN ${events_expected} + +Create Expected Access Control Policy Update Event + [Arguments] + ... ${subscription_id} + ... ${service_api_id} + ... ${api_invoker_policies} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + ${acc_ctrl_pol_list}= Create Dictionary apiId=${service_api_id} apiInvokerPolicies=${api_invoker_policies} + Check Variable ${acc_ctrl_pol_list} AccessControlPolicyListExt + + IF "${event_detail_expected}" != "${TRUE}" + ${acc_ctrl_pol_list}= Set Variable ${NONE} + END + + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... ACCESS_CONTROL_POLICY_UPDATE + ... accCtrlPolList=${acc_ctrl_pol_list} + Append To List ${events_expected} ${event_expected} + + RETURN ${events_expected} + +Create Expected Access Control Policy Unavailable + [Arguments] ${subscription_id} + ... ${events_expected}=${NONE} + + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... ACCESS_CONTROL_POLICY_UNAVAILABLE + Append To List ${events_expected} ${event_expected} + + RETURN ${events_expected} + +Create Expected Api Invoker Authorization Revoked + [Arguments] ${subscription_id} ${events_expected}=${NONE} + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... API_INVOKER_AUTHORIZATION_REVOKED + Append To List ${events_expected} ${event_expected} + RETURN ${events_expected} + +Create Expected Service Update Event + [Arguments] + ... ${subscription_id} + ... ${service_api_resource} + ... ${service_api_descriptions} + ... ${events_expected}=${NONE} + ... ${event_detail_expected}=${TRUE} + + IF ${events_expected} == ${NONE} + ${events_expected}= Create List + END + ${api_id}= Fetch From Right ${service_api_resource.path} / + Set To Dictionary ${service_api_descriptions} apiId=${api_id} + + IF "${event_detail_expected}" != "${TRUE}" + ${service_api_descriptions}= Set Variable ${NONE} + END + ${events_expected}= Create List + ${event_expected}= Create Notification Event + ... ${subscription_id} + ... SERVICE_API_UPDATE + ... serviceAPIDescriptions=${service_api_descriptions} + Append To List ${events_expected} ${event_expected} + RETURN ${events_expected} diff --git a/tests/resources/common/httpServer.robot b/tests/resources/common/httpServer.robot deleted file mode 100644 index 7105dc1..0000000 --- a/tests/resources/common/httpServer.robot +++ /dev/null @@ -1,2 +0,0 @@ -*** Settings *** -Library HttpLibrary diff --git a/tests/resources/common/httpServerCtrl.robot b/tests/resources/common/httpServerCtrl.robot deleted file mode 100644 index 8782d19..0000000 --- a/tests/resources/common/httpServerCtrl.robot +++ /dev/null @@ -1,3 +0,0 @@ -*** Settings *** - -Library String -- GitLab From 8c4ca516bf02d68c9b2d06e8c8a3df24b52789b2 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Mon, 16 Dec 2024 08:34:55 +0100 Subject: [PATCH 7/9] Update tests to accomplish apiStatus --- tests/features/Api Status/api_status.robot | 157 ++++++++++++++++++ .../CAPIF Api Events/capif_events_api.robot | 1 + .../vendor_extensibility.robot | 4 +- .../api_publish_service/bodyRequests.py | 89 ++++++---- tests/resources/common/basicRequests.robot | 26 ++- tests/resources/common/expectedMessages.robot | 17 +- 6 files changed, 251 insertions(+), 43 deletions(-) diff --git a/tests/features/Api Status/api_status.robot b/tests/features/Api Status/api_status.robot index 3c2a872..77ea788 100644 --- a/tests/features/Api Status/api_status.robot +++ b/tests/features/Api Status/api_status.robot @@ -18,6 +18,163 @@ ${SUBSCRIPTION_ID_NOT_VALID} not-valid *** Test Cases *** +Publish without apiStatus feature receive eventDetails with serviceAPIDescription + [Tags] api_status-1 mockserver smoke + + # Initialize Mock server + Init Mock Server + + # Default Invoker Registration and Onboarding + ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + + # Register APF + ${register_user_info_provider}= Provider Default Registration 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} + + # Subscribe to events + ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=C + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + # Check Results + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + + # Publish 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} + + # 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} + + # Provider Remove service_1 published API + ${resp}= Delete Request Capif + ... ${resource_url.path} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${APF_PROVIDER_USERNAME} + + Status Should Be 204 ${resp} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${service_api_available_resources}= Create List ${resource_url} + ${service_api_unavailable_resources}= Create List ${resource_url} + ${events_expected}= Create Expected Events For Service API Notifications + ... subscription_id=${subscription_id} + ... service_api_available_resources=${service_api_available_resources} + ... service_api_unavailable_resources=${service_api_unavailable_resources} + ... event_detail_expected=${TRUE} + ... service_api_description_expected=${TRUE} + ... service_api_description=${service_api_description_published} + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + +Publish without apiStatus feature receive eventDetails without serviceAPIDescription + [Tags] api_status-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} + + # Subscribe to events + ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=4 + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + # Check Results + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + + # Publish 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} + + # 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} + + # Provider Remove service_1 published API + ${resp}= Delete Request Capif + ... ${resource_url.path} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${APF_PROVIDER_USERNAME} + + Status Should Be 204 ${resp} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${service_api_available_resources}= Create List ${resource_url} + ${service_api_unavailable_resources}= Create List ${resource_url} + ${events_expected}= Create Expected Events For Service API Notifications + ... subscription_id=${subscription_id} + ... service_api_available_resources=${service_api_available_resources} + ... service_api_unavailable_resources=${service_api_unavailable_resources} + ... event_detail_expected=${TRUE} + ... service_api_description_expected=${FALSE} + ... service_api_description=${service_api_description_published} + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} +#### ----- + Invoker receives Service API Invocation events [Tags] api_status-x mockserver smoke diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index 116549f..9f8b4e2 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -280,6 +280,7 @@ Invoker subscribe to Service API Available and Unavailable events ... subscription_id=${subscription_id} ... service_api_available_resources=${service_api_available_resources} ... service_api_unavailable_resources=${service_api_unavailable_resources} + ... event_detail_expected=${TRUE} ## 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/Vendor Extensibility/vendor_extensibility.robot b/tests/features/Vendor Extensibility/vendor_extensibility.robot index 8717224..80aceed 100644 --- a/tests/features/Vendor Extensibility/vendor_extensibility.robot +++ b/tests/features/Vendor Extensibility/vendor_extensibility.robot @@ -15,7 +15,7 @@ ${API_INVOKER_NOT_REGISTERED} not-valid *** Test Cases *** Published API with vendor extensibility - [Tags] vendor_extensibility-1 + [Tags] vendor_extensibility-1 smoke ${vendor_specific_service_api_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:service-info ${vendor_specific_aef_profile_key}= Set Variable vendorSpecific-urn:etsi:mec:capifext:transport-info # Register APF @@ -162,7 +162,7 @@ Publish API with vendorExt active and discover without supported features filter ... ${service_api_description_published_to_check} Publish API with vendorExt active but without vendorSpecifics - [Tags] vendor_extensibility-4 + [Tags] vendor_extensibility-4 smoke # Register APF ${register_user_info}= Provider Default Registration diff --git a/tests/libraries/api_publish_service/bodyRequests.py b/tests/libraries/api_publish_service/bodyRequests.py index ddf25ff..b693457 100644 --- a/tests/libraries/api_publish_service/bodyRequests.py +++ b/tests/libraries/api_publish_service/bodyRequests.py @@ -1,39 +1,17 @@ def create_service_api_description(api_name="service_1", aef_id="aef_id", supported_features="0", vendor_specific_service_api_description=None, vendor_specific_aef_profile=None): + aef_ids = list() + if isinstance(aef_id, list): + aef_ids = aef_id + print("aef_id parameter is a list") + elif isinstance(aef_id, str): + print("aef_id parameter is a string") + aef_ids.append(aef_id) + + profiles = create_aef_profiles(aef_ids) + body = { "apiName": api_name, - "aefProfiles": [ - { - "aefId": aef_id, - "versions": [ - { - "apiVersion": "v1", - "expiry": "2021-11-30T10:32:02.004000+00:00", - "resources": [ - { - "resourceName": "string", - "commType": "REQUEST_RESPONSE", - "uri": "string", - "custOpName": "string", - "operations": [ - "GET" - ], - "description": "string" - } - ], - } - ], - "protocol": "HTTP_1_1", - "dataFormat": "JSON", - "securityMethods": ["PSK"], - "interfaceDescriptions": [ - { - "ipv4Addr": "string", - "port": 65535, - "securityMethods": ["PSK"] - } - ] - } - ], + "aefProfiles": profiles, "description": "ROBOT_TESTING", "shareableInfo": { "isShareable": True, @@ -63,3 +41,48 @@ def create_service_api_description(api_name="service_1", aef_id="aef_id", suppor body['supportedFeatures'] = supported_features return body + + +def create_aef_profiles(aef_ids): + profiles = list() + index=1 + for aef_id in aef_ids: + profiles.append(create_aef_profile(aef_id,"resource_" + str(index))) + index=index+1 + return profiles + + + +def create_aef_profile(aef_id, resource_name): + data = { + "aefId": aef_id, + "versions": [ + { + "apiVersion": "v1", + "expiry": "2021-11-30T10:32:02.004000+00:00", + "resources": [ + { + "resourceName": resource_name, + "commType": "REQUEST_RESPONSE", + "uri": "string", + "custOpName": "string", + "operations": [ + "GET" + ], + "description": "string" + } + ], + } + ], + "protocol": "HTTP_1_1", + "dataFormat": "JSON", + "securityMethods": ["PSK"], + "interfaceDescriptions": [ + { + "ipv4Addr": "string", + "port": 65535, + "securityMethods": ["PSK"] + } + ] + } + return data diff --git a/tests/resources/common/basicRequests.robot b/tests/resources/common/basicRequests.robot index 1f69f48..03518dd 100644 --- a/tests/resources/common/basicRequests.robot +++ b/tests/resources/common/basicRequests.robot @@ -9,7 +9,6 @@ Library Telnet Library String - *** Variables *** ${CAPIF_AUTH} ${EMPTY} ${CAPIF_BEARER} ${EMPTY} @@ -533,7 +532,7 @@ Delete User At Register Should Be Equal As Strings ${resp.status_code} 204 - IF ${environment_users} + IF ${environment_users} Call Method ${CAPIF_USERS} remove_register_users_entry ${user_uuid} END @@ -721,8 +720,8 @@ Provider Registration FOR ${prov} IN @{resp.json()['apiProvFuncs']} Log Dictionary ${prov} Store In File ${prov['apiProvFuncInfo']}.crt ${prov['regInfo']['apiProvCert']} - Log Dictionary ${register_user_info} - Log ${register_user_info['apf_username']} + Log Dictionary ${register_user_info} + Log ${register_user_info['apf_username']} IF "${prov['apiProvFuncRole']}" == "APF" IF "${prov['apiProvFuncInfo']}" == "${register_user_info['apf_username']}" Set To Dictionary ${register_user_info} apf_id=${prov['apiProvFuncId']} @@ -765,7 +764,7 @@ Provider Registration RETURN ${register_user_info} Provider Default Registration - [Arguments] + [Arguments] ... ${provider_username}=${PROVIDER_USERNAME} ... ${total_apf_roles}=1 ... ${total_aef_roles}=1 @@ -795,6 +794,14 @@ Publish Service Api ... ${supported_features}=0 ... ${vendor_specific_service_api_description}=${None} ... ${vendor_specific_aef_profile}=${None} + ... ${aef_id}=${NONE} + + ${aef_ids}= Create List + IF "${aef_id}" == "${NONE}" + Append To List ${aef_ids} ${register_user_info_provider['aef_id']} + ELSE + ${aef_ids}= Set Variable ${aef_id} + END ${apf_id_to_use}= Set Variable ${register_user_info_provider['apf_id']} ${apf_username_to_use}= Set Variable ${register_user_info_provider['apf_username']} @@ -811,7 +818,12 @@ Publish Service Api ${apf_username_to_use}= Set Variable ${apf_username} END - ${request_body}= Create Service Api Description ${service_name} ${register_user_info_provider['aef_id']} ${supported_features} ${vendor_specific_service_api_description} ${vendor_specific_aef_profile} + ${request_body}= Create Service Api Description + ... ${service_name} + ... ${aef_ids} + ... ${supported_features} + ... ${vendor_specific_service_api_description} + ... ${vendor_specific_aef_profile} ${resp}= Post Request Capif ... /published-apis/v1/${apf_id_to_use}/service-apis ... json=${request_body} @@ -914,4 +926,4 @@ Get Number Of Services Log Dictionary ${resp.json()} ${size}= Get Length ${resp.json()['services']} - RETURN ${size} + RETURN ${size} diff --git a/tests/resources/common/expectedMessages.robot b/tests/resources/common/expectedMessages.robot index d2bf2d6..c246324 100644 --- a/tests/resources/common/expectedMessages.robot +++ b/tests/resources/common/expectedMessages.robot @@ -56,12 +56,24 @@ Create Expected Events For Service API Notifications ... ${service_api_available_resources}=${NONE} ... ${service_api_unavailable_resources}=${NONE} ... ${events_expected}=${NONE} - ... ${event_detail_expected}=${TRUE} + ... ${event_detail_expected}=${FALSE} + ... ${service_api_description_expected}=${FALSE} + ... ${service_api_description}=${NONE} IF ${events_expected} == ${NONE} ${events_expected}= Create List END + ${service_api_description_to_use}= Set Variable ${NONE} + IF "${service_api_description_expected}" == "${TRUE}" + IF "${service_api_description}" == "${NONE}" + LOG service_api_description is expected but serviceApiDescription is set to None ERROR + Fail service_api_description is expected but serviceApiDescription is set to None, review Test ${TEST_NAME} + ELSE + ${service_api_description_to_use}= Set Variable ${service_api_description} + END + END + FOR ${service_api_available_resource} IN @{service_api_available_resources} Log ${service_api_available_resource} ${api_id}= Fetch From Right ${service_api_available_resource.path} / @@ -69,10 +81,12 @@ Create Expected Events For Service API Notifications IF "${event_detail_expected}" != "${TRUE}" ${api_id}= Set Variable ${NONE} END + ${event_expected}= Create Notification Event ... ${subscription_id} ... SERVICE_API_AVAILABLE ... apiIds=${api_id} + ... serviceAPIDescriptions=${service_api_description_to_use} Append To List ${events_expected} ${event_expected} END @@ -86,6 +100,7 @@ Create Expected Events For Service API Notifications ... ${subscription_id} ... SERVICE_API_UNAVAILABLE ... apiIds=${api_id} + ... serviceAPIDescriptions=${service_api_description_to_use} Append To List ${events_expected} ${event_expected} END -- GitLab From b5a26ad8e73daadd6085d7ece9fb3380838732e9 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Mon, 16 Dec 2024 10:39:20 +0100 Subject: [PATCH 8/9] Test 3 of api status implementation --- tests/features/Api Status/api_status.robot | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/tests/features/Api Status/api_status.robot b/tests/features/Api Status/api_status.robot index 77ea788..8b96fac 100644 --- a/tests/features/Api Status/api_status.robot +++ b/tests/features/Api Status/api_status.robot @@ -175,6 +175,89 @@ Publish without apiStatus feature receive eventDetails without serviceAPIDescrip Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} #### ----- +Publish without apiStatus feature receive eventDetails without eventDetails (apiMonitoringStatus active) + [Tags] api_status-3 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} + + # Subscribe to events + ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE + + ${request_body}= Create Events Subscription + ... events=@{events_list} + ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing + ... supported_features=8 + ${resp}= Post Request Capif + ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions + ... json=${request_body} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${INVOKER_USERNAME} + + # Check Results + Check Response Variable Type And Values ${resp} 201 EventSubscription + ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + + # Publish 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} + + # 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} + + # Provider Remove service_1 published API + ${resp}= Delete Request Capif + ... ${resource_url.path} + ... server=${CAPIF_HTTPS_URL} + ... verify=ca.crt + ... username=${APF_PROVIDER_USERNAME} + + Status Should Be 204 ${resp} + + # Check Event Notifications + ## Create check Events to ensure all notifications were received + ${service_api_available_resources}= Create List ${resource_url} + ${service_api_unavailable_resources}= Create List ${resource_url} + ${events_expected}= Create Expected Events For Service API Notifications + ... subscription_id=${subscription_id} + ... service_api_available_resources=${service_api_available_resources} + ... service_api_unavailable_resources=${service_api_unavailable_resources} + ... event_detail_expected=${FALSE} + ... service_api_description_expected=${FALSE} + ... service_api_description=${service_api_description_published} + ## Check Events Expected towards received notifications at mock server + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} + + + + + +###--- Invoker receives Service API Invocation events [Tags] api_status-x mockserver smoke -- GitLab From 885c0a532ddbb627ed4bc1391c7de29ac4e9d7df Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Mon, 16 Dec 2024 12:29:45 +0100 Subject: [PATCH 9/9] Comment refence test on api status --- tests/features/Api Status/api_status.robot | 120 ++++++++++----------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/tests/features/Api Status/api_status.robot b/tests/features/Api Status/api_status.robot index 8b96fac..2b76a5e 100644 --- a/tests/features/Api Status/api_status.robot +++ b/tests/features/Api Status/api_status.robot @@ -258,63 +258,63 @@ Publish without apiStatus feature receive eventDetails without eventDetails (api ###--- -Invoker receives Service API Invocation events - [Tags] api_status-x mockserver smoke - - # Initialize Mock server - Init Mock Server - - # Default Invoker Registration and Onboarding - ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - - # Register APF - ${register_user_info_provider}= Provider Default Registration - - ${aef_id}= Set Variable ${register_user_info_provider['aef_id']} - - # Subscribe to events - ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE - ${aef_ids}= Create List ${register_user_info_provider['aef_id']} - ${event_filter}= Create Capif Event Filter aefIds=${aef_ids} - ${event_filters}= Create List ${event_filter} - - ${request_body}= Create Events Subscription - ... events=@{events_list} - ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing - ... event_filters=${event_filters} - ... supported_features=4 - ${resp}= Post Request Capif - ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions - ... json=${request_body} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${INVOKER_USERNAME} - - # Check Results - Check Response Variable Type And Values ${resp} 201 EventSubscription - ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} - - # Publish one api - ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api - ... ${register_user_info_provider} - ... service_1 - - # Provider Remove service_1 published API - ${resp}= Delete Request Capif - ... ${resource_url.path} - ... server=${CAPIF_HTTPS_URL} - ... verify=ca.crt - ... username=${APF_PROVIDER_USERNAME} - - Status Should Be 204 ${resp} - - # Check Event Notifications - ## Create check Events to ensure all notifications were received - ${service_api_available_resources}= Create List ${resource_url} - ${service_api_unavailable_resources}= Create List ${resource_url} - ${events_expected}= Create Expected Events For Service API Notifications - ... subscription_id=${subscription_id} - ... service_api_available_resources=${service_api_available_resources} - ... service_api_unavailable_resources=${service_api_unavailable_resources} - ## Check Events Expected towards received notifications at mock server - Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} +# Invoker receives Service API Invocation events +# [Tags] api_status-x mockserver smoke + +# # Initialize Mock server +# Init Mock Server + +# # Default Invoker Registration and Onboarding +# ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding + +# # Register APF +# ${register_user_info_provider}= Provider Default Registration + +# ${aef_id}= Set Variable ${register_user_info_provider['aef_id']} + +# # Subscribe to events +# ${events_list}= Create List SERVICE_API_AVAILABLE SERVICE_API_UNAVAILABLE +# ${aef_ids}= Create List ${register_user_info_provider['aef_id']} +# ${event_filter}= Create Capif Event Filter aefIds=${aef_ids} +# ${event_filters}= Create List ${event_filter} + +# ${request_body}= Create Events Subscription +# ... events=@{events_list} +# ... notification_destination=${NOTIFICATION_DESTINATION_URL}/testing +# ... event_filters=${event_filters} +# ... supported_features=4 +# ${resp}= Post Request Capif +# ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions +# ... json=${request_body} +# ... server=${CAPIF_HTTPS_URL} +# ... verify=ca.crt +# ... username=${INVOKER_USERNAME} + +# # Check Results +# Check Response Variable Type And Values ${resp} 201 EventSubscription +# ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} + +# # Publish one api +# ${service_api_description_published} ${resource_url} ${request_body}= Publish Service Api +# ... ${register_user_info_provider} +# ... service_1 + +# # Provider Remove service_1 published API +# ${resp}= Delete Request Capif +# ... ${resource_url.path} +# ... server=${CAPIF_HTTPS_URL} +# ... verify=ca.crt +# ... username=${APF_PROVIDER_USERNAME} + +# Status Should Be 204 ${resp} + +# # Check Event Notifications +# ## Create check Events to ensure all notifications were received +# ${service_api_available_resources}= Create List ${resource_url} +# ${service_api_unavailable_resources}= Create List ${resource_url} +# ${events_expected}= Create Expected Events For Service API Notifications +# ... subscription_id=${subscription_id} +# ... service_api_available_resources=${service_api_available_resources} +# ... service_api_unavailable_resources=${service_api_unavailable_resources} +# ## Check Events Expected towards received notifications at mock server +# Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} -- GitLab