Commit 404084e8 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Upgrade invoker expected messages and new tests at event filter feature

parent f20eedd9
Loading
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -378,7 +378,7 @@ Provider subscribe to API Invoker events
    ${subscriber_id}    ${subscription_id}=    Check Event Location Header    ${resp}

    # Register INVOKER
    ${register_user_info_invoker}    ${url}    ${request_body}=    Invoker Default Onboarding
    ${register_user_info_invoker}    ${invoker_url}    ${request_body}=    Invoker Default Onboarding

    # Update Invoker onboarded information
    ${new_notification_destination}=    Set Variable
@@ -387,7 +387,7 @@ Provider subscribe to API Invoker events
    ...    ${request_body}
    ...    notificationDestination=${new_notification_destination}
    ${resp}=    Put Request Capif
    ...    ${url.path}
    ...    ${invoker_url.path}
    ...    ${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
@@ -399,21 +399,24 @@ Provider subscribe to API Invoker events

    # Remove Invoker from CCF
    ${resp}=    Delete Request Capif
    ...    ${url.path}
    ...    ${invoker_url.path}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}

    Call Method    ${CAPIF_USERS}    remove_capif_users_entry    ${url.path}
    Call Method    ${CAPIF_USERS}    remove_capif_users_entry    ${invoker_url.path}

    # Check Remove
    Should Be Equal As Strings    ${resp.status_code}    204

    # Check Event Notifications
    ## Create check Events to ensure all notifications were received
    ${invoker_urls}=    Create List    ${invoker_url}
    ${events_expected}=    Create Expected Api Invoker Events
    ...    ${subscription_id}
    ...    ${register_user_info_invoker['api_invoker_id']}
    ...    api_invoker_onboarded_resources=${invoker_urls}
    ...    api_invoker_updated_resources=${invoker_urls}
    ...    api_invoker_offboarded_resources=${invoker_urls}
    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}

@@ -718,7 +721,7 @@ Invoker receives Service API Invocation events without Enhanced Event Report
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    event_filters=${event_filters}
    ...    supported_features=0
    ...    supported_features=4
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_invoker['api_invoker_id']}/subscriptions
    ...    json=${request_body}
@@ -925,7 +928,7 @@ Provider subscribe to API Invoker events without Enhanced Event Report
    ${subscriber_id}    ${subscription_id}=    Check Event Location Header    ${resp}

    # Register INVOKER
    ${register_user_info_invoker}    ${url}    ${request_body}=    Invoker Default Onboarding
    ${register_user_info_invoker}    ${invoker_url}    ${request_body}=    Invoker Default Onboarding

    # Update Invoker onboarded information
    ${new_notification_destination}=    Set Variable
@@ -934,7 +937,7 @@ Provider subscribe to API Invoker events without Enhanced Event Report
    ...    ${request_body}
    ...    notificationDestination=${new_notification_destination}
    ${resp}=    Put Request Capif
    ...    ${url.path}
    ...    ${invoker_url.path}
    ...    ${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
@@ -946,21 +949,24 @@ Provider subscribe to API Invoker events without Enhanced Event Report

    # Remove Invoker from CCF
    ${resp}=    Delete Request Capif
    ...    ${url.path}
    ...    ${invoker_url.path}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}

    Call Method    ${CAPIF_USERS}    remove_capif_users_entry    ${url.path}
    Call Method    ${CAPIF_USERS}    remove_capif_users_entry    ${invoker_url.path}

    # Check Remove
    Should Be Equal As Strings    ${resp.status_code}    204

    # Check Event Notifications
    ## Create check Events to ensure all notifications were received
    ${invoker_urls}=    Create List    ${invoker_url}
    ${events_expected}=    Create Expected Api Invoker Events
    ...    ${subscription_id}
    ...    ${register_user_info_invoker['api_invoker_id']}
    ...    api_invoker_onboarded_resources=${invoker_urls}
    ...    api_invoker_updated_resources=${invoker_urls}
    ...    api_invoker_offboarded_resources=${invoker_urls}
    ...    event_detail_expected=${FALSE}
    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}
+139 −1
Original line number Diff line number Diff line
@@ -162,7 +162,145 @@ Service API Available filtered by apiIds
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}


