Commit a24bb29d authored by Benedetta Arena's avatar Benedetta Arena
Browse files

exclusive consumption operations

parent b65b46ba
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that, when one has an exclusive registration on a Context Broker and a fragment of an entity on a Context Source, if one queries the Context Broker the query gets merged with the Context Source correctly

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

Test Setup          Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Test Teardown       Delete Registration And Stop Context Source Mock Server


*** Variables ***
${entity_id_prefix}                     urn:ngsi-ld:Vehicle:
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${entity_speed_filename}                vehicle-speed-attribute.json
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld

*** Test Cases ***
D011_01_exc Query The Context Broker With Type
    [Documentation]    Check that if one queries the Context Broker for type, entity with matching type on a Context Source gets merged correctly
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_7_2
    ${entity_speed}=    Load Entity    ${entity_speed_filename}    ${entity_id}
    Set Stub Reply    GET    /broker1/ngsi-ld/v1/entities?type=Vehicle    200    ${entity_speed}
    
    ${response}=    Query Entities    entity_types=Vehicle    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}

    ${stub_count}=    Get Stub Count    GET    /broker1/ngsi-ld/v1/entities?type=Vehicle
    Should Be True    ${stub_count} > 0

    ${body}=    Get From Dictionary    ${response.json()}    speed
    Should Contain    ${body}    speed

*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
    ${entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id}

    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    local=true
    Check Response Status Code    201    ${response.status_code}

    ${registration_id}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    mode=exclusive
    ...    endpoint=/broker1
    ${response1}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response1.status_code}
    Start Context Source Mock Server

Delete Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Entity by Id    ${entity_id}
    Stop Context Source Mock Server
+73 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that an entity can be retrieved by Id with a queryEntity and a queryBatch while using an exclusive registration.
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
Resource            ${EXECDIR}/resources/MockServerUtils.resource

Test Template      Setup Registration, Context Source Mock Server And Query The Context Broker With Type
Test Teardown      Delete Registration And Stop Context Source Mock Server


*** Variables ***
${entity_id_prefix}                     urn:ngsi-ld:Vehicle:
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${entity_speed_filename}                vehicle-speed-attribute.json
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld

*** Test Cases *** 
D011_02_01_exc Query The Context Broker With Type With queryEntity
    [Documentation]    Check that if one queries the Context Broker for type, and the registration only allows the queryEntity operation, the request is forwarded as expected
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_7_2
    [Template]     Setup Registration, Context Source Mock Server And Query The Context Broker With Type    
    GET    /broker1/ngsi-ld/v1/entities?type=Vehicle

D011_02_02_exc Query The Context Broker With Type With queryBatch
    [Documentation]    Check that if one queries the Context Broker for type, and the registration only allows the queryBatch operation, the request is forwarded as expected
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_7_2
    [Template]     Setup Registration, Context Source Mock Server And Query The Context Broker With Type
    POST    /broker1/ngsi-ld/v1/entityOperations/query

*** Keywords ***
Setup Registration, Context Source Mock Server And Query The Context Broker With Type
    [Arguments]    ${method}    ${url} 
    ${entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id}

    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    local=true
    Check Response Status Code    201    ${response.status_code}

    ${registration_id}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    mode=exclusive
    ...    endpoint=/broker1
    ${response1}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response1.status_code}
    Start Context Source Mock Server

    ${entity_speed}=    Load Entity    ${entity_speed_filename}    ${entity_id}
    Set Stub Reply    ${method}   ${url}   200    ${entity_speed}
    @{entities_id}=    Create List    ${entity_id}
    
    IF    '${method}' == 'GET'
        ${response}=    Query Entities    entity_types=Vehicle    context=${ngsild_test_suite_context}
    ELSE IF    '${method}' == 'POST'
        @{entities}=    Create List    ${entity_id}
        ${response}=    Query Entities Via POST    entities=${entities}    context=${ngsild_test_suite_context}
    END

    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing Entities URIS set to    ${entities_id}    ${response.json()}


Delete Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Stop Context Source Mock Server
 No newline at end of file
+64 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that, when one has an exclusive registration on a Context Broker and an entity only on a Context Source, a retrieval request to the Context Broker the request is forwarded correcty to the Context Source

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
Resource            ${EXECDIR}/resources/MockServerUtils.resource

