diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot index 9ce9d5cf3ec1545b85b8f71ec270e2e04326e67c..721c3d9900eacd975023c6e69d712d9a601a018c 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot @@ -26,8 +26,8 @@ Create Entity Scenarios ${entity_id}= Generate Random Entity Id ${building_id_prefix} - Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} - Check Response Status Code Set To 201 - Check Response Headers Containing URI set to ${request['path']} ${entity_id} + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} + Check Response Status Code 201 ${response['status']} + Check Response Headers Containing URI set to ${request['path']} ${entity_id} ${response} [Teardown] Delete Entity by Id ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot index 973171d83cf38459cea74ea3f4de4cb0b8a92ddc..bf0050cceaa252870f563e3d99270ee030cb69eb 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot @@ -16,13 +16,14 @@ Create one valid entity and one invalid entity [Tags] mandatory ${entity_id}= Generate Random Entity Id ${building_id_prefix} - Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} - Check Response Status Code Set To 201 + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} + Check Response Status Code 201 ${response['status']} #creating entity with the same id - Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} - Check Response Status Code Set To 409 - Check Response Body Details Containing Information Error ${expected_error_message} + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} + Check Response Status Code 409 ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_ALREADY_EXISTS} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} [Teardown] Delete Entity by Id ${entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/004.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/004.robot new file mode 100644 index 0000000000000000000000000000000000000000..ca6c0422bf09c4ff97f2b7d4665fc157b6d204df --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/004.robot @@ -0,0 +1,20 @@ +*** Settings *** +Documentation Check that you can delete an entity by id +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${building_id_prefix}= urn:ngsi-ld:Building: + +*** Test Case *** +004_Delete an entity + [Documentation] Check that you can delete an entity by id + [Tags] mandatory + + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type building-simple-attributes-sample.jsonld ${entity_id} application/ld+json + Check Response Status Code 201 ${response['status']} + + ${response}= Delete Entity by Id Returning Response ${entity_id} + Check Response Status Code 204 ${response['status']} diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/005.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/005.robot new file mode 100644 index 0000000000000000000000000000000000000000..1e23d9294b8685649c01441ff874da739f828674 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/005.robot @@ -0,0 +1,28 @@ +*** Settings *** +Documentation Check that you cannot delete an entity with invalid/missing id +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Template Delete Entity Scenarios + +*** Variable *** +${entity_id_empty}= +${entity_id_not_valid}= thisisaninvaliduri + +*** Test Cases *** ENTITY_ID EXPECTED_STATUS_CODE PROBLEM_TYPE +005_01_Delete an entity if the Entity Id is not present ${entity_id_empty} 400 ${ERROR_TYPE_BAD_REQUEST_DATA} +005_02_Delete an entity if the Entity Id is not a valid URI ${entity_id_not_valid} 400 ${ERROR_TYPE_BAD_REQUEST_DATA} + + + +*** Keywords *** +Delete Entity Scenarios + [Arguments] ${entity_id} ${expected_status_code} ${problem_type} + [Documentation] Check that you cannot delete an entity with invalid/missing id + [Tags] mandatory failing + + ${response}= Delete Entity by Id Returning Response ${entity_id} + Check Response Status Code ${expected_status_code} ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${problem_type} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/006.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/006.robot new file mode 100644 index 0000000000000000000000000000000000000000..b71875cf912ac6f06289beff802a67f8b9dad9ec --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/DeleteEntity/006.robot @@ -0,0 +1,21 @@ +*** Settings *** +Documentation Check that you cannot delete an entity if the entity id is not known to the system +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${building_id_prefix}= urn:ngsi-ld:Building: +${expected_status_code}= 404 + +*** Test Case *** +006_Delete an entity with an id not known to the system + [Documentation] Check that you cannot delete an entity if the entity id is not known to the system + [Tags] mandatory + + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + + ${response}= Delete Entity by Id Returning Response ${entity_id} + Check Response Status Code ${expected_status_code} ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_RESOURCE_NOT_FOUND} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 9bd4b663ce3e19d72e33dbb27575ffb4b2d28357..cf0f717f7e8ea9d8417418bd0d8ddde653d4fc15 100644 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -21,7 +21,8 @@ ${CONTENT_TYPE_LD_JSON} application/ld+json ${ERROR_TYPE_BAD_REQUEST_DATA} http://uri.etsi.org/ngsi-ld/errors/BadRequestData ${ERROR_TYPE_INVALID_REQUEST} http://uri.etsi.org/ngsi-ld/errors/InvalidRequest -${ERROR_TYPE_RESOURCE_NOT_FOUND} https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound +${ERROR_TYPE_RESOURCE_NOT_FOUND} http://uri.etsi.org/ngsi-ld/errors/ResourceNotFound +${ERROR_TYPE_ALREADY_EXISTS} http://uri.etsi.org/ngsi-ld/errors/AlreadyExists ${response} @@ -50,6 +51,13 @@ Api DEL request Output Schema Set Test Variable ${response} +Delete Entity by Id Returning Response + [Arguments] ${id} + ${response}= DELETE ${ENTITIES_ENDPOINT_PATH}${id} + Output request + Output response + [return] ${response} + Delete Entity by Id [Arguments] ${id} ${response}= DELETE ${ENTITIES_ENDPOINT_PATH}${id} @@ -75,9 +83,8 @@ Create Entity Selecting Content Type ${response}= POST ${ENTITIES_ENDPOINT_PATH} body=${entity} headers=${headers} Output request Output response - Set Test Variable ${response} ${request}= Output request - Set Test Variable ${request} + [return] ${request} ${response} Create Entity [Arguments] ${filename} ${entity_id} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 52d195074def0d40f8f5719caf91a37783cbdd03..a648ed4ebc0faf3af86f3ec628ab3be64aa3eaff 100644 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -5,6 +5,11 @@ Library ${EXECDIR}/libraries/assertionUtils.py ${instance_id_regex_expr}= root\\[.*\\]\\['instanceId'\\] *** Keywords *** +Check Response Status Code + [Arguments] ${expected_status_code} ${response_status_code} + ${response_status_code}= convert to string ${response_status_code} + Should Be Equal ${expected_status_code} ${response_status_code} + Check Response Status Code Set To [Arguments] ${expected_status} ${response_status}= convert to string ${response['status']} @@ -23,8 +28,7 @@ Check Response Body Containing Array Of URIs set to Lists Should Be Equal ${expected_entities_ids} ${response['body']} ignore_order=True Check Response Headers Containing URI set to -# upon success, the http response shall include a loication http header that countains the uri of the created entity resource - [Arguments] ${expected_path} ${expected_entity_id} + [Arguments] ${expected_path} ${expected_entity_id} ${response} Should Be Equal ${expected_path}${expected_entity_id} ${response['headers']['location']} ignore_order=True Check Response Body Containing an Attribute set to diff --git a/resources/variables.py b/resources/variables.py index 88e1f536955c150a7437b12fde7f9f48819e492a..3b9e617a6e6abcb6815f18384ad0ee3fc278f344 100644 --- a/resources/variables.py +++ b/resources/variables.py @@ -1,6 +1,6 @@ def get_variables(arg=None): variables = { - 'url': 'http://localhost:9090/ngsi-ld/v1', + 'url': 'https://broker-ngsi-ld.demeter.ubiwhere.com/ngsi-ld/v1', 'ngsild_test_suite_context': 'https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld' } return variables