Commit 0e75c554 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

New tests related with event filter and ACL events

parent 61abfa7e
Loading
Loading
Loading
Loading
Loading
+306 −10
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ Update Security Context between ${invoker_info} and ${provider_info}


*** Test Cases ***
Service API Available filtered by apiIds
Invoker subscrived to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE_API_UPDATE events filtered by apiIds
    [Tags]    event_filter-1    mockserver

    # Initialize Mock server
@@ -269,7 +269,7 @@ Service API Available filtered by apiIds
    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}

Service API Available filtered by not valid filters
Invoker subscribed to SERVICE_API_AVAILABLE, SERVICE_API_UNAVAILABLE and SERVICE_API_UPDATE events filtered by not valid filters
    [Tags]    event_filter-2    mockserver

    # Initialize Mock server
@@ -439,7 +439,7 @@ Service API Available filtered by not valid filters
    ...    cause=Invalid eventFilter for event SERVICE_API_UPDATE
    ...    invalidParams=${invalid_param_list}

Invoker events filtered by invokerIds
Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INVOKER_UPDATED events filtered by invokerIds
    [Tags]    event_filter-3    mockserver

    # Initialize Mock server
@@ -583,7 +583,7 @@ Invoker events filtered by invokerIds
    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}

Invoker events filtered by not valid filters
Provider subscribed to API_INVOKER_ONBOARDED, API_INVOKER_OFFBOARDED and API_INVOKER_UPDATED events filtered by not valid filters
    [Tags]    event_filter-4    mockserver

    # Initialize Mock server
@@ -747,9 +747,7 @@ Invoker events filtered by not valid filters
    ...    detail=Bad Param
    ...    cause=Invalid eventFilter for event API_INVOKER_UPDATED
    ...    invalidParams=${invalid_param_list}


Invoker subscribed to ACL update event filtered by apiInvokerId
Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by only apiId, only invokerId and both
    [Tags]    event_filter-5    mockserver    smoke

    # Initialize Mock server
@@ -792,8 +790,43 @@ Invoker subscribed to ACL update event filtered by apiInvokerId
    ${event_filter_empty}=    Create Capif Event Filter
    ${event_filter_api_invoker_ids}=    Create Capif Event Filter    apiInvokerIds=${api_invoker_id_1}
    ${event_filter_api_ids}=   Create Capif Event Filter    apiIds=${service_api_id_1}
    ${event_filter_api_invoker_ids_and_api_ids}=    Create Capif Event Filter  apiInvokerIds=${api_invoker_id_1}    apiIds=${service_api_id_1}
    ${event_filter_api_invoker_ids_and_api_ids}=    Create Capif Event Filter  apiInvokerIds=${api_invoker_id_2}    apiIds=${service_api_id_2}

    # Subscription to Events 1
    ${event_filters}=   Create List    ${event_filter_api_ids}
    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=4
    ...    event_filters=${event_filters}
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions
    ...    json=${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${register_user_info_provider_1['amf_username']}

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

    # Subscription to Events 2
    ${event_filters}=   Create List    ${event_filter_api_invoker_ids_and_api_ids}
    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=4
    ...    event_filters=${event_filters}
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions
    ...    json=${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${register_user_info_provider_1['amf_username']}

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

    # Subscription to Events 3
    ${event_filters}=   Create List    ${event_filter_api_invoker_ids}
    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
@@ -807,10 +840,232 @@ Invoker subscribed to ACL update event filtered by apiInvokerId
    ...    verify=ca.crt
    ...    username=${register_user_info_provider_1['amf_username']}

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


    # Create Security Contexts and ACLs
    ${acl_provider_1}=   Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1}
    ${acl_provider_1}=   Create Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_1}

    ${acl_provider_2}=   Update Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_2}
    ${acl_provider_2}=   Update Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_2}

    # Check Event Notifications
    ## Create check Events to ensure all notifications were received
    ### Subscription 1 Checks
    ${acl_to_check}=   Create List   ${acl_provider_1[0]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_1}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}

    ${acl_to_check}=   Create List   ${acl_provider_1[1]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_1}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ${acl_to_check}=   Create List   ${acl_provider_1[0]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_1}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ${acl_to_check}=   Create List   ${acl_provider_1[1]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_1}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ### Subscription 2 checks
    ${acl_to_check}=   Create List   ${acl_provider_2[1]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_2}
    ...    ${service_api_id_2}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ### Subscription 3 checks
    ${acl_to_check}=   Create List   ${acl_provider_1[0]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_3}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ${acl_to_check}=   Create List   ${acl_provider_1[0]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_3}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ${acl_to_check}=   Create List   ${acl_provider_2[0]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_3}
    ...    ${service_api_id_2}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    Log List    ${events_expected}

    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}