Test Setup         Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Test Teardown      Delete Registration And Stop Context Source Mock Server


*** Variables ***
${entity_id_prefix}                     urn:ngsi-ld:Vehicle:
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${entity_speed_filename}                vehicle-speed-attribute.json
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld

*** Test Cases *** 
D010_01_exc Query Context Broker And Retrieve Entity By Id
    [Documentation]    Check that if one retrieves entity living on a Context Source from a Context Broker, and the registration only allows the retrieveEntity operation, the request is forwarded as expected
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_7_1
    
    ${entity_speed}=    Load Entity    ${entity_speed_filename}    ${entity_id}
    Set Stub Reply    GET    /broker1/ngsi-ld/v1/entities/${entity_id}    200    ${entity_speed}

    ${response}=    Retrieve Entity By Id    ${entity_id}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}

    ${stub_count}=    Get Stub Count    GET    /broker1/ngsi-ld/v1/entities?type=Vehicle
    Should Be True    ${stub_count} > 0

    ${body}=    Get From Dictionary    ${response.json()}    speed
    Should Contain    ${body}    speed
    
*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
        ${entity_id}=    Generate Random Vehicle Entity Id
        Set Suite Variable   ${entity_id}

        ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    local=${True}
        Check Response Status Code    201    ${response.status_code}

        ${registration_id}=    Generate Random CSR Id
        Set Suite Variable    ${registration_id}
        ${registration_payload}=    Prepare Context Source Registration From File
        ...    ${registration_id}
        ...    ${registration_payload_file_path}
        ...    entity_id=${entity_id}
        ...    mode=exclusive
        ...    endpoint=/broker1
        ${response}=    Create Context Source Registration With Return    ${registration_payload}
        Check Response Status Code    201    ${response.status_code}

        Start Context Source Mock Server

Delete Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Entity By Id    ${entity_id}
    Stop Context Source Mock Server
 No newline at end of file
+58 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that, when one has an exclusive registration on a Context Broker and part of an entity on a Context Source, a retrieval request to the Context Broker does not contain the exclusive attribute

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
Resource            ${EXECDIR}/resources/MockServerUtils.resource

Test Setup         Create Entity And Registration On The Context Broker And Start Context Source Mock Server
Test Teardown      Delete Registration And Stop Context Source Mock Server


*** Variables ***
${entity_id_prefix}                     urn:ngsi-ld:Vehicle:
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${entity_speed_filename}                vehicle-speed-attribute.json
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld

*** Test Cases *** 
D010_02_exc Query Context Broker And Retrieve Entity By Id
    [Documentation]    Check that if one retrieves a fragmented entity locally, the response does not contain the exclusive attribute
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_7_1
    
    ${entity_speed}=    Load Entity    ${entity_speed_filename}    ${entity_id}
    Set Stub Reply    GET    /broker1/ngsi-ld/v1/entities/${entity_id}    200    ${entity_speed}

    ${response}=    Retrieve Entity By Id   ${entity_id}   context=${ngsild_test_suite_context}    local=${True}
    Dictionary Should Not Contain Key    ${response.json()}    speed
    
*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
        ${entity_id}=    Generate Random Vehicle Entity Id
        Set Suite Variable   ${entity_id}

        ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    local=${True}
        Check Response Status Code    201    ${response.status_code}

        ${registration_id}=    Generate Random CSR Id
        Set Suite Variable    ${registration_id}
        ${registration_payload}=    Prepare Context Source Registration From File
        ...    ${registration_id}
        ...    ${registration_payload_file_path}
        ...    entity_id=${entity_id}
        ...    mode=exclusive
        ...    endpoint=/broker1
        ${response}=    Create Context Source Registration With Return    ${registration_payload}
        Check Response Status Code    201    ${response.status_code}

        Start Context Source Mock Server

Delete Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Entity By Id    ${entity_id}
    Stop Context Source Mock Server
 No newline at end of file
+0 −19
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID",
  "type": "ContextSourceRegistration",
  "information": [
    {
      "entities": [
        {
          "id": "urn:ngsi-ld:Vehicle:randomUUID",
          "type": "Vehicle"
        }
      ],
      "propertyNames":["speed"]
    }
  ],
  "endpoint": "http://my.csource.org:1026",
  "@context":[
    "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
 ]
}
 No newline at end of file
Loading