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

Checking 2 apfs with one serviceapi subscriber by each one and provider removed

parent e8d00c9e
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ Register Api Provider
    [Tags]    capif_api_provider_management-1
    # Register Provider User An create Certificates for each function
    ${register_user_info}=    Register User At Jwt Auth Provider
    ...    username=${PROVIDER_USERNAME}    role=${PROVIDER_ROLE}
    ...    username=${PROVIDER_USERNAME}

    # Create provider Registration Body
    ${apf_func_details}=    Create Api Provider Function Details
+21 −3
Original line number Diff line number Diff line
@@ -329,7 +329,7 @@ Delete APIs Published by NON Authorised apfId
Retrieve single APIs Published by Authorised apfId TEST
    [Tags]    capif_api_publish_service-x
    # Register APF
    ${register_user_info}=    Provider Default Registration
    ${register_user_info}=    Provider Default Registration    total_apf_roles=2

    ${service_api_description_published_1}    ${resource_url}    ${request_body}=    Publish Service Api
    ...    ${register_user_info}
@@ -337,6 +337,7 @@ Retrieve single APIs Published by Authorised apfId TEST
    ${service_api_description_published_2}    ${resource_url}    ${request_body}=    Publish Service Api
    ...    ${register_user_info}
    ...    service_2
    ...    apf_username=${APF_PROVIDER_USERNAME}_1

    # Store apiId1
    ${serviceApiId1}=    Set Variable    ${service_api_description_published_1['apiId']}
