From 3d92105e890f20d78ae5f23c8fa68a7988cc3623 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 08:29:15 +0100 Subject: [PATCH 01/14] fix(037_10): wrong q query / remove csf permutation --- .../037_10.robot | 9 +- ...registration-csourceProperty-sample.jsonld | 23 ++++ ...e-registrations-037-10-01-expectation.json | 75 +++++------ ...e-registrations-037-10-02-expectation.json | 47 +++---- ...e-registrations-037-10-03-expectation.json | 117 +++++++++--------- resources/AssertionUtils.resource | 2 +- 6 files changed, 154 insertions(+), 119 deletions(-) create mode 100644 data/csourceRegistrations/context-source-registration-csourceProperty-sample.jsonld diff --git a/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_10.robot b/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_10.robot index 22e2d184..cf87f232 100644 --- a/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_10.robot +++ b/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_10.robot @@ -15,19 +15,16 @@ Test Template Query Context Source Registration With Query Params ${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: ${first_context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld ${second_context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-detailed-information-sample.jsonld -${third_context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-location-sample.jsonld +${third_context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-csourceProperty-sample.jsonld *** Test Cases *** QUERY_PARAM_NAME QUERY_PARAM_VALUE EXPECTATION_FILE_PATH EXPECTED_CONTEXT_SOURCE_REGISTRATION_IDS 037_10_01 With list of Entity Ids [Tags] csr-query 5_10_2 - id ${first_context_source_registration_id},${third_context_source_registration_id} csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json ${first_context_source_registration_id} ${third_context_source_registration_id} + id ${first_context_source_registration_id},${third_context_source_registration_id} csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json ${first_context_source_registration_id},${third_context_source_registration_id} 037_10_02 With NGSI-LD Query [Tags] csr-query 5_10_2 - q location.type=="GeoProperty" csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json ${third_context_source_registration_id} -037_10_03 With Context Source Filter - [Tags] csr-query 5_10_2 - csf endpoint=="http://my.csource.org:1026" csourceRegistrations/expectations/context-source-registrations-037-10-03-expectation.json ${first_context_source_registration_id} ${second_context_source_registration_id} ${third_context_source_registration_id} + q csourceProperty1=="aValue" csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json ${third_context_source_registration_id} *** Keywords *** diff --git a/data/csourceRegistrations/context-source-registration-csourceProperty-sample.jsonld b/data/csourceRegistrations/context-source-registration-csourceProperty-sample.jsonld new file mode 100644 index 00000000..a76f1967 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-csourceProperty-sample.jsonld @@ -0,0 +1,23 @@ +{ + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "location":{ + "type":"Point", + "coordinates":[-8.521,41.2] + }, + "endpoint":"http://my.csource.org:1026", + "csourceProperty1": "aValue", + "csourceProperty2": "anotherValue", + "@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/csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json b/data/csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json index 25b886f0..3240674a 100644 --- a/data/csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json +++ b/data/csourceRegistrations/expectations/context-source-registrations-037-10-01-expectation.json @@ -1,37 +1,42 @@ [ - { - "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", - "type":"ContextSourceRegistration", - "information":[ - { - "entities":[ - { - "type":"Building" - } - ] - } - ], - "endpoint":"http://my.csource.org:1026" - }, - { - "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", - "type":"ContextSourceRegistration", - "information":[ - { - "entities":[ - { - "type":"Building" - } - ] - } - ], - "location":{ - "type":"GeoProperty", - "value":{ - "type":"Point", - "coordinates":[-8.521,41.2] - } - }, - "endpoint":"http://my.csource.org:1026" - } + { + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "type": "Building" + } + ] + } + ], + "endpoint": "http://my.csource.org:1026" + }, + { + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "type": "Building" + } + ] + } + ], + "location": { + "type": "Point", + "coordinates": [ + -8.521, + 41.2 + ] + }, + "endpoint": "http://my.csource.org:1026", + "csourceProperty1": "aValue", + "csourceProperty2": "anotherValue", + "@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/csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json b/data/csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json index c462e3a6..28836a2e 100644 --- a/data/csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json +++ b/data/csourceRegistrations/expectations/context-source-registrations-037-10-02-expectation.json @@ -1,23 +1,28 @@ [ - { - "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", - "type":"ContextSourceRegistration", - "information":[ - { - "entities":[ - { - "type":"Building" - } - ] - } - ], - "location":{ - "type":"GeoProperty", - "value":{ - "type":"Point", - "coordinates":[-8.521,41.2] - } - }, - "endpoint":"http://my.csource.org:1026" - } + { + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "type": "Building" + } + ] + } + ], + "location": { + "type": "Point", + "coordinates": [ + -8.521, + 41.2 + ] + }, + "endpoint": "http://my.csource.org:1026", + "csourceProperty1": "aValue", + "csourceProperty2": "anotherValue", + "@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/csourceRegistrations/expectations/context-source-registrations-037-10-03-expectation.json b/data/csourceRegistrations/expectations/context-source-registrations-037-10-03-expectation.json index 0d7f5b3c..74af173b 100644 --- a/data/csourceRegistrations/expectations/context-source-registrations-037-10-03-expectation.json +++ b/data/csourceRegistrations/expectations/context-source-registrations-037-10-03-expectation.json @@ -1,58 +1,63 @@ [ - { - "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", - "type":"ContextSourceRegistration", - "information":[ - { - "entities":[ - { - "type":"Building" - } - ] - } - ], - "endpoint":"http://my.csource.org:1026" - }, - { - "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", - "type":"ContextSourceRegistration", - "information":[ - { - "entities":[ - { - "type":"Building" - } - ], - "propertyNames":[ - "name", - "subCategory" - ], - "relationshipNames":[ - "locatedAt" - ] - } - ], - "endpoint":"http://my.csource.org:1026" - }, - { - "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", - "type":"ContextSourceRegistration", - "information":[ - { - "entities":[ - { - "type":"Building" - } - ] - } - ], - "location":{ - "type":"GeoProperty", - "value":{ - "type":"Point", - "coordinates":[-8.521,41.2] - } - }, - "endpoint":"http://my.csource.org:1026" - } + { + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "type": "Building" + } + ] + } + ], + "endpoint": "http://my.csource.org:1026" + }, + { + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "type": "Building" + } + ], + "propertyNames": [ + "name", + "subCategory" + ], + "relationshipNames": [ + "locatedAt" + ] + } + ], + "endpoint": "http://my.csource.org:1026" + }, + { + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "type": "Building" + } + ] + } + ], + "location": { + "type": "Point", + "coordinates": [ + -8.521, + 41.2 + ] + }, + "endpoint": "http://my.csource.org:1026", + "csourceProperty1": "aValue", + "csourceProperty2": "anotherValue", + "@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/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 0f7c783f..3b98a4d3 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -236,7 +236,7 @@ Check Response Body Containing Context Source Registration element ${context_source_registration_payload}= Load JSON From File ${EXECDIR}/data/${expectation_filename} ${context_source_registration}= Update Value To JSON ... ${context_source_registration_payload} - ... $..id + ... $.id ... ${context_source_registration_id} ${ignored_keys}= Create List ${context_regex_expr} ${comparison_result}= Compare Dictionaries Ignoring Keys -- GitLab From 613ad4e8dd505474bca030c7237af49105f5f0dc Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 08:35:13 +0100 Subject: [PATCH 02/14] fix(037_11): replace page by offset in pagination query --- .../QueryContextSourceRegistrations/037_11.robot | 16 ++++++++-------- .../ApiUtils/ContextSourceDiscovery.resource | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_11.robot b/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_11.robot index 9fd5f987..42da3269 100644 --- a/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_11.robot +++ b/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_11.robot @@ -8,7 +8,7 @@ Resource ${EXECDIR}/resources/JsonUtils.resource Test Setup Setup Initial Context Source Registrations Test Teardown Delete Created Context Source Registrations -Test Template Query Context Source Registration With Limit And Page Parameters +Test Template Query Context Source Registration With Limit And Offset Parameters *** Variables *** @@ -18,27 +18,27 @@ ${second_context_source_registration_payload_file_path}= csourceRegistrations ${third_context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-detailed-information-sample.jsonld -*** Test Cases *** LIMIT PAGE EXPECTED_NUMBER PREV_LINK NEXT_LINK +*** Test Cases *** LIMIT OFFSET EXPECTED_NUMBER PREV_LINK NEXT_LINK 037_11_01 Query Second Subscription [Tags] csr-query 5_10_2 - ${1} ${2} ${1} ;rel="prev";type="application/ld+json" ;rel="next";type="application/ld+json" + ${1} ${2} ${1} ;rel="prev";type="application/ld+json" ;rel="next";type="application/ld+json" 037_11_02 Query Last Subscription [Tags] csr-query 5_10_2 - ${2} ${2} ${1} ;rel="prev";type="application/ld+json" ${EMPTY} + ${2} ${2} ${1} ;rel="prev";type="application/ld+json" ${EMPTY} 037_11_03 Query All Subscriptions [Tags] csr-query 5_10_2 - ${15} ${1} ${3} ${EMPTY} ${EMPTY} + ${15} ${0} ${2} ${EMPTY} ${EMPTY} *** Keywords *** -Query Context Source Registration With Limit And Page Parameters +Query Context Source Registration With Limit And Offset Parameters [Documentation] Check that you can query context source registrations with providing page and limit parameters, pagination logic shall be in place as mandated by clause 5.5.9. - [Arguments] ${limit} ${page} ${expected_number} ${prev_link} ${next_link} + [Arguments] ${limit} ${offset} ${expected_number} ${prev_link} ${next_link} ${response}= Query Context Source Registrations ... context=${ngsild_test_suite_context} ... type=Building ... limit=${limit} - ... page=${page} + ... offset=${offset} Check Response Status Code 200 ${response.status_code} Check Response Body Containing Number Of Entities ... ContextSourceRegistration diff --git a/resources/ApiUtils/ContextSourceDiscovery.resource b/resources/ApiUtils/ContextSourceDiscovery.resource index bd7ce200..160f66f9 100755 --- a/resources/ApiUtils/ContextSourceDiscovery.resource +++ b/resources/ApiUtils/ContextSourceDiscovery.resource @@ -32,7 +32,7 @@ Query Context Source Registrations ... ${timerel}=${EMPTY} ... ${timeAt}=${EMPTY} ... ${limit}=${EMPTY} - ... ${page}=${EMPTY} + ... ${offset}=${EMPTY} ... ${accept}=${EMPTY} &{headers}= Create Dictionary @@ -69,7 +69,7 @@ Query Context Source Registrations END IF '${timeAt}'!='' Set To Dictionary ${params} timeAt=${timeAt} IF '${limit}'!='' Set To Dictionary ${params} limit=${limit} - IF '${page}'!='' Set To Dictionary ${params} page=${page} + IF '${offset}'!='' Set To Dictionary ${params} offset=${offset} ${response}= GET ... url=${url}/${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH} @@ -94,7 +94,7 @@ Query Context Source Registrations With Return ... ${timerel}=${EMPTY} ... ${timeAt}=${EMPTY} ... ${limit}=${EMPTY} - ... ${page}=${EMPTY} + ... ${offset}=${EMPTY} ... ${accept}=${EMPTY} &{headers}= Create Dictionary @@ -129,7 +129,7 @@ Query Context Source Registrations With Return END IF '${timeAt}'!='' Set To Dictionary ${params} timeAt=${timeAt} IF '${limit}'!='' Set To Dictionary ${params} limit=${limit} - IF '${page}'!='' Set To Dictionary ${params} page=${page} + IF '${offset}'!='' Set To Dictionary ${params} offset=${offset} ${response}= GET ... url=${url}/${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH} -- GitLab From 85b60b8b5808edb4e1a1d28c23465557e62cdf6a Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 09:14:40 +0100 Subject: [PATCH 03/14] fix(036_01): remove untestable permutation (retrieve CSR without an id) --- .../RetrieveContextSourceRegistration/036_01.robot | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/TP/NGSI-LD/ContextSource/Discovery/RetrieveContextSourceRegistration/036_01.robot b/TP/NGSI-LD/ContextSource/Discovery/RetrieveContextSourceRegistration/036_01.robot index 54d702b4..b0a321ae 100644 --- a/TP/NGSI-LD/ContextSource/Discovery/RetrieveContextSourceRegistration/036_01.robot +++ b/TP/NGSI-LD/ContextSource/Discovery/RetrieveContextSourceRegistration/036_01.robot @@ -1,25 +1,22 @@ *** Settings *** -Documentation Check that you cannot retrieve a Context Source Registration, if the context source registration id is not present or it is not a valid URI +Documentation Check that you cannot retrieve a Context Source Registration, if the context source registration id is not a valid URI Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource Resource ${EXECDIR}/resources/AssertionUtils.resource Resource ${EXECDIR}/resources/JsonUtils.resource -Test Template Retrieve Context Source Registration With A Not Present Or Invalid Id +Test Template Retrieve Context Source Registration With An Invalid Id *** Test Cases *** ID -036_01_01 Not Present Id - [Tags] csr-retrieve 5_10_1 - ${EMPTY} -036_01_02 Invalid Id +036_01_01 Invalid Id [Tags] csr-retrieve 5_10_1 invalidUri *** Keywords *** -Retrieve Context Source Registration With A Not Present Or Invalid Id - [Documentation] Check that you cannot retrieve a Context Source Registration, if the context source registration id is not present or it is not a valid URI +Retrieve Context Source Registration With An Invalid Id + [Documentation] Check that you cannot retrieve a Context Source Registration, if the context source registration id is not a valid URI [Arguments] ${id} ${response}= Retrieve Context Source Registration ... context_source_registration_id=${id} -- GitLab From 3d6c3ae6702a2f229170e71cb50563645dcade5c Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 09:15:24 +0100 Subject: [PATCH 04/14] fix(036_03): incorrect expectation file --- ...t-source-registration-expanded-format.json | 80 ++++++++++++++++--- 1 file changed, 67 insertions(+), 13 deletions(-) diff --git a/data/csourceRegistrations/expectations/context-source-registration-expanded-format.json b/data/csourceRegistrations/expectations/context-source-registration-expanded-format.json index f96e148a..c557935b 100644 --- a/data/csourceRegistrations/expectations/context-source-registration-expanded-format.json +++ b/data/csourceRegistrations/expectations/context-source-registration-expanded-format.json @@ -1,14 +1,68 @@ { - "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", - "type":"ContextSourceRegistration", - "information":[ - { - "entities":[ - { - "type":"https://ngsi-ld-test-suite/context#Building" - } - ] - } - ], - "endpoint":"http://my.csource.org:1026" -} \ No newline at end of file + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "endpoint": "http://my.csource.org:1026", + "information": [ + { + "entities": [ + { + "id": "urn:ngsi-ld:Vehicle:A456", + "type": "https://ngsi-ld-test-suite/context#Vehicle" + } + ], + "propertyNames": [ + "https://ngsi-ld-test-suite/context#brandName", + "https://ngsi-ld-test-suite/context#speed" + ], + "relationshipNames": [ + "isParked" + ] + }, + { + "entities": [ + { + "type": "https://ngsi-ld-test-suite/context#OffStreetParking", + "idPattern": ".*downtown$" + }, + { + "type": "https://ngsi-ld-test-suite/context#OffStreetParking", + "idPattern": ".*47$" + } + ], + "propertyNames": [ + "availableSpotNumber", + "totalSpotNumber" + ], + "relationshipNames": [ + "isNextToBuilding" + ] + } + ], + "location": { + "type": "Polygon", + "coordinates": [ + [ + [ + 100.0, + 0.0 + ], + [ + 101.0, + 0.0 + ], + [ + 101.0, + 1.0 + ], + [ + 100.0, + 1.0 + ], + [ + 100.0, + 0.0 + ] + ] + ] + } +} -- GitLab From a043f5ee690ff855f04a5a09cd90a129c982f6d6 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 09:21:37 +0100 Subject: [PATCH 05/14] fix(036_04): incorrect expectation file --- .../context-source-registration.json | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/data/csourceRegistrations/expectations/context-source-registration.json b/data/csourceRegistrations/expectations/context-source-registration.json index b4a6b06e..a534ebc7 100644 --- a/data/csourceRegistrations/expectations/context-source-registration.json +++ b/data/csourceRegistrations/expectations/context-source-registration.json @@ -1,14 +1,37 @@ { - "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", - "type":"ContextSourceRegistration", - "information":[ - { - "entities":[ - { - "type":"Building" - } - ] - } + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "id": "urn:ngsi-ld:Vehicle:A456", + "type": "Vehicle" + } + ], + "propertyNames": ["brandName","speed"], + "relationshipNames": ["isParked"] + }, + { + "entities": [ + { + "idPattern": ".*downtown$", + "type": "OffStreetParking" + }, + { + "idPattern": ".*47$", + "type": "OffStreetParking" + } + ], + "propertyNames": ["availableSpotNumber","totalSpotNumber"], + "relationshipNames": ["isNextToBuilding"] + } ], - "endpoint":"http://my.csource.org:1026" + "endpoint": "http://my.csource.org:1026", + "location": { + "type": "Polygon", + "coordinates": [ + [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], + [100.0, 1.0], [100.0, 0.0]] ] + } } \ No newline at end of file -- GitLab From d1ab6a71d3b2fa426b6eac3ce5e46b719059a421 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 09:28:25 +0100 Subject: [PATCH 06/14] fix(035_02): expected status code when no id in delete operation --- .../DeleteContextSourceRegistration/035_02.robot | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_02.robot b/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_02.robot index 074493f9..998ff34c 100644 --- a/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_02.robot +++ b/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_02.robot @@ -15,21 +15,21 @@ ${registration_id_prefix}= urn:ngsi-ld:Registration: ${filename}= context-source-registration-sample.jsonld -*** Test Cases *** INVALID_REGISTRATION_ID +*** Test Cases *** INVALID_REGISTRATION_ID EXPECTED_STATUS_CODE 035_02_01 Delete a Context Source Registration if the Id is not present [Tags] csr-delete 5_9_4 - ${EMPTY} + ${EMPTY} 405 035_02_02 Delete a Context Source Registration if the Id is not a valid URI [Tags] csr-delete 5_9_4 - invalidURI + invalidURI 400 *** Keywords *** Delete A Context Source [Documentation] Check that you cannot delete a context source registration under some conditions - [Arguments] ${invalid_registration_id} + [Arguments] ${invalid_registration_id} ${expected_status_code} ${response}= Delete Context Source Registration With Return ${invalid_registration_id} - Check Response Status Code 400 ${response.status_code} + Check Response Status Code ${expected_status_code} ${response.status_code} Check Response Body Containing ProblemDetails Element Containing Title Element ${response.json()} Delete Created Context Source Registrations -- GitLab From c00e9c262026c13cb85b4ccdc4ac6968e92df99a Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 09:32:39 +0100 Subject: [PATCH 07/14] fix(035_02): only check response body if 400 error --- .../DeleteContextSourceRegistration/035_02.robot | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_02.robot b/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_02.robot index 998ff34c..6ec5936d 100644 --- a/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_02.robot +++ b/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_02.robot @@ -15,22 +15,27 @@ ${registration_id_prefix}= urn:ngsi-ld:Registration: ${filename}= context-source-registration-sample.jsonld -*** Test Cases *** INVALID_REGISTRATION_ID EXPECTED_STATUS_CODE +*** Test Cases *** INVALID_REGISTRATION_ID EXPECTED_STATUS_CODE PROBLEM_TYPE 035_02_01 Delete a Context Source Registration if the Id is not present [Tags] csr-delete 5_9_4 - ${EMPTY} 405 + ${EMPTY} 405 ${EMPTY} 035_02_02 Delete a Context Source Registration if the Id is not a valid URI [Tags] csr-delete 5_9_4 - invalidURI 400 + invalidURI 400 ${ERROR_TYPE_BAD_REQUEST_DATA} *** Keywords *** Delete A Context Source [Documentation] Check that you cannot delete a context source registration under some conditions - [Arguments] ${invalid_registration_id} ${expected_status_code} + [Arguments] ${invalid_registration_id} ${expected_status_code} ${problem_type} ${response}= Delete Context Source Registration With Return ${invalid_registration_id} Check Response Status Code ${expected_status_code} ${response.status_code} - Check Response Body Containing ProblemDetails Element Containing Title Element ${response.json()} + IF "${problem_type}"!="${EMPTY}" + Check Response Body Containing ProblemDetails Element Containing Type Element set to + ... ${response.json()} + ... ${problem_type} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response.json()} + END Delete Created Context Source Registrations Delete Context Source Registration ${registration_id} -- GitLab From 73608bbb490b30263e4c36d64996a3b2703b45d8 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 09:58:43 +0100 Subject: [PATCH 08/14] fix(033_01_03): correctly inject retrieved id into CSR --- .../Registration/RegisterContextSource/033_01_03.robot | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_01_03.robot b/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_01_03.robot index 45c92422..bba76343 100644 --- a/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_01_03.robot +++ b/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_01_03.robot @@ -15,7 +15,7 @@ ${registration_payload_file_path}= csourceRegistrations/context-source-regi *** Test Cases *** -033_01_03 Create Context Source Registration Without A Sprecified ID +033_01_03 Create Context Source Registration Without Specifying an ID [Documentation] Check that you can create a context source registration without specifying an ID [Tags] csr-create 5_9_2 ${payload}= Load JSON From File ${EXECDIR}/data/${registration_payload_file_path} @@ -23,7 +23,8 @@ ${registration_payload_file_path}= csourceRegistrations/context-source-regi Check Response Status Code 201 ${response.status_code} ${registration_id}= Check Response Headers ID Not Empty ${response.headers} Set Suite Variable ${registration_id} - ${registration_payload}= Update Value To JSON ${payload} $..id ${registration_id} + ${id_dict}= Create Dictionary id=${registration_id} + ${registration_payload}= Add Object To Json ${payload} $ ${id_dict} ${response1}= Retrieve Context Source Registration ... context_source_registration_id=${registration_id} ... context=${ngsild_test_suite_context} -- GitLab From 7ef281e31f4720af4629f145bf116180f5a5dfaf Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 10:27:04 +0100 Subject: [PATCH 09/14] fix(033_07): correct expected type in entities map and registration id ingestion --- .../Registration/RegisterContextSource/033_07.robot | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_07.robot b/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_07.robot index b208fbb6..3010951f 100644 --- a/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_07.robot +++ b/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_07.robot @@ -21,7 +21,7 @@ ${registration_payload_file_path}= csourceRegistrations/context-source-regi ${registration_id}= Generate Random Entity Id ${registration_id_prefix} Set Suite Variable ${registration_id} ${payload}= Load JSON From File ${EXECDIR}/data/${registration_payload_file_path} - ${updated_payload}= Update Value To JSON ${payload} $..id ${registration_id} + ${updated_payload}= Update Value To JSON ${payload} $.id ${registration_id} ${response}= Create Context Source Registration With Return ... ${updated_payload} ... ${CONTENT_TYPE_LD_JSON} @@ -31,7 +31,7 @@ ${registration_payload_file_path}= csourceRegistrations/context-source-regi ... context=${ngsild_test_suite_context} Check JSON Value In Response Body ... ['information'][0]['entities'][0]['type'] - ... Building + ... Vehicle ... ${response1.json()} 033_07_02 Create one context source registration using a JSON-LD @context obtained from the request payload without Context @@ -40,7 +40,7 @@ ${registration_payload_file_path}= csourceRegistrations/context-source-regi ${registration_id}= Generate Random Entity Id ${registration_id_prefix} Set Suite Variable ${registration_id} ${payload}= Load JSON From File ${EXECDIR}/data/${registration_payload_file_path} - ${updated_payload}= Update Value To JSON ${payload} $..id ${registration_id} + ${updated_payload}= Update Value To JSON ${payload} $.id ${registration_id} ${response}= Create Context Source Registration With Return ... ${updated_payload} ... ${CONTENT_TYPE_LD_JSON} @@ -49,7 +49,7 @@ ${registration_payload_file_path}= csourceRegistrations/context-source-regi ... context_source_registration_id=${registration_id} Check JSON Value In Response Body ... ['information'][0]['entities'][0]['type'] - ... https://ngsi-ld-test-suite/context#Building + ... https://ngsi-ld-test-suite/context#Vehicle ... ${response1.json()} -- GitLab From 90a243b97156d0bedcaa8148e139bb24e65fb23c Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 10:36:17 +0100 Subject: [PATCH 10/14] fix(033_10): typo in TC documentation --- .../Registration/RegisterContextSource/033_10.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_10.robot b/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_10.robot index c154e6ad..80d52d13 100644 --- a/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_10.robot +++ b/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_10.robot @@ -13,7 +13,7 @@ ${registration_id_prefix}= urn:ngsi-ld:Registration: *** Test Cases *** -033_10_01 Create a context source registration with a different data structure than CsourRegistration data type +033_10_01 Create a context source registration with a different data structure than CSourceRegistration data type csourceRegistrations/context-source-registration-invalid-structure-sample.jsonld 033_10_02 Create a context source registration with a date in the past csourceRegistrations/context-source-registration-past-expiration-sample.jsonld -- GitLab From 469ad021067c6cdfe1797a39087e0d87b2fce266 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 11:06:47 +0100 Subject: [PATCH 11/14] fix(034_01/05): update endpoint info / set a CSR to never expire --- .../034_01.robot | 23 ++++---- .../034_05.robot | 53 +++++++++++++++++++ ...xt-source-registration-null-expiresAt.json | 3 ++ resources/AssertionUtils.resource | 4 ++ 4 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_05.robot create mode 100644 data/csourceRegistrations/fragments/context-source-registration-null-expiresAt.json diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_01.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_01.robot index ced78716..28d67a23 100644 --- a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_01.robot +++ b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_01.robot @@ -18,10 +18,7 @@ ${registration_id_prefix}= urn:ngsi-ld:Registration: *** Test Cases *** FILENAME UPDATE_FILENAME 034_01_01 Update a context source registration by id [Tags] csr-update 5_9_3 - context-source-registration-sample.jsonld context-source-registration-with-expiration-sample.jsonld -034_01_02 Update a context source registration to never expire - [Tags] csr-update 5_9_3 - context-source-registration-with-expiration-sample.jsonld context-source-registration-sample.jsonld + context-source-registration-sample.jsonld context-source-registration-update-sample.json *** Keywords *** @@ -29,18 +26,19 @@ Update A Context Source [Documentation] Check that you can update a context source registration by id [Arguments] ${filename} ${update_filename} Set Test Variable ${filename} - ${fragment}= Load JSON From File ${EXECDIR}/data/csourceRegistrations/${update_filename} - ${registration_update_fragment}= Update Value To JSON ${fragment} $..id ${registration_id} + ${fragment}= Load JSON From File ${EXECDIR}/data/csourceRegistrations/fragments/${update_filename} + ${registration_update_fragment}= Update Value To JSON ${fragment} $.id ${registration_id} ${response}= Update Context Source Registration With Return ... ${registration_id} ... ${registration_update_fragment} - ... ${CONTENT_TYPE_LD_JSON} + ... ${CONTENT_TYPE_JSON} Check Response Status Code 204 ${response.status_code} - Check Retrieving Context Source Registration - ... registration_id=${registration_id} - ... context=${ngsild_test_suite_context} - ... accept=${CONTENT_TYPE_LD_JSON} - ... registration_payload=${registration_payload} + ${response1}= Retrieve Context Source Registration + ... context_source_registration_id=${registration_id} + Check JSON Value In Response Body + ... ['endpoint'] + ... http://my.new.csource.org:1026 + ... ${response1.json()} Delete Updated Context Source Registration Delete Context Source Registration ${registration_id} @@ -48,7 +46,6 @@ Delete Updated Context Source Registration Initialize the Test Case ${registration_id}= Generate Random Entity Id ${registration_id_prefix} Set Test Variable ${registration_id} - # ${payload}= Load JSON From File ${EXECDIR}/data/csourceRegistrations/${filename} ${payload}= Load JSON From File ... ${EXECDIR}/data/csourceRegistrations/context-source-registration-sample.jsonld ${registration_payload}= Update Value To JSON ${payload} $..id ${registration_id} diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_05.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_05.robot new file mode 100644 index 00000000..4b04131f --- /dev/null +++ b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_05.robot @@ -0,0 +1,53 @@ +*** Settings *** +Documentation Check that you can update a context source registration by id + +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Setup Initialize the Test Case +Test Teardown Delete Updated Context Source Registration +Test Template Update A Context Source + + +*** Variables *** +${registration_id_prefix}= urn:ngsi-ld:Registration: + + +*** Test Cases *** FILENAME UPDATE_FILENAME +034_05_01 Update a context source registration to never expire + [Tags] csr-update 5_9_3 + context-source-registration-with-expiration-sample.jsonld context-source-registration-null-expiresAt.json + + +*** Keywords *** +Update A Context Source + [Documentation] Check that you can update a context source registration by id + [Arguments] ${filename} ${update_filename} + Set Test Variable ${filename} + ${fragment}= Load JSON From File ${EXECDIR}/data/csourceRegistrations/fragments/${update_filename} + ${registration_update_fragment}= Update Value To JSON ${fragment} $.id ${registration_id} + ${response}= Update Context Source Registration With Return + ... ${registration_id} + ... ${registration_update_fragment} + ... ${CONTENT_TYPE_JSON} + Check Response Status Code 204 ${response.status_code} + ${response1}= Retrieve Context Source Registration + ... context_source_registration_id=${registration_id} + Check JSON Value Not In Response Body + ... $.expiresAt + ... ${response1.json()} + +Delete Updated Context Source Registration + Delete Context Source Registration ${registration_id} + +Initialize the Test Case + ${registration_id}= Generate Random Entity Id ${registration_id_prefix} + Set Test Variable ${registration_id} + ${payload}= Load JSON From File + ... ${EXECDIR}/data/csourceRegistrations/context-source-registration-sample.jsonld + ${registration_payload}= Update Value To JSON ${payload} $..id ${registration_id} + Set Test Variable ${registration_payload} + ${response}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response.status_code} diff --git a/data/csourceRegistrations/fragments/context-source-registration-null-expiresAt.json b/data/csourceRegistrations/fragments/context-source-registration-null-expiresAt.json new file mode 100644 index 00000000..3d463007 --- /dev/null +++ b/data/csourceRegistrations/fragments/context-source-registration-null-expiresAt.json @@ -0,0 +1,3 @@ +{ + "expiresAt": null +} \ No newline at end of file diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 3b98a4d3..d8cca910 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -345,6 +345,10 @@ Check JSON Value In Response Body [Arguments] ${json_path_expr} ${value_to_check} ${response_body} Should Be Equal As Strings ${response_body${json_path_expr}} ${value_to_check} +Check JSON Value Not In Response Body + [Arguments] ${json_path_expr} ${response_body} + Should Not Have Value In Json ${response_body} ${json_path_expr} + Check NotificationParams [Arguments] ${filename} ${expected_additional_members} ${response_body} -- GitLab From 6340b1c068711e1daa27838349982fb3820d691f Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 11:15:02 +0100 Subject: [PATCH 12/14] fix(034_03): only set registration id at the root of the payload --- .../Registration/UpdateContextSourceRegistration/034_03.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot index 8b4f64c9..8ad986a3 100644 --- a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot +++ b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot @@ -18,7 +18,7 @@ ${filename}= context-source-registration-sample.jsonld ${registration_id}= Generate Random Entity Id ${registration_id_prefix} Set Suite Variable ${registration_id} ${fragment}= Load JSON From File ${EXECDIR}/data/csourceRegistrations/${filename} - ${fragment_with_id}= Update Value To JSON ${fragment} $..id ${registration_id} + ${fragment_with_id}= Update Value To JSON ${fragment} $.id ${registration_id} ${response}= Update Context Source Registration With Return ... ${registration_id} ... ${fragment_with_id} -- GitLab From 78bf442dd95846bfe65a0b766187f2ecb0715485 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 11:15:37 +0100 Subject: [PATCH 13/14] fix(034_04): use a clearer invalid JSON payload --- .../034_04.robot | 7 ++-- ...urce-registration-invalid-json-sample.json | 5 +++ ...xt-source-registration-invalid-sample.json | 5 +++ ...-source-registration-invalid-sample.jsonld | 36 ++----------------- .../ContextSourceRegistration.resource | 12 +++++++ 5 files changed, 27 insertions(+), 38 deletions(-) create mode 100644 data/csourceRegistrations/context-source-registration-invalid-json-sample.json create mode 100644 data/csourceRegistrations/context-source-registration-invalid-sample.json diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_04.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_04.robot index 6eb6eb67..faef017a 100644 --- a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_04.robot +++ b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_04.robot @@ -12,17 +12,16 @@ Test Teardown Delete Initial Context Source Registration *** Variables *** ${registration_id_prefix}= urn:ngsi-ld:Registration: ${filename}= context-source-registration-sample.jsonld -${registration_payload_file_path}= context-source-registration-invalid-sample.jsonld +${registration_payload_file_path}= context-source-registration-invalid-json-sample.json *** Test Cases *** 034_04_01 Update a context source registration if the request body is invalid [Documentation] Check that you cannot update a context source registration if the request body is invalid [Tags] csr-update 5_9_3 - ${response}= Update Context Source Registration + ${response}= Update Context Source Registration From File ... ${registration_id} ... ${registration_payload_file_path} - # Check Response Status Code ${response.json()} Check Response Status Code 400 ${response.status_code} Check Response Body Type When Using Session Request ${response.json()} ${ERROR_TYPE_BAD_REQUEST_DATA} Check Response Body Title When Using Session Request ${response.json()} @@ -35,7 +34,7 @@ Create Initial Context Source Registration ${registration_id}= Generate Random Entity Id ${registration_id_prefix} Set Test Variable ${registration_id} ${payload}= Load JSON From File ${EXECDIR}/data/csourceRegistrations/${filename} - ${updated_payload}= Update Value To JSON ${payload} $..id ${registration_id} + ${updated_payload}= Update Value To JSON ${payload} $.id ${registration_id} ${response}= Create Context Source Registration With Return ${updated_payload} Check Response Status Code 201 ${response.status_code} diff --git a/data/csourceRegistrations/context-source-registration-invalid-json-sample.json b/data/csourceRegistrations/context-source-registration-invalid-json-sample.json new file mode 100644 index 00000000..e72bb9a4 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-invalid-json-sample.json @@ -0,0 +1,5 @@ +{ + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration",, + "endpoint": "http://my.new.csource.org:1026" +} \ No newline at end of file diff --git a/data/csourceRegistrations/context-source-registration-invalid-sample.json b/data/csourceRegistrations/context-source-registration-invalid-sample.json new file mode 100644 index 00000000..b097e4f5 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-invalid-sample.json @@ -0,0 +1,5 @@ +{ + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": null +} \ No newline at end of file diff --git a/data/csourceRegistrations/context-source-registration-invalid-sample.jsonld b/data/csourceRegistrations/context-source-registration-invalid-sample.jsonld index 06fe7cc9..595a5d63 100644 --- a/data/csourceRegistrations/context-source-registration-invalid-sample.jsonld +++ b/data/csourceRegistrations/context-source-registration-invalid-sample.jsonld @@ -1,39 +1,7 @@ { - "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID",, + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", "type": "ContextSourceRegistration", - "information": [ - { - "entities": [ - { - "id": "urn:ngsi-ld:Vehicle:A456", - "type": "Vehicle" - } - ], - "propertyNames": ["brandName","speed"], - "relationshipNames": ["isParked"] - }, - { - "entities": [ - { - "idPattern": ".*downtown$", - "type": "OffStreetParking" - }, - { - "idPattern": ".*47$", - "type": "OffStreetParking" - } - ], - "propertyNames": ["availableSpotNumber","totalSpotNumber"], - "relationshipNames": ["isNextToBuilding"] - } - ], - "endpoint": "http://my.csource.org:1026", - "location": { - "type": "Polygon", - "coordinates": [ - [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], - [100.0, 1.0], [100.0, 0.0]] ] - }, + "information": null, "@context": [ "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" ] diff --git a/resources/ApiUtils/ContextSourceRegistration.resource b/resources/ApiUtils/ContextSourceRegistration.resource index c1aca20b..8b567dcd 100755 --- a/resources/ApiUtils/ContextSourceRegistration.resource +++ b/resources/ApiUtils/ContextSourceRegistration.resource @@ -2,6 +2,7 @@ Variables ${EXECDIR}/resources/variables.py Library ${EXECDIR}/libraries/logUtils.py Library Collections +Library OperatingSystem Library RequestsLibrary @@ -73,6 +74,17 @@ Update Context Source Registration Output ${response} Update Context Source Registration RETURN ${response} +Update Context Source Registration From File + [Arguments] ${context_source_registration_id} ${filename} + + ${file_content}= Get File ${EXECDIR}/data/csourceRegistrations/${filename} + ${response}= PATCH + ... url=${url}/${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH}/${context_source_registration_id} + ... data=${file_content} + ... expected_status=any + Output ${response} Update Context Source Registration From File + RETURN ${response} + Update Context Source Registration With Return [Arguments] ${registration_id} ${fragment} ${content_type} ${accept}=${EMPTY} &{headers}= Create Dictionary Content-Type=${content_type} -- GitLab From 1cc4b7d415b07be4bee6608e650f7fb0d0910f3f Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 16 Dec 2023 12:11:42 +0100 Subject: [PATCH 14/14] fix(034_02): update expected status codes and invalid update fragment --- .../034_02.robot | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_02.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_02.robot index a879a3c6..a0d7de60 100644 --- a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_02.robot +++ b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_02.robot @@ -18,34 +18,36 @@ ${registration_payload_file_path}= context-source-registration-invalid-samp *** Test Cases *** 034_02_01 Update a context source registration by id if the Id is not present - ${EMPTY} fragments/context-source-registration-different-type-sample.jsonld + ${EMPTY} fragments/context-source-registration-different-type-sample.jsonld 405 ${EMPTY} 034_02_02 Update a context source registration by id if the Id is not a valid URI - invalidURI fragments/context-source-registration-different-type-sample.jsonld + invalidURI fragments/context-source-registration-different-type-sample.jsonld 400 ${ERROR_TYPE_BAD_REQUEST_DATA} 034_02_03 Update a context source registration if the request body is not of the same data type - ${valid_registration_id} fragments/context-source-registration-different-type-sample.jsonld + ${valid_registration_id} fragments/context-source-registration-different-type-sample.jsonld 400 ${ERROR_TYPE_BAD_REQUEST_DATA} 034_02_04 Update a context source registration if you attempt to remove a mandatory property - ${valid_registration_id} context-source-registration-invalid-structure-sample.jsonld + ${valid_registration_id} context-source-registration-invalid-sample.jsonld 400 ${ERROR_TYPE_BAD_REQUEST_DATA} *** Keywords *** Update A Context Source [Documentation] Check that you cannot update a context source registration under some conditions [Tags] csr-update 5_9_3 - [Arguments] ${registration_id} ${fragment_filename} + [Arguments] ${registration_id} ${fragment_filename} ${expected_status_code} ${problem_type} ${fragment}= Load JSON From File ${EXECDIR}/data/csourceRegistrations/${fragment_filename} - ${fragment_with_id}= Update Value To JSON ${fragment} $..id ${registration_id} + ${fragment_with_id}= Update Value To JSON ${fragment} $.id ${registration_id} ${response}= Update Context Source Registration With Return ... ${registration_id} ... ${fragment_with_id} ... ${CONTENT_TYPE_LD_JSON} - Check Response Status Code 400 ${response.status_code} - Check Response Body Containing ProblemDetails Element Containing Title Element ${response.json()} + Check Response Status Code ${expected_status_code} ${response.status_code} + IF "${problem_type}"!="${EMPTY}" + Check Response Body Containing ProblemDetails Element Containing Title Element ${response.json()} + END Create Initial Context Source Registration ${valid_registration_id}= Generate Random Entity Id ${registration_id_prefix} Set Suite Variable ${valid_registration_id} ${payload}= Load JSON From File ${EXECDIR}/data/csourceRegistrations/${filename} - ${updated_payload}= Update Value To JSON ${payload} $..id ${valid_registration_id} + ${updated_payload}= Update Value To JSON ${payload} $.id ${valid_registration_id} ${response}= Create Context Source Registration With Return ${updated_payload} Check Response Status Code 201 ${response.status_code} -- GitLab