diff --git a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/UpdateEntityAttributes/D004_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/UpdateEntityAttributes/D004_01_exc.robot new file mode 100644 index 0000000000000000000000000000000000000000..c9db6eac0b0162c207679c17b1ef7f15e781b096 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/UpdateEntityAttributes/D004_01_exc.robot @@ -0,0 +1,63 @@ +*** Settings *** +Documentation Verify that an entity with an exclusive attribute is registered on the Context Source and said attribute can be updated via the Context Broker with redirectionOps + +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource + +Test Setup Create Entity And Registration And Start Context Source Mock Server +Test Teardown Delete Created Entity And Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_id_prefix} urn:ngsi-ld:Vehicle: +${entity_payload_filename} vehicle-simple-attributes.jsonld +${entity_speed_filename} vehicle-speed-attribute.jsonld +${entity_newSpeed_filename} vehicle-speed-different-attribute.jsonld +${registration_id_prefix} urn:ngsi-ld:Registration: +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed.jsonld + +*** Test Cases *** +D004_01_exc Create Entity and Registration And Start Context Source Mock Server + [Documentation] Check that the entity is updated correctly in the Context Source via redirectionOps + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_2 + + Set Stub Reply PATCH /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/ 204 + ${response}= Update Entity Attributes + ... ${entity_id} + ... ${entity_newSpeed_filename} + ... ${CONTENT_TYPE_LD_JSON} + ${response}= Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count PATCH /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/ + Should Be True ${stub_count} > 0 + +*** Keywords *** +Create Entity And Registration 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} local=${True} + Check Response Status Code 201 ${response.status_code} + + ${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=exclusive + ... endpoint=/broker1 + ${response}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response.status_code} + + Start Context Source Mock Server + +Delete Created Entity And Registration And Stop Context Source Mock Server + Delete Context Source Registration ${registration_id} + Delete Entity By Id ${entity_id} + Stop Context Source Mock Server \ No newline at end of file diff --git a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/UpdateEntityAttributes/D004_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/UpdateEntityAttributes/D004_01_red.robot new file mode 100644 index 0000000000000000000000000000000000000000..271bc9167344eda69c324bfb2cf6613079a3155a --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/UpdateEntityAttributes/D004_01_red.robot @@ -0,0 +1,72 @@ +*** Settings *** +Documentation Verify that, when one has a redirect registration on a Context Broker with redirectionOps, one is able to update the entity on the Context Source + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Test Setup Setup Registration And Start Context Source Mock Server +Test Teardown Delete Registration And Stop Context Source Mock Server + + +*** Variables *** +${entity_payload_filename} vehicle-simple-attributes.jsonld +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld +${fragment_filename} vehicle-brandname-complete-fragment.jsonld + +*** Test Cases *** +D004_01_red Query The Context Broker With Type + [Documentation] Check that if one request the Context Broker to update an entity that matches an inclusive registration, this is updated on the Context Source too + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_2 + + Set Stub Reply PATCH /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/ 204 + Set Stub Reply PATCH /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/ 204 + + ${response}= Update Entity Attributes + ... ${entity_id} + ... ${fragment_filename} + ... ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count PATCH /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/ + Should Be True ${stub_count} > 0 + ${stub_count}= Get Stub Count PATCH /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/ + Should Be True ${stub_count} > 0 + +*** Keywords *** +Setup Registration And Start Context Source Mock Server + ${entity_id}= Generate Random Vehicle Entity Id + Set Suite 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=redirect + ... endpoint=/broker1 + ${response1}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response1.status_code} + + ${registration_id2}= Generate Random CSR Id + Set Suite Variable ${registration_id2} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id2} + ... ${registration_payload_file_path} + ... entity_id=${entity_id} + ... mode=redirect + ... endpoint=/broker2 + ${response1}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response1.status_code} + Start Context Source Mock Server + +Delete Registration And Stop Context Source Mock Server + Delete Context Source Registration ${registration_id} + Delete Context Source Registration ${registration_id2} + Stop Context Source Mock Server \ No newline at end of file diff --git a/data/csourceRegistrations/context-source-registration-vehicle-speed.jsonld b/data/csourceRegistrations/context-source-registration-vehicle-speed.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..b1798060b56ef16a88b88829b549d2cad3f63e69 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-vehicle-speed.jsonld @@ -0,0 +1,21 @@ +{ + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle" + } + + ], + "propertyNames":["speed"] + } + ], + "operations": ["redirectionOps"], + "endpoint": "http://my.csource.org:1026/", + "@context":[ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-speed-different-attribute.jsonld b/data/entities/fragmentEntities/vehicle-speed-different-attribute.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..dc6f3b8025e6dd878202b0c2483a08b05c2e043a --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-speed-different-attribute.jsonld @@ -0,0 +1,15 @@ +{ + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "speed": { + "type": "Property", + "value": 66, + "source": { + "type": "Property", + "value": "Speedometer" + } + }, + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] +} \ No newline at end of file diff --git a/data/entities/vehicle-speed-attribute.jsonld b/data/entities/vehicle-speed-attribute.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..7462308062d285ff87c0f12443638ed30d202b39 --- /dev/null +++ b/data/entities/vehicle-speed-attribute.jsonld @@ -0,0 +1,15 @@ +{ + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "speed": { + "type": "Property", + "value": 56, + "source": { + "type": "Property", + "value": "Speedometer" + } + }, + "@context": [ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] +} \ No newline at end of file