Commit e2f64e67 authored by Ken Zangelin's avatar Ken Zangelin
Browse files

feat(head): add TCs for HEAD on the Attribute, the Attribute value and...

feat(head): add TCs for HEAD on the Attribute, the Attribute value and /info/sourceIdentity (061_03, 061_04)
parent 582a0fd2
Loading
Loading
Loading
Loading
+58 −0
Changes for TP/NGSI-LD/CommonBehaviours/CommonResponses/VerifyHEAD/061_03.robot: 58 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that a HEAD request on the Attribute, the Attribute value and the context source identity functions in the same manner as a GET request, and that the response code 204 No Content, without Content-Length, is used on success

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

Suite Setup         Create Initial Entity
Suite Teardown      Delete Initial Entity


*** Variables ***
${building_filename}=       building-simple-attributes.jsonld


*** Test Cases ***
061_03_01 Endpoint /entities/{entityId}/attrs/{attrId}
    [Documentation]    Verify that a HEAD request on /entities/{entityId}/attrs/{attrId} is answered with 204 No Content, without Content-Length
    [Tags]    since_ts104_v1.1.1    ea-retrieve    cb-head    http_5    http_7_5_3_1
    ${response}=    Request With HEAD
    ...    path=entities/${entity_id}/attrs/name
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}
    Check Response Body Is Empty    ${response}
    Check Response Headers Not Containing Content-Length    ${response.headers}

061_03_02 Endpoint /entities/{entityId}/attrs/{attrId}/value
    [Documentation]    Verify that a HEAD request on /entities/{entityId}/attrs/{attrId}/value is answered with 204 No Content, without Content-Length
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    cb-head    http_5    http_7_6_3_1
    ${response}=    Request With HEAD
    ...    path=entities/${entity_id}/attrs/name/value
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}
    Check Response Body Is Empty    ${response}
    Check Response Headers Not Containing Content-Length    ${response.headers}

061_03_03 Endpoint /info/sourceIdentity
    [Documentation]    Verify that a HEAD request on /info/sourceIdentity is answered with 204 No Content, without Content-Length
    [Tags]    since_ts104_v1.1.1    csi-retrieve    cb-head    http_5    http_12_2_3_1
    ${response}=    Request With HEAD
    ...    path=info/sourceIdentity
    Check Response Status Code    204    ${response.status_code}
    Check Response Body Is Empty    ${response}
    Check Response Headers Not Containing Content-Length    ${response.headers}


*** Keywords ***
Create Initial Entity
    ${entity_id}=    Generate Random Building Entity Id
    ${response}=    Create Entity Selecting Content Type
    ...    ${building_filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    Set Suite Variable    ${entity_id}

Delete Initial Entity
    Delete Entity    ${entity_id}
+59 −0
Changes for TP/NGSI-LD/CommonBehaviours/CommonResponses/VerifyHEAD/061_04.robot: 59 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that a HEAD request on the Attribute or the Attribute value that the corresponding GET request would answer with an error is answered with the same error status code

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

Suite Setup         Create Initial Entity
Suite Teardown      Delete Initial Entity
Test Template       Request With HEAD Answered With An Error


*** Variables ***
${building_filename}=       building-simple-attributes.jsonld


*** Test Cases ***    PATH    CONTEXT    EXPECTED_STATUS_CODE
061_04_01 Endpoint /entities/{entityId}/attrs/{attrId} If The Attribute Is Not Known
    [Tags]    since_ts104_v1.1.1    ea-retrieve    cb-head    http_5    http_7_5_3_1
    entities/${entity_id}/attrs/unknownAttribute    ${ngsild_test_suite_context}    404
061_04_02 Endpoint /entities/{entityId}/attrs/{attrId}/value If The Attribute Is Not Known
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    cb-head    http_5    http_7_6_3_1
    entities/${entity_id}/attrs/unknownAttribute/value    ${ngsild_test_suite_context}    404
061_04_03 Endpoint /entities/{entityId}/attrs/{attrId}/value If The Entity Is Not Known
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    cb-head    http_5    http_7_6_3_1
    entities/urn:ngsi-ld:Building:unknown061/attrs/name/value    ${ngsild_test_suite_context}    404
061_04_04 Endpoint /entities/{entityId}/attrs/{attrId} If The Entity Id Is Not A Valid URI
    [Tags]    since_ts104_v1.1.1    ea-retrieve    cb-head    http_5    http_7_5_3_1
    entities/thisisaninvaliduri/attrs/name    ${ngsild_test_suite_context}    400
061_04_05 Endpoint /entities/{entityId}/attrs/{attrId} If The Entity Is Not Known
    [Tags]    since_ts104_v1.1.1    ea-retrieve    cb-head    http_5    http_7_5_3_1
    entities/urn:ngsi-ld:Building:unknown061/attrs/name    ${ngsild_test_suite_context}    404
061_04_06 Endpoint /entities/{entityId}/attrs/{attrId}/value If The Entity Id Is Not A Valid URI
    [Tags]    since_ts104_v1.1.1    ea-retrieve-value    cb-head    http_5    http_7_6_3_1
    entities/thisisaninvaliduri/attrs/name/value    ${ngsild_test_suite_context}    400


*** Keywords ***
Create Initial Entity
    ${entity_id}=    Generate Random Building Entity Id
    ${response}=    Create Entity Selecting Content Type
    ...    ${building_filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    Set Suite Variable    ${entity_id}

Delete Initial Entity
    Delete Entity    ${entity_id}

Request With HEAD Answered With An Error
    [Documentation]    Verify that a HEAD request that the GET request would answer with an error gets the same status code
    [Arguments]    ${path}    ${context}    ${expected_status_code}

    ${response}=    Request With HEAD
    ...    path=${path}
    ...    context=${context}
    Check Response Status Code    ${expected_status_code}    ${response.status_code}
    Check Response Body Is Empty    ${response}