Commit a397de81 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

Merge branch 'fix/type-validation' into 'develop'

fix: type validation

See merge request !196
parents cfae22a3 ef11dd05
Loading
Loading
Loading
Loading
+20 −22
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot query entities if the requested entity types are incorrect
Documentation       Check that one cannot query entities if the requested id pattern is incorrect

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
@@ -12,22 +12,20 @@ Suite Teardown Delete Entities


*** Variables ***
${building_filename}=           building-minimal.jsonld
${vehicle_filename}=            vehicle-simple-attributes.jsonld
${invalid_entity_type_one}=     type
${invalid_entity_type_two}=     invalid_entity_type_two
${filename}=                        building-minimal.jsonld
${entity_type}=                     https://ngsi-ld-test-suite/context#Building
${invalid_entity_id_pattern}=       invalid_entity_id_pattern**


*** Test Cases ***
019_03_02 Query entities based on incorrect entity types
    [Documentation]    Check that one cannot query entities if the requested entity types are incorrect
019_03_02 Query several entities based on incorrect id pattern
    [Documentation]    Check that one cannot query entities if the requested id pattern is incorrect
    [Tags]    e-query    5_7_2
    ${entity_types_to_be_retrieved}=    Catenate
    ...    SEPARATOR=,
    ...    ${invalid_entity_type_one}
    ...    ${invalid_entity_type_two}
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    ${entity_type}

    ${response}=    Query Entities    entity_types=${entity_types_to_be_retrieved}
    ${response}=    Query Entities
    ...    entity_id_pattern=${invalid_entity_id_pattern}
    ...    entity_types=${entity_types_to_be_retrieved}

    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
@@ -38,21 +36,21 @@ ${invalid_entity_type_two}= invalid_entity_type_two

*** Keywords ***
Create Entities
    ${building_entity_id}=    Generate Random Building Entity Id
    Set Suite Variable    ${building_entity_id}
    ${first_entity_id}=    Generate Random Building Entity Id
    Set Suite Variable    ${first_entity_id}
    ${create_response1}=    Create Entity Selecting Content Type
    ...    ${building_filename}
    ...    ${building_entity_id}
    ...    ${filename}
    ...    ${first_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response1.status_code}
    ${vehicle_entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${vehicle_entity_id}
    ${second_entity_id}=    Generate Random Building Entity Id
    Set Suite Variable    ${second_entity_id}
    ${create_response2}=    Create Entity Selecting Content Type
    ...    ${vehicle_filename}
    ...    ${vehicle_entity_id}
    ...    ${filename}
    ...    ${second_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response2.status_code}

Delete Entities
    Delete Entity by Id    ${building_entity_id}
    Delete Entity by Id    ${vehicle_entity_id}
    Delete Entity by Id    ${first_entity_id}
    Delete Entity by Id    ${second_entity_id}
+9 −10
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot query entities if the requested id pattern is incorrect
Documentation       Check that one cannot query entities if the requested attribute names are incorrect

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
@@ -14,18 +14,17 @@ Suite Teardown Delete Entities
*** Variables ***
${filename}=                    building-minimal.jsonld
${entity_type}=                 https://ngsi-ld-test-suite/context#Building
${invalid_entity_id_pattern}=       invalid_entity_id_pattern**
${invalid_attribute_one}=       id
${invalid_attribute_two}=       type


*** Test Cases ***
019_03_03 Query several entities based on incorrect id pattern
    [Documentation]    Check that one cannot query entities if the requested id pattern is incorrect
019_03_03 Query several entities based on incorrect attribute names
    [Documentation]    Check that one cannot query entities if the requested attribute names are incorrect
    [Tags]    e-query    5_7_2
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    ${entity_type}
    ${attributes_to_be_retrieved}=    Catenate    SEPARATOR=,    ${invalid_attribute_one}    ${invalid_attribute_two}

    ${response}=    Query Entities
    ...    entity_id_pattern=${invalid_entity_id_pattern}
    ...    entity_types=${entity_types_to_be_retrieved}
    ${response}=    Query Entities    attrs=${attributes_to_be_retrieved}

    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
+18 −10
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot query entities if the requested attribute names are incorrect
Documentation       Check that one cannot query entities if the request has a wrong geometryProperty

Resource            ${EXECDIR}/resources/ApiUtils/Common.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
@@ -12,19 +12,27 @@ Suite Teardown Delete Entities


*** Variables ***
${filename}=                    building-minimal.jsonld
${entity_type}=                 https://ngsi-ld-test-suite/context#Building
${invalid_attribute_one}=       id
${invalid_attribute_two}=       type
${filename}=        building-location-attribute.jsonld
${entity_type}=     Building
${georel}=          invalid
${geometry}=        Point
${coordinates}=     [-8.503,41.202]
${geoproperty}=     location


*** Test Cases ***
019_03_04 Query several entities based on incorrect attribute names
    [Documentation]    Check that one cannot query entities if the requested attribute names are incorrect
019_03_04 Query entities when the request has a wrong geometryProperty
    [Documentation]    Check that one cannot query entities if the request has a wrong geometryProperty
    [Tags]    e-query    5_7_2
    ${attributes_to_be_retrieved}=    Catenate    SEPARATOR=,    ${invalid_attribute_one}    ${invalid_attribute_two}

    ${response}=    Query Entities    attrs=${attributes_to_be_retrieved}
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    ${entity_type}

    ${response}=    Query Entities
    ...    entity_types=${entity_types_to_be_retrieved}
    ...    geoproperty=${geoproperty}
    ...    georel=${georel}
    ...    geometry=${geometry}
    ...    coordinates=${coordinates}
    ...    context=${ngsild_test_suite_context}

    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
+0 −63
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one cannot query entities if the request has a wrong geometryProperty

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

Suite Setup         Create Entities
Suite Teardown      Delete Entities


*** Variables ***
${filename}=        building-location-attribute.jsonld
${entity_type}=     Building
${georel}=          invalid
${geometry}=        Point
${coordinates}=     [-8.503,41.202]
${geoproperty}=     location


*** Test Cases ***
019_03_05 Query entities when the request has a wrong geometryProperty
    [Documentation]    Check that one cannot query entities if the request has a wrong geometryProperty
    [Tags]    e-query    5_7_2
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    ${entity_type}

    ${response}=    Query Entities
    ...    entity_types=${entity_types_to_be_retrieved}
    ...    geoproperty=${geoproperty}
    ...    georel=${georel}
    ...    geometry=${geometry}
    ...    coordinates=${coordinates}
    ...    context=${ngsild_test_suite_context}

    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}


*** Keywords ***
Create Entities
    ${first_entity_id}=    Generate Random Building Entity Id
    Set Suite Variable    ${first_entity_id}
    ${create_response1}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${first_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response1.status_code}
    ${second_entity_id}=    Generate Random Building Entity Id
    Set Suite Variable    ${second_entity_id}
    ${create_response2}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${second_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response2.status_code}

Delete Entities
    Delete Entity by Id    ${first_entity_id}
    Delete Entity by Id    ${second_entity_id}
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@ Test Template Create Entity With Invalid Request Scenarios
001_02_03 EntityWithNoContext
    [Tags]    e-create    5_6_1
    building-minimal.json    ${ERROR_TYPE_BAD_REQUEST_DATA}
001_02_04 EntityWithNoContext
    [Tags]    e-create    5_6_1
    invalid-type.jsonld    ${ERROR_TYPE_INVALID_REQUEST}


*** Keywords ***
Loading