Commit 8c4ca516 authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Update tests to accomplish apiStatus

parent ee505566
Loading
Loading
Loading
Loading
Loading
+157 −0
Original line number Diff line number Diff line
@@ -18,6 +18,163 @@ ${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}
#### -----

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

+1 −0
Original line number Diff line number Diff line
@@ -280,6 +280,7 @@ Invoker subscribe to Service API Available and Unavailable events
    ...    subscription_id=${subscription_id}
    ...    service_api_available_resources=${service_api_available_resources}
    ...    service_api_unavailable_resources=${service_api_unavailable_resources}
    ...    event_detail_expected=${TRUE}
    ## Check Events Expected towards received notifications at mock server
    Wait Until Keyword Succeeds    5x    5s    Check Mock Server Notification Events    ${events_expected}

+2 −2
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ ${API_INVOKER_NOT_REGISTERED} not-valid

*** Test Cases ***
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_aef_profile_key}=    Set Variable    vendorSpecific-urn:etsi:mec:capifext:transport-info
    # Register APF
@@ -162,7 +162,7 @@ Publish API with vendorExt active and discover without supported features filter
    ...    ${service_api_description_published_to_check}

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

+56 −33
Original line number Diff line number Diff line
def create_service_api_description(api_name="service_1", aef_id="aef_id", supported_features="0", vendor_specific_service_api_description=None, vendor_specific_aef_profile=None):
    aef_ids = list()
    if isinstance(aef_id, list):
        aef_ids = aef_id
        print("aef_id parameter is a list")
    elif isinstance(aef_id, str):
        print("aef_id parameter is a string")
        aef_ids.append(aef_id)

    profiles = create_aef_profiles(aef_ids)

    body = {
        "apiName": api_name,
        "aefProfiles": [
            {
                "aefId": aef_id,
                "versions": [
                    {
                        "apiVersion": "v1",
                        "expiry": "2021-11-30T10:32:02.004000+00:00",
                        "resources": [
                            {
                                "resourceName": "string",
                                "commType": "REQUEST_RESPONSE",
                                "uri": "string",
                                "custOpName": "string",
                                "operations": [
                                    "GET"
                                ],
                                "description": "string"
                            }
                        ],
                    }
                ],
                "protocol": "HTTP_1_1",
                "dataFormat": "JSON",
                "securityMethods": ["PSK"],
                "interfaceDescriptions": [
                    {
                        "ipv4Addr": "string",
                        "port": 65535,
                        "securityMethods": ["PSK"]
                    }
                ]
            }
        ],
        "aefProfiles": profiles,
        "description": "ROBOT_TESTING",
        "shareableInfo": {
            "isShareable": True,
@@ -63,3 +41,48 @@ def create_service_api_description(api_name="service_1", aef_id="aef_id", suppor
        body['supportedFeatures'] = supported_features

    return body


def create_aef_profiles(aef_ids):
    profiles = list()
    index=1
    for aef_id in aef_ids:
        profiles.append(create_aef_profile(aef_id,"resource_" + str(index)))
        index=index+1
    return profiles



def create_aef_profile(aef_id, resource_name):
    data = {
        "aefId": aef_id,
        "versions": [
            {
                "apiVersion": "v1",
                "expiry": "2021-11-30T10:32:02.004000+00:00",
                "resources": [
                    {
                        "resourceName": resource_name,
                        "commType": "REQUEST_RESPONSE",
                        "uri": "string",
                        "custOpName": "string",
                        "operations": [
                                    "GET"
                        ],
                        "description": "string"
                    }
                ],
            }
        ],
        "protocol": "HTTP_1_1",
        "dataFormat": "JSON",
        "securityMethods": ["PSK"],
        "interfaceDescriptions": [
                    {
                        "ipv4Addr": "string",
                        "port": 65535,
                        "securityMethods": ["PSK"]
                    }
        ]
    }
    return data
+19 −7
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ Library Telnet
Library             String



*** Variables ***
${CAPIF_AUTH}                           ${EMPTY}
${CAPIF_BEARER}                         ${EMPTY}
@@ -795,6 +794,14 @@ Publish Service Api
    ...    ${supported_features}=0
    ...    ${vendor_specific_service_api_description}=${None}
    ...    ${vendor_specific_aef_profile}=${None}
    ...    ${aef_id}=${NONE}

    ${aef_ids}=    Create List
    IF    "${aef_id}" == "${NONE}"
        Append To List    ${aef_ids}    ${register_user_info_provider['aef_id']}
    ELSE
        ${aef_ids}=   Set Variable     ${aef_id}
    END

    ${apf_id_to_use}=    Set Variable    ${register_user_info_provider['apf_id']}
    ${apf_username_to_use}=    Set Variable    ${register_user_info_provider['apf_username']}
@@ -811,7 +818,12 @@ Publish Service Api
        ${apf_username_to_use}=    Set Variable    ${apf_username}
    END

    ${request_body}=    Create Service Api Description    ${service_name}    ${register_user_info_provider['aef_id']}  ${supported_features}  ${vendor_specific_service_api_description}   ${vendor_specific_aef_profile}
    ${request_body}=    Create Service Api Description
    ...    ${service_name}
    ...    ${aef_ids}
    ...    ${supported_features}
    ...    ${vendor_specific_service_api_description}
    ...    ${vendor_specific_aef_profile}
    ${resp}=    Post Request Capif
    ...    /published-apis/v1/${apf_id_to_use}/service-apis
    ...    json=${request_body}
Loading