Commit 9fcad4fc authored by kzangeli's avatar kzangeli
Browse files

fix(D011): query-forward assertions vs broker-correct behaviour

- stub URLs used attrs= for the forwarded projection; attrs is also
  entity SELECTION (an entity with none of the listed attributes does
  not match), so a broker must not forward it — split entities held
  partially at a source would be silently dropped. Brokers forward the
  projection-only pick= instead; the stubs now expect that form
  (D011_01_02/03/04_inc, D011_01_exc, D011_02_exc)
- Query Entities Via POST sent Content-Type application/ld+json with
  the @context in a Link header and none in the body — illegal both
  ways (TS 104-176 clause 6.2.4). For ld+json the @context now goes in
  the body; the Link form stays for plain json
- D011_02_exc: the fixture's redirectionOps group does not include
  queryBatch (TS 104-175 Table 9.2-2) — the POST variant now restricts
  the registration to the operation under test, as D011_03_inc already
  does
- HttpCtrl POST /entityOperations/query stub matching crashed on array
  stub bodies (response_body['type'] on a list) and KeyError'd when the
  request selector carried no id; rewritten as a tolerant helper that
  also accepts the expanded-IRI form of a term where the stub uses the
  short name (the GET matcher's substring check already tolerated
  this)
parent d9a20233
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ D011_01_02_inc Query The Context Broker With Type And Missing Attribute
    ...    Contrast with D011_01_04, where a local entity also exists but also lacks the queried attribute.
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_7_2
    ${empty_response}=    Create Empty Array Result
    Set Stub Reply    GET    /ngsi-ld/v1/entities?attrs=speed&type=Vehicle    200    ${empty_response}
    Set Stub Reply    GET    /ngsi-ld/v1/entities?pick=speed&type=Vehicle    200    ${empty_response}

    ${response}=    Query Entities    entity_types=Vehicle    attrs=speed    context=${ngsild_test_suite_context}

+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ D011_01_03_inc Query The Context Broker With Type And Attribute
    ...    entity gets returned
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_7_2
    ${serialized_entity}=    Load Entity As Serialized Array    ${entity_payload_filename2}    ${second_entity_id}
    Set Stub Reply    GET    /ngsi-ld/v1/entities?attrs=isParked2&type=Vehicle    200    ${serialized_entity}
    Set Stub Reply    GET    /ngsi-ld/v1/entities?pick=isParked2&type=Vehicle    200    ${serialized_entity}

    ${response}=    Query Entities    entity_types=Vehicle    attrs=isParked2    context=${ngsild_test_suite_context}

+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ D011_01_04_inc Query The Context Broker With Type And Attribute In Neither
    ...    returned. Contrast with D011_01_02, where no local entity exists at all.
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_7_2
    ${empty_response}=    Create Empty Array Result
    Set Stub Reply    GET    /ngsi-ld/v1/entities?attrs=speed&type=Vehicle    200    ${empty_response}
    Set Stub Reply    GET    /ngsi-ld/v1/entities?pick=speed&type=Vehicle    200    ${empty_response}

    ${response}=    Query Entities    entity_types=Vehicle    attrs=speed    context=${ngsild_test_suite_context}

+2 −2
Original line number Diff line number Diff line
@@ -30,14 +30,14 @@ D011_01_exc Query The Context Broker With Type
    ${serialized_entity}=    Load Entity As Serialized Array    ${entity_speed_filename}    ${entity_id}
    Set Stub Reply
    ...    GET
    ...    /broker1/ngsi-ld/v1/entities?type=Vehicle&id=${entity_id}&attrs=speed
    ...    /broker1/ngsi-ld/v1/entities?type=Vehicle&id=${entity_id}&pick=speed
    ...    200
    ...    ${serialized_entity}

    ${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&id=${entity_id}&attrs=speed
    ${stub_count}=    Get Stub Count    GET    /broker1/ngsi-ld/v1/entities?type=Vehicle&id=${entity_id}&pick=speed
    Should Be True    ${stub_count} > 0

    Should Have Value In Json    ${response.json()[0]}    $.speed
+10 −1
Original line number Diff line number Diff line
@@ -46,12 +46,21 @@ Setup Registration And Context Source Mock Server And Query The Context Broker W

    ${registration_id}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id}
    # The fixture's redirectionOps group does NOT include queryBatch
    # (TS 104-175 Table 9.2-2) — restrict to the operation under test so
    # the broker picks the matching forward form.
    IF    '${method}' == 'POST'
        ${operations}=    Create List    queryBatch
    ELSE
        ${operations}=    Create List    queryEntity
    END
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    mode=exclusive
    ...    endpoint=/broker1
    ...    operations=${operations}
    ${response1}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response1.status_code}
    Start Context Source Mock Server
@@ -60,7 +69,7 @@ Setup Registration And Context Source Mock Server And Query The Context Broker W
    @{entities_id}=    Create List    ${entity_id}

    IF    '${method}' == 'GET'
        Set Stub Reply    ${method}    ${url}?type=Vehicle&id=${entity_id}&attrs=speed    200    ${serialized_entity}
        Set Stub Reply    ${method}    ${url}?type=Vehicle&id=${entity_id}&pick=speed    200    ${serialized_entity}
        ${response2}=    Query Entities    entity_types=Vehicle    context=${ngsild_test_suite_context}
    ELSE IF    '${method}' == 'POST'
        Set Stub Reply    ${method}    ${url}    200    ${serialized_entity}
Loading