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

fix: minor typos and improve test D018_01 and D018_03 logic

parent f7c06e08
Loading
Loading
Loading
Loading
+34 −22
Original line number Diff line number Diff line
@@ -10,40 +10,52 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource

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

*** Test Cases ***    FILENAME
D018_01 Loop Detection With Header Via
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    5_6_6    6_3_18
    vehicle-simple-attributes.jsonld
*** Variables ***
${entity_payload_filename}           vehicle-simple-attributes.jsonld
${registration_payload_file_path}    csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld


*** Keywords ***
Create Entity Scenarios
*** Test Cases ***
D018_01 Loop Detection With Via Header
    [Documentation]    Verify that a loop is detected when the Via header contains the broker's identifier.
    [Arguments]    ${filename}
    [Tags]    since_v1.8.1    dist-ops    4_3_3    cf_06    5_6_6    6_3_18
    
    ${entity_id}=    Generate Random Vehicle Entity Id
    Set Test Variable    ${entity_id}
    ${response}=    Create Entity    ${filename}    ${entity_id}    local=true
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    Wait For Request
    ${response}=    Get Request Headers
    ${payload}=    Convert To Dictionary    ${response}
    ${expected_payload}=    Get From Dictionary    ${payload}    Via
    ${expected_via_header}=    Get From Dictionary    ${payload}    Via

    ${response}=   Delete Entity    ${entity_id}    local=true
    ${response}=    Delete Entity    ${entity_id}
    Check Response Status Code    508    ${response.status_code}

    Wait For Request
    ${response}=    Get Request Headers
    ${payload}=    Convert To Dictionary    ${response}
    ${actual_payload}=    Get From Dictionary    ${payload}    Via
    ${actual_via_header}=    Convert To Dictionary    ${response}
    Should Contain    ${actual_via_header}    ${expected_via_header}

    Should Be Equal    ${actual_payload}    ${expected_payload}
    Reply By    508
*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
    ${entity_id}=    Generate Random Vehicle Entity Id
    Set Test Variable    ${entity_id}

    ${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=inclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}

    Start Context Source Mock Server

Delete Initial Entity
    Delete Entity    ${entity_id}    local=true
Delete Registrations And Stop Context Source Mock Server
    Delete Entity    ${entity_id}
    Delete Context Source Registration    ${registration_id}
    Stop Context Source Mock Server
+4 −4
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the request contains the VIA when forwarding operations to the Context Broker
Documentation       Verify that the request contains the Via header when forwarding operations to the Context Broker

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
@@ -18,9 +18,9 @@ ${entity_payload_filename} vehicle-simple-attributes.jsonld
${registration_payload_file_path}    csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld

*** Test Cases ***
D018_02 Check Via Header For Loop Detection
    [Documentation]    Verify that the request contains the VIA when forwarding operations to the Context Broker
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    5_6_6    6_3_18
D018_02 Check Via Header Forwarding To Context Source
    [Documentation]    Verify that the request contains the Via header when forwarding operations to the Context Source
    [Tags]    since_v1.8.1    dist-ops    4_3_3    cf_06    additive-inclusive    5_6_6    6_3_18

    Set Stub Reply    DELETE    /broker1/ngsi-ld/v1/entities/${entity_id}    204
    ${response}=    Delete Entity    ${entity_id}
+15 −15
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the request contains both the VIA header from the Context Broker and the Via from the Context Source
Documentation       Verify that the request contains both the Via header from the Context Broker and the Via from the Context Source

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
@@ -18,9 +18,18 @@ ${entity_payload_filename} vehicle-simple-attributes.jsonld
${registration_payload_file_path}    csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld

*** Test Cases ***
D018_03 Check Via Header For Loop Detection
    [Documentation]    Verify that the request contains both the VIA header from the Context Broker and the Via from the Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    5_6_6    6_3_18
D018_03 Check Via Header Forwarding To Context Source
    [Documentation]    Verify that the request contains the Via header from both the Context Broker and the Context Source
    [Tags]    since_v1.8.1    dist-ops    4_3_3    cf_06    additive-inclusive    5_6_6    6_3_18

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

    Wait For Request
    ${response}=    Get Request Headers
    ${payload}=    Convert To Dictionary    ${response}
    ${create_via_header}=    Get From Dictionary    ${payload}    Via
    Set Suite Variable    ${create_via_header}

    Set Stub Reply    DELETE    /broker1/ngsi-ld/v1/entities/${entity_id}    204
    ${response}=    Delete Entity    ${entity_id}
@@ -28,22 +37,13 @@ D018_03 Check Via Header For Loop Detection

    Wait For Request
    ${response}=    Get Request Headers
    ${payload}=    Convert To Dictionary    ${response}
    Dictionary Should Contain Key    ${payload}    Via
    Dictionary Should Contain Key    ${payload}    ${expected_payload}
    ${delete_via_header}=    Convert To Dictionary    ${response}
    Should Contain    ${delete_via_header}    ${create_via_header}

*** 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}
    Check Response Status Code    201    ${response.status_code}

    Wait For Request
    ${response}=    Get Request Headers
    ${payload}=    Convert To Dictionary    ${response}
    ${expected_payload}=    Get From Dictionary    ${payload}    Via
    Set Suite Variable    ${expected_payload}

    ${registration_id}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id}