Commit 34a4bbe7 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Merge branch 'OCF122-test-plan-event-filter' into 'staging'

Resolve "Test Plan - Event Filter"

Closes #122

See merge request !107
parents 8a1f3005 5bbbb14c
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -317,6 +317,7 @@ class SecurityOperations(Resource):
                    "Service api not found with id: " + api_invoker_id)
                return not_found_error(detail="Service API not existing", cause="Not exist securiy information for this invoker")

            update_acls=list()
            for service_instance in service_security.security_info:
                if service_instance.interface_details is not None:
                    security_methods = service_instance.interface_details.security_methods
@@ -343,14 +344,22 @@ class SecurityOperations(Resource):
                        valid_security_methods) & set(pref_security_methods)
                    service_instance.sel_security_method = list(
                        valid_security_method)[0]
                update_acls.append({"api_id": service_instance.api_id, "aef_id": service_instance.aef_id})

            service_security = service_security.to_dict()
            service_security = clean_empty(service_security)

            result = mycol.find_one_and_update(old_object, {"$set": service_security}, projection={
                                               '_id': 0, "api_invoker_id": 0}, return_document=ReturnDocument.AFTER, upsert=False)
            current_app.logger.debug(
                    "Inserted security context in database")

            # result = clean_empty(result)
            for update_acl in update_acls:
                # Send service instance to ACL
                current_app.logger.debug("Sending message to create ACL")
                publish_ops.publish_message("acls-messages", "create-acl:"+str(
                    api_invoker_id)+":"+str(update_acl['api_id'])+":"+str(update_acl['aef_id']))

            current_app.logger.debug("Updated security context")

+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ export ROBOT_DOCKER_FILE_FOLDER=$CAPIF_BASE_DIR/tools/robot

# Image URL and version
export REGISTRY_BASE_URL="labs.etsi.org:5050/ocf/capif/prod"
export OCF_VERSION="v2.0.0-release"
export OCF_VERSION="v2.x.x-release"

# Capif hostname
export CAPIF_HOSTNAME=capifcore
+20 −14
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ Invoker receives Service API Invocation events
    ${events_list}=    Create List    SERVICE_API_INVOCATION_SUCCESS    SERVICE_API_INVOCATION_FAILURE
    ${aef_ids}=    Create List    ${register_user_info['aef_id']}
    ${event_filter}=    Create Capif Event Filter    aefIds=${aef_ids}
    ${event_filters}=    Create List    ${event_filter}
    ${event_filters}=    Create List    ${event_filter}  ${event_filter}

    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
@@ -240,7 +240,7 @@ Invoker subscribe to Service API Available and Unavailable events
    ${events_list}=    Create List    SERVICE_API_AVAILABLE    SERVICE_API_UNAVAILABLE
    ${aef_ids}=    Create List    ${register_user_info_provider['aef_id']}
    ${event_filter}=    Create Capif Event Filter    aefIds=${aef_ids}
    ${event_filters}=    Create List    ${event_filter}
    ${event_filters}=    Create List    ${event_filter}  ${event_filter}

    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
@@ -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}

@@ -712,7 +715,7 @@ Invoker receives Service API Invocation events without Enhanced Event Report
    ${events_list}=    Create List    SERVICE_API_INVOCATION_SUCCESS    SERVICE_API_INVOCATION_FAILURE
    ${aef_ids}=    Create List    ${register_user_info['aef_id']}
    ${event_filter}=    Create Capif Event Filter    aefIds=${aef_ids}
    ${event_filters}=    Create List    ${event_filter}
    ${event_filters}=    Create List    ${event_filter}  ${event_filter}

    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
@@ -786,7 +789,7 @@ Invoker subscribe to Service API Available and Unavailable events without Enhanc
    ${events_list}=    Create List    SERVICE_API_AVAILABLE    SERVICE_API_UNAVAILABLE
    ${aef_ids}=    Create List    ${register_user_info_provider['aef_id']}
    ${event_filter}=    Create Capif Event Filter    aefIds=${aef_ids}
    ${event_filters}=    Create List    ${event_filter}
    ${event_filters}=    Create List    ${event_filter}  ${event_filter}

    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
@@ -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}
+2 −0
Original line number Diff line number Diff line
*** Settings ***
Force Tags    event_filter
 No newline at end of file
+1012 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading