Commit b754f3e4 authored by Andrea Il Grande's avatar Andrea Il Grande
Browse files

test: redirect tests for retrieve entity

parent 38857502
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation        Verify that, when one has a redirect registration on a Context Broker and an entity only on a Context Source, if one retrieves entity from the Context Broker the request gets forwarded to the Context Source correctly

Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup         Setup Entity On Remote And Registration
Test Teardown      Delete Created Entity And Registration

*** Variables ***
${entity_id_prefix}                       urn:ngsi-ld:Vehicle:
${entity_payload_filename}                vehicle-simple-attributes.jsonld
${registration_id_prefix}                 urn:ngsi-ld:Registration:
${registration_payload_file_path}         csourceRegistrations/context-source-registration-vehicle-complete-redirect.jsonld

*** Test Cases ***
063_01_red Retrieve entity on a Context Source from the Context Broker
    [Tags]    since_v1.6.1    dist-ops    proxied-redirect    5_7_1
    [Documentation]    Check that if one retrieves entity living on a Context Source from a Context Broker, entity gets returned
    ${response}=    Retrieve Entity By Id    ${entity_id}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}
    Check JSON Value In Response Body    ['id']    ${entity_id}    ${response.json()}

*** Keywords ***
Setup Entity On Remote And Registration
    ${entity_id}=    Generate Random Entity Id    ${entity_id_prefix}
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    base_url=${remote_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id}=    Generate Random Entity Id    ${registration_id_prefix}
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File   
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ${response1}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response1.status_code}

Delete Created Entity And Registration
    Delete Entity By Id    ${entity_id}    base_url=${remote_url}
    Delete Context Source Registration    ${registration_id}
 No newline at end of file
+46 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation        Verify that, when one has a redirect registration on a Context Broker and an entity only on a Context Source, if one retrieves entity from the Context Broker with local flag conflict error is raised

Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup         Setup Entity On Remote And Registration
Test Teardown      Delete Created Entity And Registration

*** Variables ***
${entity_id_prefix}                     urn:ngsi-ld:Vehicle:
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-complete-redirect.jsonld

*** Test Cases ***
063_02_red Retrieve entity on a Context Source from the Context Broker with local flag
    [Tags]    since_v1.6.1    dist-ops    proxied-redirect    5_7_1
    [Documentation]    Check that if one retrieves entity living on a Context Source from a Context Broker with local flag, conflict error is raised
    ${response}=    Retrieve Entity By Id    ${entity_id}    context=${ngsild_test_suite_context}    local=true
    Check Response Status Code    409    ${response.status_code}


*** Keywords ***
Setup Entity On Remote And Registration
    ${entity_id}=    Generate Random Entity Id    ${entity_id_prefix}
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    base_url=${remote_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id}=    Generate Random Entity Id    ${registration_id_prefix}
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File   
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ${response1}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response1.status_code}
    

Delete Created Entity And Registration
    Delete Entity By Id    ${entity_id}    base_url=${remote_url}
    Delete Context Source Registration    ${registration_id} 
 No newline at end of file