Commit c4f424f7 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Merge branch 'OCF91-create-robot-test-for-apistatus' into 'staging'

Resolve "Create Robot Test for ApiStatus"

Closes #91

See merge request !82
parents ee40d3de 885c0a53
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
*** Settings ***
*** Settings ***

Force Tags    api_status
Library         String
 No newline at end of file
+320 −0
Original line number Original line Diff line number Diff line
*** Settings ***
Resource            /opt/robot-tests/tests/resources/common.resource
Library             /opt/robot-tests/tests/libraries/bodyRequests.py
Library             XML
Library             String
Resource            /opt/robot-tests/tests/resources/common/basicRequests.robot
Resource            ../../resources/common.resource

Suite Teardown      Reset Testing Environment
Test Setup          Reset Testing Environment
Test Teardown       Reset Testing Environment


*** Variables ***
${API_INVOKER_NOT_REGISTERED}       not-valid
${SUBSCRIBER_ID_NOT_VALID}          not-valid
${SUBSCRIPTION_ID_NOT_VALID}        not-valid


*** Test Cases ***
Publish without apiStatus feature receive eventDetails with serviceAPIDescription
    [Tags]    api_status-1    mockserver    smoke

    # Initialize Mock server
    Init Mock Server

    # Default Invoker Registration and Onboarding
    ${register_user_info_invoker}    ${url}    ${request_body}=    Invoker Default Onboarding

    # 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}

    # Subscribe to events
    ${events_list}=    Create List    SERVICE_API_AVAILABLE    SERVICE_API_UNAVAILABLE

    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=C
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_invoker['api_invoker_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}

    # 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}

    # Discover APIs by invoker
    ${resp}=    Get Request Capif
    ...    ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${aef_id_1}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}

    Check Response Variable Type And Values    ${resp}    200    DiscoveredAPIs

    # Check Results
    Dictionary Should Contain Key    ${resp.json()}    serviceAPIDescriptions
    Should Not Be Empty    ${resp.json()['serviceAPIDescriptions']}
    Length Should Be    ${resp.json()['serviceAPIDescriptions']}    1
    List Should Contain Value    ${resp.json()['serviceAPIDescriptions']}    ${service_api_description_published}

    # Provider Remove service_1 published API
    ${resp}=    Delete Request Capif
    ...    ${resource_url.path}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${APF_PROVIDER_USERNAME}

    Status Should Be    204    ${resp}

    # Check Event Notifications
    ## Create check Events to ensure all notifications were received
    ${service_api_available_resources}=    Create List    ${resource_url}
    ${service_api_unavailable_resources}=    Create List    ${resource_url}
    ${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}
    ...    event_detail_expected=${TRUE}
    ...    service_api_description_expected=${TRUE}
    ...    service_api_description=${service_api_description_published}
    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}

Publish without apiStatus feature receive eventDetails without serviceAPIDescription
    [Tags]    api_status-2    mockserver

    # Initialize Mock server
    Init Mock Server

    # Default Invoker Registration and Onboarding
    ${register_user_info_invoker}    ${url}    ${request_body}=    Invoker Default Onboarding

    # 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}

    # Subscribe to events
    ${events_list}=    Create List    SERVICE_API_AVAILABLE    SERVICE_API_UNAVAILABLE

    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=4
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_invoker['api_invoker_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}

    # 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}

    # Discover APIs by invoker
    ${resp}=    Get Request Capif
    ...    ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${aef_id_1}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}

    Check Response Variable Type And Values    ${resp}    200    DiscoveredAPIs

    # Check Results
    Dictionary Should Contain Key    ${resp.json()}    serviceAPIDescriptions
    Should Not Be Empty    ${resp.json()['serviceAPIDescriptions']}
    Length Should Be    ${resp.json()['serviceAPIDescriptions']}    1
    List Should Contain Value    ${resp.json()['serviceAPIDescriptions']}    ${service_api_description_published}

    # Provider Remove service_1 published API
    ${resp}=    Delete Request Capif
    ...    ${resource_url.path}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${APF_PROVIDER_USERNAME}

    Status Should Be    204    ${resp}

    # Check Event Notifications
    ## Create check Events to ensure all notifications were received
    ${service_api_available_resources}=    Create List    ${resource_url}
    ${service_api_unavailable_resources}=    Create List    ${resource_url}
    ${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}
    ...    event_detail_expected=${TRUE}
    ...    service_api_description_expected=${FALSE}
    ...    service_api_description=${service_api_description_published}
    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}
#### -----

Publish without apiStatus feature receive eventDetails without eventDetails (apiMonitoringStatus active)
    [Tags]    api_status-3    mockserver

    # Initialize Mock server
    Init Mock Server

    # Default Invoker Registration and Onboarding
    ${register_user_info_invoker}    ${url}    ${request_body}=    Invoker Default Onboarding

    # 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}

    # Subscribe to events
    ${events_list}=    Create List    SERVICE_API_AVAILABLE    SERVICE_API_UNAVAILABLE

    ${request_body}=    Create Events Subscription
    ...    events=@{events_list}
    ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
    ...    supported_features=8
    ${resp}=    Post Request Capif
    ...    /capif-events/v1/${register_user_info_invoker['api_invoker_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}

    # 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}

    # Discover APIs by invoker
    ${resp}=    Get Request Capif
    ...    ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&aef-id=${aef_id_1}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}

    Check Response Variable Type And Values    ${resp}    200    DiscoveredAPIs

    # Check Results
    Dictionary Should Contain Key    ${resp.json()}    serviceAPIDescriptions
    Should Not Be Empty    ${resp.json()['serviceAPIDescriptions']}
    Length Should Be    ${resp.json()['serviceAPIDescriptions']}    1
    List Should Contain Value    ${resp.json()['serviceAPIDescriptions']}    ${service_api_description_published}

    # Provider Remove service_1 published API
    ${resp}=    Delete Request Capif
    ...    ${resource_url.path}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${APF_PROVIDER_USERNAME}

    Status Should Be    204    ${resp}

    # Check Event Notifications
    ## Create check Events to ensure all notifications were received
    ${service_api_available_resources}=    Create List    ${resource_url}
    ${service_api_unavailable_resources}=    Create List    ${resource_url}
    ${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}
    ...    event_detail_expected=${FALSE}
    ...    service_api_description_expected=${FALSE}
    ...    service_api_description=${service_api_description_published}
    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}





