Commit 38c22eaa authored by Pelayo Torres's avatar Pelayo Torres
Browse files

Merge branch 'OCF204-same-apiname-between-different-apis-must-be-allowed-new-tests' into 'staging'

2 new tests related with apiName improvement

See merge request !187
parents 87bf585a 1b50ac5d
Loading
Loading
Loading
Loading
Loading
+135 −0
Original line number Original line Diff line number Diff line
@@ -393,3 +393,138 @@ Check Two Published APIs with different APFs are removed when Provider is delete
    # ${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)


Publish API same apiName but different AEF
    [Tags]    capif_api_publish_service-15  smoke

    # Set API name
    ${api_name}=  Set Variable    testing_robot_service_1

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

    # Create Provider1 with 2 AEF roles and publish API
    ${register_user_info_provider_1}=    Provider Default Registration    total_aef_roles=2
    ${aef_id_1}=    Set Variable    ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']}
    ${aef_id_2}=    Set Variable
    ...    ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']}

    ## Publish API service_1 with aefIds_1
    ${service_api_description_published_1_1}    ${resource_url}    ${request_body}=    Publish Service Api
    ...    ${register_user_info_provider_1}
    ...    ${api_name}
    ...    aef_id=${aef_id_1}

    ## Publish API service_1 with aefIds_2
    ${service_api_description_published_1_2}    ${resource_url}    ${request_body}=    Publish Service Api
    ...    ${register_user_info_provider_1}
    ...    ${api_name}
    ...    aef_id=${aef_id_2}

    # Create Provider2 with 1 AEF role and publish API
    ${register_user_info_provider_2}=    Provider Default Registration    provider_username=${PROVIDER_USERNAME}_NEW
    ${aef2_id_1}=    Set Variable
    ...    ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']}

    ## Publish API service_1 with Provider2
    ${service_api_description_published_2}    ${resource_url_2}    ${request_body_2}=    Publish Service Api
    ...    ${register_user_info_provider_2}
    ...    ${api_name}
    ...    aef_id=${aef2_id_1}

    # Validation of final scenario.
    ## Check if there are 2 API published with same apiName but different AEFs by retrieving all APIs for provider 1 using APF provider credentials
    ### Retrieve Services published
    ${resp}=    Get Request Capif
    ...    /published-apis/v1/${register_user_info_provider_1['apf_id']}/service-apis
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${APF_PROVIDER_USERNAME}

    ### Validate response and values obtained
    Check Response Variable Type And Values    ${resp}    200    ServiceAPIDescription
    #### Check returned values
    List Should Contain Value    ${resp.json()}    ${service_api_description_published_1_1}
    List Should Contain Value    ${resp.json()}    ${service_api_description_published_1_2}

    ## Check if there are 3 API published with same apiName but different AEFs
    ### Discover API published by retrieving all APIs for Invoker using Invoker credentials
    ${resp}=    Get Request Capif
    ...    ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api_name=${api_name}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}

    ### Validate response and values obtained
    Check Response Variable Type And Values    ${resp}    200    DiscoveredAPIs
    #### Check returned values
    Should Not Be Empty    ${resp.json()['serviceAPIDescriptions']}
    Length Should Be    ${resp.json()['serviceAPIDescriptions']}    3
    List Should Contain Value    ${resp.json()['serviceAPIDescriptions']}    ${service_api_description_published_1_1}
    List Should Contain Value    ${resp.json()['serviceAPIDescriptions']}    ${service_api_description_published_1_2}
    List Should Contain Value    ${resp.json()['serviceAPIDescriptions']}    ${service_api_description_published_2}

Publish API same apiName and same AEF
    [Tags]    capif_api_publish_service-16  smoke

    # Set API name
    ${api_name}=  Set Variable    testing_robot_service_1

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

    # Create Provider1 with 2 AEF roles
    ${register_user_info_provider_1}=    Provider Default Registration    total_aef_roles=2
    ${aef_id_1}=    Set Variable    ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}']['aef_id']}
    ${aef_id_2}=    Set Variable    ${register_user_info_provider_1['aef_roles']['${AEF_PROVIDER_USERNAME}_1']['aef_id']}
    ${aef_ids}=    Create List    ${aef_id_1}    ${aef_id_2}

    ## Publish API service_1 with aefIds_1
    ${resp}   ${request_body}=    Publish Service Api Request   ${register_user_info_provider_1}    ${api_name}    aef_id=${aef_id_1}

    ### Validate response and values obtained
    Check Response Variable Type And Values    ${resp}    201    ServiceAPIDescription
    Dictionary Should Contain Key    ${resp.json()}    apiId
    ${service_api_description_published_1_1}=   Set Variable    ${resp.json()}

    ## Publish API service_1 with aefIds_1, error expected since same apiName and same AEF
    ${resp}   ${request_body}=    Publish Service Api Request   ${register_user_info_provider_1}    ${api_name}    aef_id=${aef_id_1}

    ### Validate error response and values obtained
    Check Response Variable Type And Values    ${resp}    403    ProblemDetails
    ...    status=403
    ...    title=Forbidden
    ...    detail=Already registered service with same api name and aef id
    ...    cause=Found service with same api name and aef id

    # Create Provider2 with 1 AEF role and publish API
    ${register_user_info_provider_2}=    Provider Default Registration    provider_username=${PROVIDER_USERNAME}_NEW
    ${aef2_id_1}=    Set Variable
    ...    ${register_user_info_provider_2['aef_roles']['${AEF_PROVIDER_USERNAME}_NEW']['aef_id']}

    ## Publish API service_1 with Provider2 aefid_1, since same apiName but different AEF, it should be published successfully
    ${service_api_description_published_2}    ${resource_url_2}    ${request_body_2}=    Publish Service Api
    ...    ${register_user_info_provider_2}
    ...    ${api_name}
    ...    aef_id=${aef2_id_1}

    # Validation of final scenario.
    ## Check if there are 2 API published with same apiName but different AEFs
    ### Discover API published by retrieving all APIs for Invoker using Invoker credentials
    ${resp}=    Get Request Capif
    ...    ${DISCOVER_URL}${register_user_info_invoker['api_invoker_id']}&api_name=${api_name}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${INVOKER_USERNAME}

    ### Validate response and values obtained
    Check Response Variable Type And Values    ${resp}    200    DiscoveredAPIs
    #### Check returned values
    Should Not Be Empty    ${resp.json()['serviceAPIDescriptions']}
    Length Should Be    ${resp.json()['serviceAPIDescriptions']}    2
    List Should Contain Value    ${resp.json()['serviceAPIDescriptions']}    ${service_api_description_published_1_1}
    List Should Contain Value    ${resp.json()['serviceAPIDescriptions']}    ${service_api_description_published_2}