Try error
Invoker events filtered by invokerIds
    [Tags]    event_filter-3    mockserver

    # Initialize Mock server
    Init Mock Server

    # Register APF
    ${register_user_info_provider}=    Provider Default Registration    total_aef_roles=2

    ${aef_id_1}=    Set Variable    ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']}
    ${aef_id_2}=    Set Variable    ${register_user_info_provider['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']}
    ${aef_ids}=    Create List    ${aef_id_1}    ${aef_id_2}
    ${aef_empty_list}=    Create List

    # Publish api with 2 aefIds
    ${service_api_description_published}    ${resource_url}    ${request_body}=    Publish Service Api
    ...    ${register_user_info_provider}
    ...    service_1
    ...    aef_id=${aef_ids}
    ...    api_status=${aef_empty_list}
    ...    supported_features=020

    # Subscribe to events
    ${events_list}=    Create List    API_INVOKER_ONBOARDED
    ${event_filter}=    Create Capif Event Filter
    ${event_filters}=    Create List    ${event_filter}

    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=C
    ...    event_filters=${event_filters}
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions
    ...    json=${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${AMF_PROVIDER_USERNAME}

    # Check Results
    Check Response Variable Type And Values    ${resp}    201    EventSubscription
    ${subscriber_id}    ${subscription_id}=    Check Event Location Header    ${resp}

    # Default Invoker Registration and Onboarding
    ${register_user_info_invoker_1}    ${invoker_url_1}    ${request_body_1}=    Invoker Default Onboarding  invoker_username=${INVOKER_USERNAME}_1
    ${api_invoker_id_1}=   Set Variable    ${register_user_info_invoker_1['api_invoker_id']}

    # Default Invoker Registration and Onboarding
    ${register_user_info_invoker_2}    ${invoker_url_2}    ${request_body_2}=    Invoker Default Onboarding  invoker_username=${INVOKER_USERNAME}_1
    ${api_invoker_id_2}=   Set Variable    ${register_user_info_invoker_2['api_invoker_id']}

    # Subscribe to events
    ${events_list}=    Create List    API_INVOKER_ONBOARDED   API_INVOKER_OFFBOARDED  API_INVOKER_UPDATED
    ${event_filter_empty}=    Create Capif Event Filter
    ${event_filter_invoker_id_1}=    Create Capif Event Filter    apiInvokersIds=${api_invoker_id_1}
    ${event_filters}=    Create List    ${event_filter_empty}    ${event_filter_invoker_id_1}    ${event_filter_invoker_id_1}

    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=C
    ...    event_filters=${event_filters}
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_provider['amf_id']}/subscriptions
    ...    json=${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}

    # Check Results
    Check Response Variable Type And Values    ${resp}    201    EventSubscription
    ${subscriber_id}    ${subscription_id}=    Check Event Location Header    ${resp}

    # Update Invokers
    ## Update Invoker 1
    ${new_notification_destination}=    Set Variable
    ...    http://${CAPIF_CALLBACK_IP}:${CAPIF_CALLBACK_PORT}/netapp_new_callback_1
    Set To Dictionary
    ...    ${request_body}
    ...    notificationDestination=${new_notification_destination}
    ${resp}=    Put Request Capif
    ...    ${invoker_url_1.path}
    ...    ${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}_1
    Check Response Variable Type And Values    ${resp}    200    APIInvokerEnrolmentDetails
    ...    notificationDestination=${new_notification_destination}

    ## Update Invoker 1
    ${new_notification_destination}=    Set Variable
    ...    http://${CAPIF_CALLBACK_IP}:${CAPIF_CALLBACK_PORT}/netapp_new_callback_2
    Set To Dictionary
    ...    ${request_body}
    ...    notificationDestination=${new_notification_destination}
    ${resp}=    Put Request Capif
    ...    ${invoker_url_2.path}
    ...    ${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}_2
    Check Response Variable Type And Values    ${resp}    200    APIInvokerEnrolmentDetails
    ...    notificationDestination=${new_notification_destination}

    # Remove invokers
    ## Remove Invoker 1
    ${resp}=    Delete Request Capif
    ...    ${invoker_url_1.path}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}_1
    Call Method    ${CAPIF_USERS}    remove_capif_users_entry    ${invoker_url_1.path}
    Should Be Equal As Strings    ${resp.status_code}    204

    ## Remove Invoker 2
    ${resp}=    Delete Request Capif
    ...    ${invoker_url_2.path}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}_2
    Call Method    ${CAPIF_USERS}    remove_capif_users_entry    ${invoker_url_2.path}
    Should Be Equal As Strings    ${resp.status_code}    204

    # Check Event Notifications
    ## Create check Events to ensure all notifications were received
    ${invoker_urls}=    Create List    ${invoker_url_1}
    ${empty_list}=    Create List
    ${events_expected}=    Create Expected Api Invoker Events
    ...    ${subscription_id}
    ...    api_invoker_onboarded_resources=${empty_list}
    ...    api_invoker_updated_resources=${invoker_url}
    ...    api_invoker_offboarded_resources=${invoker_url}
    ...    event_detail_expected=${FALSE}
    Log List    ${events_expected}
    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}