Provider subscribed to ACCESS_CONTROL_POLICY_UPDATE event filtered by aefId
    [Tags]    event_filter-6     smoke

    # Initialize Mock server
    Init Mock Server

    # Register provider 1
    ${register_user_info_provider_1}=    Provider Default Registration  provider_username=${PROVIDER_USERNAME}_1
    ${aef_id_1}=    Set Variable    ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']}

    # Publish one api
    ${service_api_description_published_1}    ${provider_resource_url_1}    ${provider_request_body_1}=    Publish Service Api
    ...    ${register_user_info_provider_1}
    ...    service_name=service_1

    # Store apiId1 and apiId2
    ${service_api_id_1}=    Set Variable    ${service_api_description_published_1['apiId']}

    # Subscribe to events
    ${events_list}=    Create List    ACCESS_CONTROL_POLICY_UPDATE

    # Event filters
    ${event_filter_aef_id}=   Create Capif Event Filter  aefIds=${aef_id_1}

    # Subscription to Events 1
    ${event_filters}=   Create List    ${event_filter_aef_id}
    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=4
    ...    event_filters=${event_filters}
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions
    ...    json=${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${register_user_info_provider_1['amf_username']}

    # Check Results
    ${invalid_param}=  Create Dictionary    param=eventFilter    reason=The eventFilter {'aef_ids'} for event ACCESS_CONTROL_POLICY_UPDATE are not applicable.
    ${invalid_param_list}=   Create List    ${invalid_param}
    Check Response Variable Type And Values
    ...    ${resp}
    ...    400
    ...    ProblemDetails
    ...    title=Bad Request
    ...    status=400
    ...    detail=Bad Param
    ...    cause=Invalid eventFilter for event ACCESS_CONTROL_POLICY_UPDATE
    ...    invalidParams=${invalid_param_list}

Provider subscribed to SERVICE_API_INVOCATION_SUCCESS and SERVICE_API_INVOCATION_FAILURE filtered by apiId, invokerId, aefId and all of them
    [Tags]    event_filter-7    mockserver    smoke

    # Initialize Mock server
    Init Mock Server

    # Register provider 1
    ${register_user_info_provider_1}=    Provider Default Registration  provider_username=${PROVIDER_USERNAME}_1

    # Publish one api
    ${service_api_description_published_1}    ${provider_resource_url_1}    ${provider_request_body_1}=    Publish Service Api
    ...    ${register_user_info_provider_1}
    ...    service_name=service_1

    # Register APF
    ${register_user_info_provider_2}=    Provider Default Registration  provider_username=${PROVIDER_USERNAME}_2

    # Publish one api
    ${service_api_description_published_2}    ${provider_resource_url_2}    ${provider_request_body_2}=    Publish Service Api
    ...    ${register_user_info_provider_2}
    ...    service_name=service_2

    # Store apiId1 and apiId2
    ${service_api_id_1}=    Set Variable    ${service_api_description_published_1['apiId']}

    ${service_api_id_2}=    Set Variable    ${service_api_description_published_2['apiId']}

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

    # Register INVOKER 2
    ${register_user_info_invoker_2}    ${invoker_url_2}    ${request_body_2}=    Invoker Default Onboarding  invoke_username=${INVOKER_USERNAME}_2
    ${api_invoker_id_2}=    Set Variable    ${register_user_info_invoker_2['api_invoker_id']}


    # Subscribe to events
    ${events_list}=    Create List    ACCESS_CONTROL_POLICY_UPDATE

    # Event filters
    ${event_filter_empty}=    Create Capif Event Filter
    ${event_filter_api_invoker_ids}=    Create Capif Event Filter    apiInvokerIds=${api_invoker_id_1}
    ${event_filter_api_ids}=   Create Capif Event Filter    apiIds=${service_api_id_1}
    ${event_filter_api_invoker_ids_and_api_ids}=    Create Capif Event Filter  apiInvokerIds=${api_invoker_id_2}    apiIds=${service_api_id_2}

    # Subscription to Events 1
    ${event_filters}=   Create List    ${event_filter_api_ids}
    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=4
    ...    event_filters=${event_filters}
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions
    ...    json=${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${register_user_info_provider_1['amf_username']}

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

    # Subscription to Events 2
    ${event_filters}=   Create List    ${event_filter_api_invoker_ids_and_api_ids}
    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=4
    ...    event_filters=${event_filters}
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions
    ...    json=${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${register_user_info_provider_1['amf_username']}

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

    # Subscription to Events 3
    ${event_filters}=   Create List    ${event_filter_api_invoker_ids}
    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=4
    ...    event_filters=${event_filters}
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_provider_1['amf_id']}/subscriptions
    ...    json=${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${register_user_info_provider_1['amf_username']}

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


    # Create Security Contexts and ACLs
    ${acl_provider_1}=   Create Security Context between ${register_user_info_invoker_1} and ${register_user_info_provider_1}
    ${acl_provider_1}=   Create Security Context between ${register_user_info_invoker_2} and ${register_user_info_provider_1}

@@ -819,12 +1074,20 @@ Invoker subscribed to ACL update event filtered by apiInvokerId

    # Check Event Notifications
    ## Create check Events to ensure all notifications were received
    ### Subscription 1 Checks
    ${acl_to_check}=   Create List   ${acl_provider_1[0]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_1}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}

    ${acl_to_check}=   Create List   ${acl_provider_1[1]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_1}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ${acl_to_check}=   Create List   ${acl_provider_1[0]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_1}
@@ -832,11 +1095,44 @@ Invoker subscribed to ACL update event filtered by apiInvokerId
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ${acl_to_check}=   Create List   ${acl_provider_2[0]}
    ${acl_to_check}=   Create List   ${acl_provider_1[1]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_1}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ### Subscription 2 checks
    ${acl_to_check}=   Create List   ${acl_provider_2[1]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_2}
    ...    ${service_api_id_2}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ### Subscription 3 checks
    ${acl_to_check}=   Create List   ${acl_provider_1[0]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_3}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ${acl_to_check}=   Create List   ${acl_provider_1[0]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_3}
    ...    ${service_api_id_1}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    ${acl_to_check}=   Create List   ${acl_provider_2[0]}
    ${events_expected}=    Create Expected Access Control Policy Update Event
    ...    ${subscription_id_3}
    ...    ${service_api_id_2}
    ...    ${acl_to_check}
    ...    events_expected=${events_expected}

    Log List    ${events_expected}

    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}
 No newline at end of file