###---
# Invoker receives Service API Invocation events
#     [Tags]    api_status-x    mockserver    smoke

#     # Initialize Mock server
#     Init Mock Server

#     # Default Invoker Registration and Onboarding
#     ${register_user_info_invoker}    ${url}    ${request_body}=    Invoker Default Onboarding

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

#     ${aef_id}=    Set Variable    ${register_user_info_provider['aef_id']}

#     # Subscribe to 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}

#     ${request_body}=    Create Events Subscription
#     ...    events=@{events_list}
#     ...    notification_destination=${NOTIFICATION_DESTINATION_URL}/testing
#     ...    event_filters=${event_filters}
#     ...    supported_features=4
#     ${resp}=    Post Request Capif
#     ...    /capif-events/v1/${register_user_info_invoker['api_invoker_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}

#     # Publish one api
#     ${service_api_description_published}    ${resource_url}    ${request_body}=    Publish Service Api
#     ...    ${register_user_info_provider}
#     ...    service_1

#     # Provider Remove service_1 published API
#     ${resp}=    Delete Request Capif
#     ...    ${resource_url.path}
#     ...    server=${CAPIF_HTTPS_URL}
#     ...    verify=ca.crt
#     ...    username=${APF_PROVIDER_USERNAME}

#     Status Should Be    204    ${resp}

#     # Check Event Notifications
#     ## Create check Events to ensure all notifications were received
#     ${service_api_available_resources}=    Create List    ${resource_url}
#     ${service_api_unavailable_resources}=    Create List    ${resource_url}
#     ${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
#     Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}
+570 −160

File changed.

Preview size limit exceeded, changes collapsed.

+9 −9
Original line number Original line Diff line number Diff line
@@ -381,15 +381,15 @@ Check Two Published APIs with different APFs are removed when Provider is delete


    Run Keyword And Continue On Failure    Should Be Equal    "${services_removed}"    "2"      msg=Not all services removed after delete provider (removed) vs (expected)
    Run Keyword And Continue On Failure    Should Be Equal    "${services_removed}"    "2"      msg=Not all services removed after delete provider (removed) vs (expected)


    # Remove service API by superadmin
    # # Remove service API by superadmin
    ${resp}=    Delete Request Capif
    # ${resp}=    Delete Request Capif
    ...    /published-apis/v1/${register_user_info['apf_roles']['${APF_PROVIDER_USERNAME}_1']['apf_id']}/service-apis/${serviceApiId2}
    # ...    /published-apis/v1/${register_user_info['apf_roles']['${APF_PROVIDER_USERNAME}_1']['apf_id']}/service-apis/${serviceApiId2}
    ...    server=${CAPIF_HTTPS_URL}
    # ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    # ...    verify=ca.crt
    ...    username=${SUPERADMIN_USERNAME}
    # ...    username=${SUPERADMIN_USERNAME}


    ${services_present_on_ccf_after_provider_deletion_superadmin}=    Get Number Of Services
    # ${services_present_on_ccf_after_provider_deletion_superadmin}=    Get Number Of Services


    ${services_removed}=   Evaluate    ${services_present_on_ccf_after_publish} - ${services_present_on_ccf_after_provider_deletion_superadmin}
    # ${services_removed}=   Evaluate    ${services_present_on_ccf_after_publish} - ${services_present_on_ccf_after_provider_deletion_superadmin}
    
    
    Run Keyword And Continue On Failure   Should Be Equal    "${services_removed}"    "2"      msg=Not all services removed after delete provider (removed) vs (expected)
    # Run Keyword And Continue On Failure   Should Be Equal    "${services_removed}"    "2"      msg=Not all services removed after delete provider (removed) vs (expected)
+2 −2
Original line number Original line Diff line number Diff line
@@ -15,7 +15,7 @@ ${API_INVOKER_NOT_REGISTERED} not-valid


*** Test Cases ***
*** Test Cases ***
Published API with vendor extensibility
Published API with vendor extensibility
    [Tags]    vendor_extensibility-1
    [Tags]    vendor_extensibility-1    smoke
    ${vendor_specific_service_api_key}=    Set Variable    vendorSpecific-urn:etsi:mec:capifext:service-info
    ${vendor_specific_service_api_key}=    Set Variable    vendorSpecific-urn:etsi:mec:capifext:service-info
    ${vendor_specific_aef_profile_key}=    Set Variable    vendorSpecific-urn:etsi:mec:capifext:transport-info
    ${vendor_specific_aef_profile_key}=    Set Variable    vendorSpecific-urn:etsi:mec:capifext:transport-info
    # Register APF
    # Register APF
@@ -162,7 +162,7 @@ Publish API with vendorExt active and discover without supported features filter
    ...    ${service_api_description_published_to_check}
    ...    ${service_api_description_published_to_check}


Publish API with vendorExt active but without vendorSpecifics
Publish API with vendorExt active but without vendorSpecifics
    [Tags]    vendor_extensibility-4
    [Tags]    vendor_extensibility-4  smoke
    # Register APF
    # Register APF
    ${register_user_info}=    Provider Default Registration
    ${register_user_info}=    Provider Default Registration


Loading