@@ -354,10 +355,10 @@ Retrieve single APIs Published by Authorised apfId TEST

    # Retrieve Services 1
    ${resp}=    Get Request Capif
    ...    /published-apis/v1/${register_user_info['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}
    ...    verify=ca.crt
    ...    username=${APF_PROVIDER_USERNAME}
    ...    username=${APF_PROVIDER_USERNAME}_1

    Check Response Variable Type And Values    ${resp}    200    ServiceAPIDescription
    Dictionaries Should Be Equal    ${resp.json()}    ${service_api_description_published_2}
@@ -385,3 +386,20 @@ Retrieve single APIs Published by Authorised apfId TEST
    ...    username=${SUPERADMIN_USERNAME}

    Log Dictionary    ${resp.json()}

    Run Keyword And Continue On Failure  Length Should Be    ${resp.json()['services']}    0

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

    ${resp}=    Get Request Capif
    ...   /helper/getServices
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${SUPERADMIN_USERNAME}

    Log Dictionary    ${resp.json()}
    Length Should Be    ${resp.json()['services']}    0
 No newline at end of file
+127 −35
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ Library Telnet
Library             String



*** Variables ***
${CAPIF_AUTH}                           ${EMPTY}
${CAPIF_BEARER}                         ${EMPTY}
@@ -396,19 +397,65 @@ Register User At Jwt Auth
    RETURN    ${register_user_info}

Register User At Jwt Auth Provider
    [Arguments]    ${username}    ${role}    ${password}=password    ${description}=Testing
    [Arguments]
    ...    ${username}
    ...    ${password}=password
    ...    ${description}=Testing
    ...    ${total_apf_roles}=1
    ...    ${total_aef_roles}=1
    ...    ${total_amf_roles}=1

    ${apf_roles}=    Create Dictionary
    ${default_apf_username}=    Set Variable    APF_${username}
    FOR    ${index}    IN RANGE    ${total_apf_roles}
        ${apf_username}=    Set Variable    ${default_apf_username}_${index}
        IF    ${index} == 0
            ${apf_username}=    Set Variable    ${default_apf_username}
        END
        ${apf_csr_request}=    Create User Csr    ${apf_username}    apf
        ${apf_role}=
        ...    Create Dictionary
        ...    username=${apf_username}
        ...    csr_request=${apf_csr_request}
        ...    role=APF
        Set To Dictionary    ${apf_roles}    ${apf_username}=${apf_role}
    END

    ${apf_username}=    Set Variable    APF_${username}
    ${aef_username}=    Set Variable    AEF_${username}
    ${amf_username}=    Set Variable    AMF_${username}
    ${aef_roles}=    Create Dictionary
    ${default_aef_username}=    Set Variable    AEF_${username}
    FOR    ${index}    IN RANGE    ${total_aef_roles}
        ${aef_username}=    Set Variable    ${default_aef_username}_${index}
        IF    ${index} == 0
            ${aef_username}=    Set Variable    ${default_aef_username}
        END
        ${aef_csr_request}=    Create User Csr    ${aef_username}    aef
        ${aef_role}=
        ...    Create Dictionary
        ...    username=${aef_username}
        ...    csr_request=${aef_csr_request}
        ...    role=AEF
        Set To Dictionary    ${aef_roles}    ${aef_username}=${aef_role}
    END

    ${amf_roles}=    Create Dictionary
    ${default_amf_username}=    Set Variable    AMF_${username}
    FOR    ${index}    IN RANGE    ${total_amf_roles}
        ${amf_username}=    Set Variable    ${default_amf_username}_${index}
        IF    ${index} == 0
            ${amf_username}=    Set Variable    ${default_amf_username}
        END
        ${amf_csr_request}=    Create User Csr    ${amf_username}    amf
        ${amf_role}=
        ...    Create Dictionary
        ...    username=${amf_username}
        ...    csr_request=${amf_csr_request}
        ...    role=AMF
        Set To Dictionary    ${amf_roles}    ${amf_username}=${amf_role}
    END

    # Create a certificate for each kind of role under provider
    ${csr_request}=    Create User Csr    ${username}    provider

    ${apf_csr_request}=    Create User Csr    ${apf_username}    apf
    ${aef_csr_request}=    Create User Csr    ${aef_username}    aef
    ${amf_csr_request}=    Create User Csr    ${amf_username}    amf

    # Register provider
    ${resp}=    Create User At Register
    ...    ${username}
@@ -423,12 +470,15 @@ Register User At Jwt Auth Provider
    ${register_user_info}=    Create Dictionary
    ...    netappID=${resp.json()['uuid']}
    ...    csr_request=${csr_request}
    ...    apf_csr_request=${apf_csr_request}
    ...    aef_csr_request=${aef_csr_request}
    ...    amf_csr_request=${amf_csr_request}
    ...    apf_username=${apf_username}
    ...    aef_username=${aef_username}
    ...    amf_username=${amf_username}
    ...    apf_username=${default_apf_username}
    ...    aef_username=${default_aef_username}
    ...    amf_username=${default_amf_username}
    ...    apf_csr_request=${apf_roles['${default_apf_username}']['csr_request']}
    ...    aef_csr_request=${aef_roles['${default_aef_username}']['csr_request']}
    ...    amf_csr_request=${amf_roles['${default_amf_username}']['csr_request']}
    ...    apf_roles=${apf_roles}
    ...    aef_roles=${aef_roles}
    ...    amf_roles=${amf_roles}
    ...    &{resp.json()}
    ...    &{get_auth_response}

@@ -640,20 +690,16 @@ Invoker Default Onboarding
Provider Registration
    [Arguments]    ${register_user_info}

    ${api_prov_funcs}=    Create List

    # Create provider Registration Body
    ${apf_func_details}=    Create Api Provider Function Details
    ...    ${register_user_info['apf_username']}
    ...    ${register_user_info['apf_csr_request']}
    ...    APF
    ${aef_func_details}=    Create Api Provider Function Details
    ...    ${register_user_info['aef_username']}
    ...    ${register_user_info['aef_csr_request']}
    ...    AEF
    ${amf_func_details}=    Create Api Provider Function Details
    ...    ${register_user_info['amf_username']}
    ...    ${register_user_info['amf_csr_request']}
    ...    AMF
    ${api_prov_funcs}=    Create List    ${apf_func_details}    ${aef_func_details}    ${amf_func_details}
    FOR    ${key}    ${value}    IN    &{register_user_info['apf_roles']}    &{register_user_info['aef_roles']}    &{register_user_info['amf_roles']}
        ${func_details}=    Create Api Provider Function Details
        ...    ${key}
        ...    ${value['csr_request']}
        ...    ${value['role']}
        Append To List    ${api_prov_funcs}    ${func_details}
    END

    ${request_body}=    Create Api Provider Enrolment Details Body
    ...    ${register_user_info['access_token']}
@@ -676,12 +722,29 @@ Provider Registration
    FOR    ${prov}    IN    @{resp.json()['apiProvFuncs']}
        Log Dictionary    ${prov}
        Store In File    ${prov['apiProvFuncInfo']}.crt    ${prov['regInfo']['apiProvCert']}
        Log Dictionary   ${register_user_info}
        Log  ${register_user_info['apf_username']}
        IF    "${prov['apiProvFuncRole']}" == "APF"
            IF    "${prov['apiProvFuncInfo']}" == "${register_user_info['apf_username']}"
                Set To Dictionary    ${register_user_info}    apf_id=${prov['apiProvFuncId']}
            END
            Set To Dictionary
            ...    ${register_user_info['apf_roles']['${prov['apiProvFuncInfo']}']}
            ...    apf_id=${prov['apiProvFuncId']}
        ELSE IF    "${prov['apiProvFuncRole']}" == "AEF"
            IF    "${prov['apiProvFuncInfo']}" == "${register_user_info['aef_username']}"
                Set To Dictionary    ${register_user_info}    aef_id=${prov['apiProvFuncId']}
            END
            Set To Dictionary
            ...    ${register_user_info['aef_roles']['${prov['apiProvFuncInfo']}']}
            ...    aef_id=${prov['apiProvFuncId']}
        ELSE IF    "${prov['apiProvFuncRole']}" == "AMF"
            IF    "${prov['apiProvFuncInfo']}" == "${register_user_info['amf_username']}"
                Set To Dictionary    ${register_user_info}    amf_id=${prov['apiProvFuncId']}
            END
            Set To Dictionary
            ...    ${register_user_info['amf_roles']['${prov['apiProvFuncInfo']}']}
            ...    amf_id=${prov['apiProvFuncId']}
        ELSE
            Fail    "${prov['apiProvFuncRole']} is not valid role"
        END
@@ -703,10 +766,20 @@ Provider Registration
    RETURN    ${register_user_info}

Provider Default Registration
    [Arguments]    ${provider_username}=${PROVIDER_USERNAME}
    [Arguments]    
    ...    ${provider_username}=${PROVIDER_USERNAME}
    ...    ${total_apf_roles}=1
    ...    ${total_aef_roles}=1
    ...    ${total_amf_roles}=1
    ...    ${apf_id}=${NONE}
    ...    ${apf_username}=${NONE}

    # Register Provider
    ${register_user_info}=    Register User At Jwt Auth Provider
    ...    username=${provider_username}    role=${PROVIDER_ROLE}
    ...    username=${provider_username}
    ...    total_apf_roles=${total_apf_roles}
    ...    total_aef_roles=${total_aef_roles}
    ...    total_amf_roles=${total_amf_roles}

    ${register_user_info}=    Provider Registration    ${register_user_info}

@@ -715,15 +788,34 @@ Provider Default Registration
    RETURN    ${register_user_info}

Publish Service Api
    [Arguments]    ${register_user_info_provider}    ${service_name}=service_1
    [Arguments]
    ...    ${register_user_info_provider}
    ...    ${service_name}=service_1
    ...    ${apf_id}=${NONE}
    ...    ${apf_username}=${NONE}

    ${apf_id_to_use}=    Set Variable    ${register_user_info_provider['apf_id']}
    ${apf_username_to_use}=    Set Variable    ${register_user_info_provider['apf_username']}
    IF    "${apf_id}" != "${NONE}" and "${apf_id}" != "${register_user_info_provider['apf_id']}"
        FOR    ${apf_username}    ${apf_role}    IN    &{register_user_info_provider['apf_roles']}
            IF    "${apf_role['apf_id']}" == "${apf_id}"
                ${apf_id_to_use}=    Set Variable    ${apf_id}
                ${apf_username_to_use}=    Set Variable    ${apf_username}
                BREAK
            END
        END
    ELSE IF    "${apf_username}" != "${NONE}" and "${apf_username}" != "${register_user_info_provider['apf_username']}"
        ${apf_id_to_use}=    Set Variable    ${register_user_info_provider['apf_roles']['${apf_username}']['apf_id']}
        ${apf_username_to_use}=    Set Variable    ${apf_username}
    END

    ${request_body}=    Create Service Api Description    ${service_name}    ${register_user_info_provider['aef_id']}
    ${resp}=    Post Request Capif
    ...    /published-apis/v1/${register_user_info_provider['apf_id']}/service-apis
    ...    /published-apis/v1/${apf_id_to_use}/service-apis
    ...    json=${request_body}
    ...    server=${CAPIF_HTTPS_URL}
    ...    verify=ca.crt
    ...    username=${register_user_info_provider['apf_username']}
    ...    username=${apf_username_to_use}

    Check Response Variable Type And Values    ${resp}    201    ServiceAPIDescription
    Dictionary Should Contain Key    ${resp.json()}    apiId