diff --git a/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_10.robot b/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_10.robot index 22e2d1845d80ff04ad8a688e6c7438edc0d1140b..cf87f23264aa588aa99f7a7b4a60b3142f7e9e08 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/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_11.robot b/TP/NGSI-LD/ContextSource/Discovery/QueryContextSourceRegistrations/037_11.robot index 9fd5f98730ed263cc26094e95b5d840021bff558..42da3269d92a9b68fe320c640f66b2a9e5a3d843 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/TP/NGSI-LD/ContextSource/Discovery/RetrieveContextSourceRegistration/036_01.robot b/TP/NGSI-LD/ContextSource/Discovery/RetrieveContextSourceRegistration/036_01.robot index 54d702b45d05c815cd4f830940a44b98cff1c3c8..b0a321ae10e57ea9dcc3ce8fa36aad57947b6384 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} diff --git a/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_02.robot b/TP/NGSI-LD/ContextSource/Registration/DeleteContextSourceRegistration/035_02.robot index 074493f9fb193c467ea3acbd176740e6ee79638d..6ec5936d178d0b49e2a2742a0e1903bfda27de76 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 +*** 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} + ${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 + 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} + [Arguments] ${invalid_registration_id} ${expected_status_code} ${problem_type} ${response}= Delete Context Source Registration With Return ${invalid_registration_id} - 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 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} 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 45c92422ffd068073da3c0ab35c7bf01e5290ef9..bba76343bba3d32e8eb6876357be7cfb70bdefda 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} diff --git a/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_07.robot b/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_07.robot index b208fbb66fc5d780af419e6c1d6489bbabc508b8..3010951f0801a0b2c34a8d32c16a06fcfb702f52 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()} diff --git a/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_10.robot b/TP/NGSI-LD/ContextSource/Registration/RegisterContextSource/033_10.robot index c154e6adef5e8bf8b9cd76b3998b587ac63e0d07..80d52d135964076747a314a1fb2cc05745525195 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 diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_01.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_01.robot index ced78716a0f1a51f082fe1a2ec34f5bcaa3f01dd..28d67a239951076caf5b22edcda85c6b32be55f9 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_02.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_02.robot index a879a3c627c7ac2977e9252a2f5d393994cb365e..a0d7de604f2153f9006d2f85da1408cc483ac588 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} diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_03.robot index 8b4f64c9a4bb96c5daeebbb4e2566673042ed8e1..8ad986a3709d3e7ae466f13c210310a8564f1381 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} diff --git a/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_04.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_04.robot index 6eb6eb679252d48f2453d2b659131959bb159b65..faef017ac06b9a1f443d85b3e7ddf14af28e0d70 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/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_05.robot b/TP/NGSI-LD/ContextSource/Registration/UpdateContextSourceRegistration/034_05.robot new file mode 100644 index 0000000000000000000000000000000000000000..4b04131f0d8872a5545ddd70d0e21a90ece6837c --- /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/context-source-registration-csourceProperty-sample.jsonld b/data/csourceRegistrations/context-source-registration-csourceProperty-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..a76f1967cbf3761df68ad1fa0f1eeda5ed7663aa --- /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/context-source-registration-invalid-json-sample.json b/data/csourceRegistrations/context-source-registration-invalid-json-sample.json new file mode 100644 index 0000000000000000000000000000000000000000..e72bb9a4e4d86ccae072733c37f46f7e201062c6 --- /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 0000000000000000000000000000000000000000..b097e4f53a1dbe28e449f2f84065ee7436d2a22b --- /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 06fe7cc9e7e0c620250ac8ee94a5d343ae3329c0..595a5d63d58ee07981092230f9cb4e44cf5e37c0 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/data/csourceRegistrations/expectations/context-source-registration-expanded-format.json b/data/csourceRegistrations/expectations/context-source-registration-expanded-format.json index f96e148a8cfc62b0fa453f50bc9dc895d046dace..c557935b32c73e5c7250b206b7aed5056684cedd 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 + ] + ] + ] + } +} diff --git a/data/csourceRegistrations/expectations/context-source-registration.json b/data/csourceRegistrations/expectations/context-source-registration.json index b4a6b06efb3f5a7e307eb5f2467e5b92afb248ac..a534ebc79efd2b876087d1a57917b21c67e5078d 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 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 25b886f0bd2af3453720ca84284313b26077d47f..3240674ad45240d610e5eb312e4d681a7b2b9678 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 c462e3a6fc0150248ae10cc2b23efb34a879a6f3..28836a2ebbce818b83bf2d96a5ac02a4d4b69c77 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 0d7f5b3cc1d28e9b8238c2677090ff4e9c54d2e8..74af173bc058800d637e0c04322652de91d31a17 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/data/csourceRegistrations/fragments/context-source-registration-null-expiresAt.json b/data/csourceRegistrations/fragments/context-source-registration-null-expiresAt.json new file mode 100644 index 0000000000000000000000000000000000000000..3d463007a5c689c02dd66a3915bf38a53968b5cf --- /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/ApiUtils/ContextSourceDiscovery.resource b/resources/ApiUtils/ContextSourceDiscovery.resource index bd7ce2003b404bc5de0fbfa320e13299e42441da..160f66f9cd5a7ff9334fbc14c4717522c25199a9 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} diff --git a/resources/ApiUtils/ContextSourceRegistration.resource b/resources/ApiUtils/ContextSourceRegistration.resource index c1aca20b8617ecb33205b3d2dbaa69b15d26c70b..8b567dcddf21b7b253dcdc347f42745cb864d5bb 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} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 0f7c783f2328fe90ca0f7e5a947f29389cdac716..d8cca9104aa38dd36be33983e73d4affc2174681 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 @@ -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}