Loading tests/features/CAPIF Api Events/capif_events_api.robot +210 −202 Original line number Diff line number Diff line Loading @@ -142,9 +142,8 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriptionId Invoker receives Service API Invocation events [Tags] capif_api_events-6 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info}= Provider Default Registration Loading Loading @@ -203,33 +202,19 @@ Invoker receives Service API Invocation events Check Response Variable Type And Values ${resp} 201 InvocationLog ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification # Create check Events to ensure all notifications were received ${check_events} ${check_events_length}= Create Events From InvocationLogs # Check Event Notifications ## Create check Events to ensure all notifications were received ${events_expected}= Create Events From InvocationLogs ... ${subscription_id} ... ${request_body} # Number of events received must be equal than events expected Length Should Be ${notification_events_on_mock_server} ${check_events_length} # Check if events received are the same than expected FOR ${event} IN @{check_events} Log ${event} List Should Contain Value ${notification_events_on_mock_server} ${event} END ## Check Events Expected towards received notifications at mock server Check Mock Server Notification Events ${events_expected} Invoker subscribe to Service API Available and Unavailable events [Tags] capif_api_events-7 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading Loading @@ -284,41 +269,22 @@ Invoker subscribe to Service API Available and Unavailable events Status Should Be 204 ${resp} # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification # Create Notification Events expected to be received ${api_id_1}= Fetch From Right ${resource_url_1.path} / ${notification_event_expected_removed}= Create Notification Event ... ${subscription_id} ... SERVICE_API_UNAVAILABLE ... apiIds=${api_id_1} Check Variable ${notification_event_expected_removed} EventNotification ${api_id_2}= Fetch From Right ${resource_url_2.path} / ${notification_event_expected_created}= Create Notification Event ... ${subscription_id} ... SERVICE_API_AVAILABLE ... apiIds=${api_id_2} Check Variable ${notification_event_expected_created} EventNotification # Check results Length Should Be ${notification_events_on_mock_server} 2 List Should Contain Value ${notification_events_on_mock_server} ${notification_event_expected_removed} List Should Contain Value ${notification_events_on_mock_server} ${notification_event_expected_created} # 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} ## Check Events Expected towards received notifications at mock server Check Mock Server Notification Events ${events_expected} Invoker subscribe to Service API Update [Tags] capif_api_events-8 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading Loading @@ -360,10 +326,10 @@ Invoker subscribe to Service API Update ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} # Update Service API ${request_body_modified}= Create Service Api Description service_1_modified ${service_api_description_modified}= Create Service Api Description service_1_modified ${resp}= Put Request Capif ... ${resource_url.path} ... json=${request_body_modified} ... json=${service_api_description_modified} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${APF_PROVIDER_USERNAME} Loading @@ -371,33 +337,17 @@ Invoker subscribe to Service API Update Check Response Variable Type And Values ${resp} 200 ServiceAPIDescription ... apiName=service_1_modified # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification # Create Notification Events expected to be received ${api_id}= Fetch From Right ${resource_url.path} / Set To Dictionary ${request_body_modified} apiId=${api_id} ${notification_event_expected}= Create Notification Event ... ${subscription_id} ... SERVICE_API_UPDATE ... serviceAPIDescriptions=${request_body_modified} Check Variable ${notification_event_expected} EventNotification # Check results Length Should Be ${notification_events_on_mock_server} 1 List Should Contain Value ${notification_events_on_mock_server} ${notification_event_expected} # 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} ## Check Events Expected towards received notifications at mock server Check Mock Server Notification Events ${events_expected} Provider subscribe to API Invoker events [Tags] capif_api_events-9 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading Loading @@ -450,54 +400,19 @@ Provider subscribe to API Invoker events # Check Remove Should Be Equal As Strings ${resp.status_code} 204 # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification ## Create events expected ${events_expected}= Create List ${api_invoker_id}= Set Variable ${register_user_info_invoker['api_invoker_id']} # Create Notification Events expected to be received for Onboard event ${event_expected}= Create Notification Event ... ${subscription_id} ... API_INVOKER_ONBOARDED ... apiInvokerIds=${api_invoker_id} 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} Append To List ${events_expected} ${event_expected} # Create Notification Events expected to be received for Offboard event ${event_expected}= Create Notification Event # Check Event Notifications ## Create check Events to ensure all notifications were received ${events_expected}= Create Expected Api Invoker Events ... ${subscription_id} ... API_INVOKER_OFFBOARDED ... apiInvokerIds=${api_invoker_id} Append To List ${events_expected} ${event_expected} Check Variable ${events_expected} EventNotification # Check results ${events_expected_length}= Get Length ${events_expected} Length Should Be ${notification_events_on_mock_server} ${events_expected_length} FOR ${event_expected} IN @{events_expected} Log ${event_expected} List Should Contain Value ${notification_events_on_mock_server} ${event_expected} END ... ${register_user_info_invoker['api_invoker_id']} ## Check Events Expected towards received notifications at mock server Check Mock Server Notification Events ${events_expected} Invoker subscribed to ACL update event [Tags] capif_api_events-10 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading @@ -507,7 +422,7 @@ Invoker subscribed to ACL update event ... ${register_user_info_provider} # Store apiId1 ${serviceApiId}= Set Variable ${service_api_description_published['apiId']} ${service_api_id}= Set Variable ${service_api_description_published['apiId']} # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Loading @@ -528,7 +443,6 @@ Invoker subscribed to ACL update event 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']} Loading @@ -554,7 +468,7 @@ Invoker subscribed to ACL update event ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} ${resp}= Get Request Capif ... /access-control-policy/v1/accessControlPolicyList/${serviceApiId}?aef-id=${register_user_info_provider['aef_id']} ... /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} Loading @@ -569,40 +483,20 @@ Invoker subscribed to ACL update event ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} ## Create events expected ${acc_ctrl_pol_list}= Create Dictionary apiId=${serviceApiId} apiInvokerPolicies=${api_invoker_policies} Check Variable ${acc_ctrl_pol_list} AccessControlPolicyListExt ${events_expected}= Create List ${event_expected}= Create Notification Event # Check Event Notifications ## Create check Events to ensure all notifications were received ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id} ... ACCESS_CONTROL_POLICY_UPDATE ... accCtrlPolList=${acc_ctrl_pol_list} Append To List ${events_expected} ${event_expected} Check Variable ${events_expected} EventNotification # Check results ${events_expected_length}= Get Length ${events_expected} Length Should Be ${notification_events_on_mock_server} ${events_expected_length} FOR ${event_expected} IN @{events_expected} Log ${event_expected} List Should Contain Value ${notification_events_on_mock_server} ${event_expected} END ... ${service_api_id} ... ${api_invoker_policies} ## Check Events Expected towards received notifications at mock server Check Mock Server Notification Events ${events_expected} Provider receives an ACL unavailable event when invoker remove Security Context. [Tags] capif_api_events-11 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading Loading @@ -633,7 +527,6 @@ Provider receives an ACL unavailable event when invoker remove Security Context. 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']} Loading Loading @@ -667,34 +560,17 @@ Provider receives an ACL unavailable event when invoker remove Security Context. Status Should Be 204 ${resp} # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} ## Create events expected ${events_expected}= Create List ${event_expected}= Create Notification Event ... ${subscription_id} ... ACCESS_CONTROL_POLICY_UNAVAILABLE Append To List ${events_expected} ${event_expected} Check Variable ${events_expected} EventNotification # Check results ${events_expected_length}= Get Length ${events_expected} Length Should Be ${notification_events_on_mock_server} ${events_expected_length} FOR ${event_expected} IN @{events_expected} Log ${event_expected} List Should Contain Value ${notification_events_on_mock_server} ${event_expected} END # 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 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 # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading Loading @@ -765,30 +641,162 @@ Invoker receives an Invoker Authorization Revoked and ACL unavailable event when # Check Results Status Should Be 204 ${resp} # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # 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 Check Mock Server Notification Events ${events_expected} *** Keywords *** Create Events From InvocationLogs [Arguments] ${subscription_id} ${invocation_log} ${events_expected}=${NONE} 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} ${event_expected}= Create Notification Event ${subscription_id} ${event_enum} invocationLogs=${invocation_logs} Append To List ${events_expected} ${event_expected} END RETURN ${events_expected} Create Expected Events For Service API Notifications [Arguments] ... ${subscription_id} ... ${service_api_available_resources}=${NONE} ... ${service_api_unavailable_resources}=${NONE} ... ${events_expected}=${NONE} IF ${events_expected} == ${NONE} ${events_expected}= Create List END FOR ${service_api_available_resource} IN @{service_api_available_resources} Log ${service_api_available_resource} ${api_id}= Fetch From Right ${service_api_available_resource.path} / ${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} / ${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} IF ${events_expected} == ${NONE} ${events_expected}= Create List 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} 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} 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} 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} 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 ${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 ## ACCESS_CONTROL_POLICY_UNAVAILABLE event END ${event_expected}= Create Notification Event ... ${subscription_id} ... ACCESS_CONTROL_POLICY_UNAVAILABLE Append To List ${events_expected} ${event_expected} ## API_INVOKER_AUTHORIZATION_REVOKED event 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} Check Variable ${events_expected} EventNotification # Check results ${events_expected_length}= Get Length ${events_expected} Length Should Be ${notification_events_on_mock_server} ${events_expected_length} FOR ${event_expected} IN @{events_expected} Log ${event_expected} List Should Contain Value ${notification_events_on_mock_server} ${event_expected} RETURN ${events_expected} Create Expected Service Update Event [Arguments] ${subscription_id} ${service_api_resource} ${service_api_descriptions} ${events_expected}=${NONE} 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} ${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 tests/resources/common.resource +24 −1 Original line number Diff line number Diff line Loading @@ -91,6 +91,10 @@ Test ${TEST NAME} Currently Not Supported Log Test "${TEST NAME}" Currently not supported WARN Skip Test "${TEST NAME}" Currently not supported Init Mock Server Check Mock Server Clean Mock Server Check Mock Server Log Checking mock Server for Robot Framework. Loading Loading @@ -142,3 +146,22 @@ Get Mock Server Messages Status Should Be 200 ${resp} Log List ${resp.json()} RETURN ${resp} Check Mock Server Notification Events [Arguments] ${events_expected} Check Variable ${events_expected} EventNotification # Check results ${events_expected_length}= Get Length ${events_expected} Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} Check Variable ${notification_events_on_mock_server} EventNotification Length Should Be ${notification_events_on_mock_server} ${events_expected_length} FOR ${event_expected} IN @{events_expected} Log ${event_expected} List Should Contain Value ${notification_events_on_mock_server} ${event_expected} END No newline at end of file tests/resources/common/basicRequests.robot +0 −36 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
tests/features/CAPIF Api Events/capif_events_api.robot +210 −202 Original line number Diff line number Diff line Loading @@ -142,9 +142,8 @@ Deletes an individual CAPIF Event Subscription with invalid SubscriptionId Invoker receives Service API Invocation events [Tags] capif_api_events-6 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info}= Provider Default Registration Loading Loading @@ -203,33 +202,19 @@ Invoker receives Service API Invocation events Check Response Variable Type And Values ${resp} 201 InvocationLog ${resource_url}= Check Location Header ${resp} ${LOCATION_LOGGING_RESOURCE_REGEX} Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification # Create check Events to ensure all notifications were received ${check_events} ${check_events_length}= Create Events From InvocationLogs # Check Event Notifications ## Create check Events to ensure all notifications were received ${events_expected}= Create Events From InvocationLogs ... ${subscription_id} ... ${request_body} # Number of events received must be equal than events expected Length Should Be ${notification_events_on_mock_server} ${check_events_length} # Check if events received are the same than expected FOR ${event} IN @{check_events} Log ${event} List Should Contain Value ${notification_events_on_mock_server} ${event} END ## Check Events Expected towards received notifications at mock server Check Mock Server Notification Events ${events_expected} Invoker subscribe to Service API Available and Unavailable events [Tags] capif_api_events-7 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading Loading @@ -284,41 +269,22 @@ Invoker subscribe to Service API Available and Unavailable events Status Should Be 204 ${resp} # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification # Create Notification Events expected to be received ${api_id_1}= Fetch From Right ${resource_url_1.path} / ${notification_event_expected_removed}= Create Notification Event ... ${subscription_id} ... SERVICE_API_UNAVAILABLE ... apiIds=${api_id_1} Check Variable ${notification_event_expected_removed} EventNotification ${api_id_2}= Fetch From Right ${resource_url_2.path} / ${notification_event_expected_created}= Create Notification Event ... ${subscription_id} ... SERVICE_API_AVAILABLE ... apiIds=${api_id_2} Check Variable ${notification_event_expected_created} EventNotification # Check results Length Should Be ${notification_events_on_mock_server} 2 List Should Contain Value ${notification_events_on_mock_server} ${notification_event_expected_removed} List Should Contain Value ${notification_events_on_mock_server} ${notification_event_expected_created} # 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} ## Check Events Expected towards received notifications at mock server Check Mock Server Notification Events ${events_expected} Invoker subscribe to Service API Update [Tags] capif_api_events-8 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading Loading @@ -360,10 +326,10 @@ Invoker subscribe to Service API Update ${subscriber_id} ${subscription_id}= Check Event Location Header ${resp} # Update Service API ${request_body_modified}= Create Service Api Description service_1_modified ${service_api_description_modified}= Create Service Api Description service_1_modified ${resp}= Put Request Capif ... ${resource_url.path} ... json=${request_body_modified} ... json=${service_api_description_modified} ... server=${CAPIF_HTTPS_URL} ... verify=ca.crt ... username=${APF_PROVIDER_USERNAME} Loading @@ -371,33 +337,17 @@ Invoker subscribe to Service API Update Check Response Variable Type And Values ${resp} 200 ServiceAPIDescription ... apiName=service_1_modified # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification # Create Notification Events expected to be received ${api_id}= Fetch From Right ${resource_url.path} / Set To Dictionary ${request_body_modified} apiId=${api_id} ${notification_event_expected}= Create Notification Event ... ${subscription_id} ... SERVICE_API_UPDATE ... serviceAPIDescriptions=${request_body_modified} Check Variable ${notification_event_expected} EventNotification # Check results Length Should Be ${notification_events_on_mock_server} 1 List Should Contain Value ${notification_events_on_mock_server} ${notification_event_expected} # 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} ## Check Events Expected towards received notifications at mock server Check Mock Server Notification Events ${events_expected} Provider subscribe to API Invoker events [Tags] capif_api_events-9 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading Loading @@ -450,54 +400,19 @@ Provider subscribe to API Invoker events # Check Remove Should Be Equal As Strings ${resp.status_code} 204 # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # Check if message follow EventNotification definition. Check Variable ${notification_events_on_mock_server} EventNotification ## Create events expected ${events_expected}= Create List ${api_invoker_id}= Set Variable ${register_user_info_invoker['api_invoker_id']} # Create Notification Events expected to be received for Onboard event ${event_expected}= Create Notification Event ... ${subscription_id} ... API_INVOKER_ONBOARDED ... apiInvokerIds=${api_invoker_id} 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} Append To List ${events_expected} ${event_expected} # Create Notification Events expected to be received for Offboard event ${event_expected}= Create Notification Event # Check Event Notifications ## Create check Events to ensure all notifications were received ${events_expected}= Create Expected Api Invoker Events ... ${subscription_id} ... API_INVOKER_OFFBOARDED ... apiInvokerIds=${api_invoker_id} Append To List ${events_expected} ${event_expected} Check Variable ${events_expected} EventNotification # Check results ${events_expected_length}= Get Length ${events_expected} Length Should Be ${notification_events_on_mock_server} ${events_expected_length} FOR ${event_expected} IN @{events_expected} Log ${event_expected} List Should Contain Value ${notification_events_on_mock_server} ${event_expected} END ... ${register_user_info_invoker['api_invoker_id']} ## Check Events Expected towards received notifications at mock server Check Mock Server Notification Events ${events_expected} Invoker subscribed to ACL update event [Tags] capif_api_events-10 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading @@ -507,7 +422,7 @@ Invoker subscribed to ACL update event ... ${register_user_info_provider} # Store apiId1 ${serviceApiId}= Set Variable ${service_api_description_published['apiId']} ${service_api_id}= Set Variable ${service_api_description_published['apiId']} # Register INVOKER ${register_user_info_invoker} ${url} ${request_body}= Invoker Default Onboarding Loading @@ -528,7 +443,6 @@ Invoker subscribed to ACL update event 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']} Loading @@ -554,7 +468,7 @@ Invoker subscribed to ACL update event ${resource_url}= Check Location Header ${resp} ${LOCATION_SECURITY_RESOURCE_REGEX} ${resp}= Get Request Capif ... /access-control-policy/v1/accessControlPolicyList/${serviceApiId}?aef-id=${register_user_info_provider['aef_id']} ... /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} Loading @@ -569,40 +483,20 @@ Invoker subscribed to ACL update event ${api_invoker_policies}= Set Variable ${resp.json()['apiInvokerPolicies']} # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} ## Create events expected ${acc_ctrl_pol_list}= Create Dictionary apiId=${serviceApiId} apiInvokerPolicies=${api_invoker_policies} Check Variable ${acc_ctrl_pol_list} AccessControlPolicyListExt ${events_expected}= Create List ${event_expected}= Create Notification Event # Check Event Notifications ## Create check Events to ensure all notifications were received ${events_expected}= Create Expected Access Control Policy Update Event ... ${subscription_id} ... ACCESS_CONTROL_POLICY_UPDATE ... accCtrlPolList=${acc_ctrl_pol_list} Append To List ${events_expected} ${event_expected} Check Variable ${events_expected} EventNotification # Check results ${events_expected_length}= Get Length ${events_expected} Length Should Be ${notification_events_on_mock_server} ${events_expected_length} FOR ${event_expected} IN @{events_expected} Log ${event_expected} List Should Contain Value ${notification_events_on_mock_server} ${event_expected} END ... ${service_api_id} ... ${api_invoker_policies} ## Check Events Expected towards received notifications at mock server Check Mock Server Notification Events ${events_expected} Provider receives an ACL unavailable event when invoker remove Security Context. [Tags] capif_api_events-11 mockserver # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading Loading @@ -633,7 +527,6 @@ Provider receives an ACL unavailable event when invoker remove Security Context. 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']} Loading Loading @@ -667,34 +560,17 @@ Provider receives an ACL unavailable event when invoker remove Security Context. Status Should Be 204 ${resp} # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} ## Create events expected ${events_expected}= Create List ${event_expected}= Create Notification Event ... ${subscription_id} ... ACCESS_CONTROL_POLICY_UNAVAILABLE Append To List ${events_expected} ${event_expected} Check Variable ${events_expected} EventNotification # Check results ${events_expected_length}= Get Length ${events_expected} Length Should Be ${notification_events_on_mock_server} ${events_expected_length} FOR ${event_expected} IN @{events_expected} Log ${event_expected} List Should Contain Value ${notification_events_on_mock_server} ${event_expected} END # 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 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 # Start Mock server Check Mock Server Clean Mock Server # Initialize Mock server Init Mock Server # Register APF ${register_user_info_provider}= Provider Default Registration Loading Loading @@ -765,30 +641,162 @@ Invoker receives an Invoker Authorization Revoked and ACL unavailable event when # Check Results Status Should Be 204 ${resp} # Check Results Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} # 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 Check Mock Server Notification Events ${events_expected} *** Keywords *** Create Events From InvocationLogs [Arguments] ${subscription_id} ${invocation_log} ${events_expected}=${NONE} 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} ${event_expected}= Create Notification Event ${subscription_id} ${event_enum} invocationLogs=${invocation_logs} Append To List ${events_expected} ${event_expected} END RETURN ${events_expected} Create Expected Events For Service API Notifications [Arguments] ... ${subscription_id} ... ${service_api_available_resources}=${NONE} ... ${service_api_unavailable_resources}=${NONE} ... ${events_expected}=${NONE} IF ${events_expected} == ${NONE} ${events_expected}= Create List END FOR ${service_api_available_resource} IN @{service_api_available_resources} Log ${service_api_available_resource} ${api_id}= Fetch From Right ${service_api_available_resource.path} / ${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} / ${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} IF ${events_expected} == ${NONE} ${events_expected}= Create List 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} 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} 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} 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} 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 ${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 ## ACCESS_CONTROL_POLICY_UNAVAILABLE event END ${event_expected}= Create Notification Event ... ${subscription_id} ... ACCESS_CONTROL_POLICY_UNAVAILABLE Append To List ${events_expected} ${event_expected} ## API_INVOKER_AUTHORIZATION_REVOKED event 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} Check Variable ${events_expected} EventNotification # Check results ${events_expected_length}= Get Length ${events_expected} Length Should Be ${notification_events_on_mock_server} ${events_expected_length} FOR ${event_expected} IN @{events_expected} Log ${event_expected} List Should Contain Value ${notification_events_on_mock_server} ${event_expected} RETURN ${events_expected} Create Expected Service Update Event [Arguments] ${subscription_id} ${service_api_resource} ${service_api_descriptions} ${events_expected}=${NONE} 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} ${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
tests/resources/common.resource +24 −1 Original line number Diff line number Diff line Loading @@ -91,6 +91,10 @@ Test ${TEST NAME} Currently Not Supported Log Test "${TEST NAME}" Currently not supported WARN Skip Test "${TEST NAME}" Currently not supported Init Mock Server Check Mock Server Clean Mock Server Check Mock Server Log Checking mock Server for Robot Framework. Loading Loading @@ -142,3 +146,22 @@ Get Mock Server Messages Status Should Be 200 ${resp} Log List ${resp.json()} RETURN ${resp} Check Mock Server Notification Events [Arguments] ${events_expected} Check Variable ${events_expected} EventNotification # Check results ${events_expected_length}= Get Length ${events_expected} Sleep 3s # Get from Mock server the EventNotification Messages sent to callback setup on event subscription. ${resp}= Get Mock Server Messages ${notification_events_on_mock_server}= Set Variable ${resp.json()} Check Variable ${notification_events_on_mock_server} EventNotification Length Should Be ${notification_events_on_mock_server} ${events_expected_length} FOR ${event_expected} IN @{events_expected} Log ${event_expected} List Should Contain Value ${notification_events_on_mock_server} ${event_expected} END No newline at end of file
tests/resources/common/basicRequests.robot +0 −36 File changed.Preview size limit exceeded, changes collapsed. Show changes