From 302f7a8b2377a490074e04e09e2454bf90afb4c0 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 4 Jul 2024 09:24:41 +0200 Subject: [PATCH] NOTIFICATION_DESTINATION changed to NOTIFICATION_DESTINATION_URL and also removed old one. Code refactor and improvement of robot script --- services/run_capif_tests.sh | 7 +-- .../capif_api_access_control_policy.robot | 1 - .../capif_auditing_api.robot | 1 - .../CAPIF Api Events/capif_events_api.robot | 28 +++++------ .../capif_logging_api.robot | 1 - .../capif_security_api.robot | 47 +++++++++---------- tests/resources/common.resource | 1 + 7 files changed, 40 insertions(+), 46 deletions(-) diff --git a/services/run_capif_tests.sh b/services/run_capif_tests.sh index f0a3f07..5f2840d 100755 --- a/services/run_capif_tests.sh +++ b/services/run_capif_tests.sh @@ -10,24 +10,20 @@ RESULT_FOLDER=$REPOSITORY_BASE_FOLDER/results/$timestamp ROBOT_DOCKER_FILE_FOLDER=$REPOSITORY_BASE_FOLDER/tools/robot # nginx Hostname and http port (80 by default) to reach for tests -# CAPIF_REGISTER=registercapif.mobilesandbox.cloud CAPIF_REGISTER=capifcore -# CAPIF_REGISTER_PORT=37211 CAPIF_REGISTER_PORT=8084 -# CAPIF_HOSTNAME=capif.mobilesandbox.cloud CAPIF_HOSTNAME=capifcore CAPIF_HTTP_PORT=8080 CAPIF_HTTPS_PORT=443 # VAULT access configuration -# CAPIF_VAULT=vault.5gnacar.int CAPIF_VAULT=vault CAPIF_VAULT_PORT=8200 -# CAPIF_VAULT_TOKEN=dev-only-token CAPIF_VAULT_TOKEN=read-ca-token MOCK_SERVER_URL=http://mock-server:9090 +NOTIFICATION_DESTINATION_URL=http://mock-server:9090 echo "CAPIF_HOSTNAME = $CAPIF_HOSTNAME" @@ -78,4 +74,5 @@ docker run -ti --rm --network="host" \ --variable CAPIF_VAULT:$CAPIF_VAULT \ --variable CAPIF_VAULT_PORT:$CAPIF_VAULT_PORT \ --variable CAPIF_VAULT_TOKEN:$CAPIF_VAULT_TOKEN \ + --variable NOTIFICATION_DESTINATION_URL:$NOTIFICATION_DESTINATION_URL \ --variable MOCK_SERVER_URL:$MOCK_SERVER_URL $@ diff --git a/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot b/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot index cd49784..768367e 100644 --- a/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot +++ b/tests/features/CAPIF Api Access Control Policy/capif_api_access_control_policy.robot @@ -14,7 +14,6 @@ Test Teardown Reset Testing Environment ${APF_ID_NOT_VALID} apf-example ${SERVICE_API_ID_NOT_VALID} not-valid ${API_INVOKER_NOT_VALID} not-valid -${NOTIFICATION_DESTINATION} http://robot.testing:1080 ${AEF_ID_NOT_VALID} not-valid diff --git a/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot b/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot index d850a57..a1f2fef 100644 --- a/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot +++ b/tests/features/CAPIF Api Auditing Service/capif_auditing_api.robot @@ -14,7 +14,6 @@ Test Teardown Reset Testing Environment ${AEF_ID_NOT_VALID} aef-example ${SERVICE_API_ID_NOT_VALID} not-valid ${API_INVOKER_NOT_VALID} not-valid -${NOTIFICATION_DESTINATION} http://robot.testing:1080 ${API_VERSION_VALID} v1 ${API_VERSION_NOT_VALID} v58 diff --git a/tests/features/CAPIF Api Events/capif_events_api.robot b/tests/features/CAPIF Api Events/capif_events_api.robot index fdec6a9..07ed967 100644 --- a/tests/features/CAPIF Api Events/capif_events_api.robot +++ b/tests/features/CAPIF Api Events/capif_events_api.robot @@ -171,7 +171,7 @@ Invoker receives Service API Invocation events ${request_body}= Create Events Subscription ... events=@{events_list} - ... notificationDestination=${MOCK_SERVER_URL}/testing + ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing ... eventFilters=${event_filters} ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions @@ -209,7 +209,7 @@ Invoker receives Service API Invocation events ... ${subscription_id} ... ${request_body} ## Check Events Expected towards received notifications at mock server - 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 @@ -243,7 +243,7 @@ Invoker subscribe to Service API Available and Unavailable events ${request_body}= Create Events Subscription ... events=@{events_list} - ... notificationDestination=${MOCK_SERVER_URL}/testing + ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing ... eventFilters=${event_filters} ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions @@ -279,7 +279,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 - 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 @@ -313,7 +313,7 @@ Invoker subscribe to Service API Update ${request_body}= Create Events Subscription ... events=@{events_list} - ... notificationDestination=${MOCK_SERVER_URL}/testing + ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing ... eventFilters=${event_filters} ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions @@ -342,7 +342,7 @@ Invoker subscribe to Service API Update ## Create check Events to ensure all notifications were received ${events_expected}= Create Expected Service Update Event ${subscription_id} ${resource_url} ${service_api_description_modified} ## Check Events Expected towards received notifications at mock server - 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 @@ -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=${MOCK_SERVER_URL}/testing + ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -407,7 +407,7 @@ Provider subscribe to API Invoker events ... ${subscription_id} ... ${register_user_info_invoker['api_invoker_id']} ## Check Events Expected towards received notifications at mock server - 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 @@ -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=${MOCK_SERVER_URL}/testing + ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -491,7 +491,7 @@ Invoker subscribed to ACL update event ... ${service_api_id} ... ${api_invoker_policies} ## Check Events Expected towards received notifications at mock server - 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 @@ -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=${MOCK_SERVER_URL}/testing + ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -565,7 +565,7 @@ Provider receives an ACL unavailable event when invoker remove Security Context. ## 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 - 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 @@ -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=${MOCK_SERVER_URL}/testing + ... notificationDestination=${NOTIFICATION_DESTINATION_URL}/testing ${resp}= Post Request Capif ... /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions ... json=${request_body} @@ -649,7 +649,7 @@ 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 - Check Mock Server Notification Events ${events_expected} + Wait Until Keyword Succeeds 5x 5s Check Mock Server Notification Events ${events_expected} *** Keywords *** diff --git a/tests/features/CAPIF Api Logging Service/capif_logging_api.robot b/tests/features/CAPIF Api Logging Service/capif_logging_api.robot index 4db54b2..fc2bfca 100644 --- a/tests/features/CAPIF Api Logging Service/capif_logging_api.robot +++ b/tests/features/CAPIF Api Logging Service/capif_logging_api.robot @@ -14,7 +14,6 @@ Test Teardown Reset Testing Environment ${AEF_ID_NOT_VALID} aef-example ${SERVICE_API_ID_NOT_VALID} not-valid ${API_INVOKER_NOT_VALID} not-valid -${NOTIFICATION_DESTINATION} http://robot.testing:1080 *** Test Cases *** diff --git a/tests/features/CAPIF Security Api/capif_security_api.robot b/tests/features/CAPIF Security Api/capif_security_api.robot index f644839..e50d16a 100644 --- a/tests/features/CAPIF Security Api/capif_security_api.robot +++ b/tests/features/CAPIF Security Api/capif_security_api.robot @@ -14,7 +14,6 @@ Test Teardown Reset Testing Environment ${APF_ID_NOT_VALID} apf-example ${SERVICE_API_ID_NOT_VALID} not-valid ${API_INVOKER_NOT_VALID} not-valid -${NOTIFICATION_DESTINATION} http://robot.testing:1080 *** Test Cases *** @@ -24,7 +23,7 @@ Create a security context for an API invoker ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding # Create Security Context - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} @@ -45,7 +44,7 @@ Create a security context for an API invoker with Provider role ${register_user_info_publisher}= Provider Default Registration # Create Security Context - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} @@ -66,7 +65,7 @@ Create a security context for an API invoker with Provider entity role and inval ${register_user_info_publisher}= Provider Default Registration # Create Security Context - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID} ... json=${request_body} @@ -86,7 +85,7 @@ Create a security context for an API invoker with Invalid apiInvokerID # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID} ... json=${request_body} @@ -106,7 +105,7 @@ Retrieve the Security Context of an API Invoker # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} @@ -162,7 +161,7 @@ Retrieve the Security Context of an API Invoker with invalid apfId # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} @@ -191,7 +190,7 @@ Delete the Security Context of an API Invoker # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} @@ -231,7 +230,7 @@ Delete the Security Context of an API Invoker with Invoker entity role # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} @@ -298,7 +297,7 @@ Update the Security Context of an API Invoker # Register Provider ${register_user_info_publisher}= Provider Default Registration - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} @@ -342,7 +341,7 @@ Update the Security Context of an API Invoker with Provider entity role # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} @@ -374,7 +373,7 @@ Update the Security Context of an API Invoker with AEF entity role and invalid a # Register Provider ${register_user_info_publisher}= Provider Default Registration - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Post Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID}/update ... json=${request_body} @@ -393,7 +392,7 @@ Update the Security Context of an API Invoker with invalid apiInvokerID # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Post Request Capif ... /capif-security/v1/trustedInvokers/${API_INVOKER_NOT_VALID}/update ... json=${request_body} @@ -479,7 +478,7 @@ Revoke the authorization of the API invoker for APIs without valid apfID. # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} @@ -529,7 +528,7 @@ Revoke the authorization of the API invoker for APIs with invalid apiInvokerId # Default Invoker Registration and Onboarding ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding - ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION} + ${request_body}= Create Service Security Body ${NOTIFICATION_DESTINATION_URL} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} ... json=${request_body} @@ -595,7 +594,7 @@ Retrieve access token # create Security Context ${request_body}= Create Service Security From Discover Response - ... ${NOTIFICATION_DESTINATION} + ... ${NOTIFICATION_DESTINATION_URL} ... ${discover_response} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -648,7 +647,7 @@ Retrieve access token by Provider # create Security Context ${request_body}= Create Service Security From Discover Response - ... ${NOTIFICATION_DESTINATION} + ... ${NOTIFICATION_DESTINATION_URL} ... ${discover_response} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -700,7 +699,7 @@ Retrieve access token by Provider with invalid apiInvokerId # create Security Context ${request_body}= Create Service Security From Discover Response - ... ${NOTIFICATION_DESTINATION} + ... ${NOTIFICATION_DESTINATION_URL} ... ${discover_response} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -753,7 +752,7 @@ Retrieve access token with invalid apiInvokerId # create Security Context ${request_body}= Create Service Security From Discover Response - ... ${NOTIFICATION_DESTINATION} + ... ${NOTIFICATION_DESTINATION_URL} ... ${discover_response} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -808,7 +807,7 @@ Retrieve access token with invalid client_id # create Security Context ${request_body}= Create Service Security From Discover Response - ... ${NOTIFICATION_DESTINATION} + ... ${NOTIFICATION_DESTINATION_URL} ... ${discover_response} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -861,7 +860,7 @@ Retrieve access token with unsupported grant_type # create Security Context ${request_body}= Create Service Security From Discover Response - ... ${NOTIFICATION_DESTINATION} + ... ${NOTIFICATION_DESTINATION_URL} ... ${discover_response} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -921,7 +920,7 @@ Retrieve access token with invalid scope # create Security Context ${request_body}= Create Service Security From Discover Response - ... ${NOTIFICATION_DESTINATION} + ... ${NOTIFICATION_DESTINATION_URL} ... ${discover_response} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -976,7 +975,7 @@ Retrieve access token with invalid aefid at scope # create Security Context ${request_body}= Create Service Security From Discover Response - ... ${NOTIFICATION_DESTINATION} + ... ${NOTIFICATION_DESTINATION_URL} ... ${discover_response} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} @@ -1031,7 +1030,7 @@ Retrieve access token with invalid apiName at scope # create Security Context ${request_body}= Create Service Security From Discover Response - ... ${NOTIFICATION_DESTINATION} + ... ${NOTIFICATION_DESTINATION_URL} ... ${discover_response} ${resp}= Put Request Capif ... /capif-security/v1/trustedInvokers/${register_user_info_invoker['api_invoker_id']} diff --git a/tests/resources/common.resource b/tests/resources/common.resource index fcd9a97..0acd867 100644 --- a/tests/resources/common.resource +++ b/tests/resources/common.resource @@ -36,6 +36,7 @@ ${REGISTER_ADMIN_PASSWORD} password123 ${REQUESTS_TIMEOUT} 120s ${MOCK_SERVER_URL} +${NOTIFICATION_DESTINATION_URL} ${MOCK_SERVER_URL} ${DISCOVER_URL} /service-apis/v1/allServiceAPIs?api-invoker-id= -- GitLab