Service API Available filtered by aefIds
    [Tags]    event_filter-2    mockserver

    # Initialize Mock server
+52 −22
Original line number Diff line number Diff line
@@ -113,7 +113,9 @@ Create Expected Events For Service API Notifications
Create Expected Api Invoker Events
    [Arguments]
    ...    ${subscription_id}
    ...    ${api_invoker_id}
    ...    ${api_invoker_onboarded_resources}=${NONE}
    ...    ${api_invoker_updated_resources}=${NONE}
    ...    ${api_invoker_offboarded_resources}=${NONE}
    ...    ${events_expected}=${NONE}
    ...    ${event_detail_expected}=${TRUE}

@@ -121,31 +123,59 @@ Create Expected Api Invoker Events
        ${events_expected}=    Create List
    END

    ${api_invoker_id_used}=    Set Variable    ${api_invoker_id}
    # Create Notification Events expected to be received for Onboarded event
    IF   "${api_invoker_onboarded_resources}" != "${NONE}"
        FOR    ${api_invoker_onboarded_resource}    IN    @{api_invoker_onboarded_resources}
            Log    ${api_invoker_onboarded_resource}
            ${api_invoker_id}=    Fetch From Right    ${api_invoker_onboarded_resource.path}    /

            IF    "${event_detail_expected}" != "${TRUE}"
        ${api_invoker_id_used}=    Set Variable    ${NONE}
                ${api_invoker_id}=    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}
            ...    apiInvokerIds=${api_invoker_id}
            Append To List    ${events_expected}    ${event_expected}
        END
    END

    # Create Notification Events expected to be received for Updated event
    IF   "${api_invoker_updated_resources}" != "${NONE}"
        FOR    ${api_invoker_updated_resource}    IN    @{api_invoker_updated_resources}
            Log    ${api_invoker_updated_resource}
            ${api_invoker_id}=    Fetch From Right    ${api_invoker_updated_resource.path}    /

            IF    "${event_detail_expected}" != "${TRUE}"
                ${api_invoker_id}=    Set Variable    ${NONE}
            END

            ${event_expected}=    Create Notification Event
            ...    ${subscription_id}
            ...    API_INVOKER_UPDATED
    ...    apiInvokerIds=${api_invoker_id_used}
            ...    apiInvokerIds=${api_invoker_id}
            Append To List    ${events_expected}    ${event_expected}
        END
    END

    # Create Notification Events expected to be received for Offboarded event
    IF   "${api_invoker_offboarded_resources}" != "${NONE}"
        FOR    ${api_invoker_offboarded_resource}    IN    @{api_invoker_offboarded_resources}
            Log    ${api_invoker_offboarded_resource}
            ${api_invoker_id}=    Fetch From Right    ${api_invoker_offboarded_resource.path}    /

            IF    "${event_detail_expected}" != "${TRUE}"
                ${api_invoker_id}=    Set Variable    ${NONE}
            END

    # 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}
            ...    apiInvokerIds=${api_invoker_id}
            Append To List    ${events_expected}    ${event_expected}
        END
    END

    RETURN    ${events_expected}