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

feat: new test for redirect

parent 782a3a3f
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ D012_01_exc Batch Create Entities With Exclusive Registration
    @{entities_to_be_created}=    Create List    ${speed_entity1}    ${speed_entity2}
    @{expected_entities_ids}=    Create List    ${entity_id1}    ${entity_id2}
    Set Suite Variable    @{entities_to_be_created}
    Set Suite Variable    @{expected_entities_ids}

    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entityOperations/create    201
    ${response}=    Batch Create Entities
+76 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can create a batch of entities on the both Context Source thanks to a redirect registration

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          Setup Entity Id And Registration And Start Context Source Mock Server
Test Teardown       Delete Registration And Stop Context Source Mock Server

*** Variables ***
${entity_payload_filename}              vehicle-simple-different-attributes.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld

*** Test Cases ***
D012_01_red Batch Create Entities With Redirect Registration
    [Documentation]    Check that if one requests the Context Broker to create a batch of entities that match a redirect registration, these are created on the Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_6_7
    
    ${entity1}=    Load Entity    ${entity_speed_payload_filename}    ${entity_id1}
    ${entity2}=    Load Entity    ${entity_speed_payload_filename}    ${entity_id2}
    @{entities_to_be_created}=    Create List    ${entity1}    ${entity2}
    Set Suite Variable    @{entities_to_be_created}

    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entityOperations/create    201
    Set Stub Reply    POST    /broker2/ngsi-ld/v1/entityOperations/create    201
    ${response}=    Batch Create Entities
    ...    @{entities_to_be_created}
    Check Response Status Code    201    ${response.status_code}

    ${stub_count}=    Get Stub Count    POST    /broker1/ngsi-ld/v1/entityOperations/create
    Should Be Equal    ${stub_count}    1
    ${stub_count}=    Get Stub Count    POST    /broker2/ngsi-ld/v1/entityOperations/create
    Should Be Equal    ${stub_count}    1

*** Keywords ***
Setup Entity Id And Registration And Start Context Source Mock Server
    ${entity_id1}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id1}
    ${entity_id2}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id2}

    ${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=${EMPTY}
    ...    mode=redirect
    ...    endpoint=/broker1
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id2}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id2}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id2}
    ...    ${registration_payload_file_path}
    ...    entity_id=${EMPTY}
    ...    mode=redirect
    ...    endpoint=/broker2
    ${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
    Batch Delete Entities    entities_ids_to_be_deleted=@{expected_entities_ids}
    Delete Context Source Registration    ${registration_id}
    Delete Context Source Registration    ${registration_id2}
    Stop Context Source Mock Server
+43 −0
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/CreateBatchEntities/D012_01_red",
  "test_objective": "Check that one can create a batch of entities on the both Context Source thanks to a redirect registration",
  "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.7",
  "config_id": "",
  "parent_release": "v1.6.1",
  "clauses": [
    "4.3.3",
    "4.3.6.3",
    "5.6.7"
  ],
  "pics_selection": "",
  "keywords": [
    "Setup Entity Id And Registration And Start Context Source Mock Server",
    "Delete Registration And Stop Context Source Mock Server"
  ],
  "teardown": "None",
  "initial_condition": "with {\n    the SUT being in the \"initial state\" and\n    the SUT containing an initial Entity id set to ${entity_id}\n    and the SUT containing a Context Source Registration \n        with id equal to ${registration_id}\n        and payload set to ${registration_payload_file_path}\n    and the SUT containing a Context Source Mock Server\n}",
  "test_cases": [
    {
      "name": "D012_01_red Batch Create Entities With Redirect Registration",
      "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/CreateBatchEntities/D012_01_red",
      "doc": "Check that if one requests the Context Broker to create a batch of entities that match a redirect registration, these are created on the Context Source",
      "tags": [
        "4_3_3",
        "4_3_6_3",
        "5_6_7",
        "cf_06",
        "dist-ops",
        "proxy-exclusive",
        "since_v1.6.1"
      ],
      "setup": "Setup Entity Id And Registration And Start Context Source Mock Server",
      "teardown": "Delete Registration And Stop Context Source Mock Server",
      "template": null,
      "http_verb": "POST",
      "endpoint": "entityOperations/create"
    }
  ],
  "permutations": [],
  "robotpath": "DistributedOperations/Provision/BatchEntities/CreateBatchEntities",
  "robotfile": "D012_01_red"
}
 No newline at end of file