From 919abcc8b07301b40572a2473d9d725a8f00b0f6 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Mon, 8 Feb 2021 18:00:12 +0100 Subject: [PATCH 1/3] feat: add tps for retrieve context source --- .../001_01.robot | 16 +++++++++ .../001_02.robot | 16 +++++++++ .../001_03.robot | 35 +++++++++++++++++++ .../001_04.robot | 35 +++++++++++++++++++ ...t-source-registration-expanded-format.json | 14 ++++++++ .../context-source-registration.json | 14 ++++++++ resources/ApiUtils.resource | 19 +++++++--- resources/AssertionUtils.resource | 8 +++++ 8 files changed, 153 insertions(+), 4 deletions(-) create mode 100644 TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_01.robot create mode 100644 TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_02.robot create mode 100644 TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_03.robot create mode 100644 TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_04.robot create mode 100644 data/csourceRegistrations/expectations/context-source-registration-expanded-format.json create mode 100644 data/csourceRegistrations/expectations/context-source-registration.json diff --git a/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_01.robot b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_01.robot new file mode 100644 index 00000000..45c790b4 --- /dev/null +++ b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_01.robot @@ -0,0 +1,16 @@ +*** Settings *** +Documentation Check that you cannot a retrieve Context Source Registration, if the context source registration id is not present or it is not a valid URI +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Test Case *** +Retrieve Context Source Registration With An Invalid Id + [Documentation] Check that you cannot a retrieve Context Source Registration, if the context source registration id is not present or it is not a valid URI + [Tags] mandatory + + Retrieve Context Source Registration invalidUri + + Check Response Status Code Set To 400 + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} diff --git a/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_02.robot b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_02.robot new file mode 100644 index 00000000..bdc90d76 --- /dev/null +++ b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_02.robot @@ -0,0 +1,16 @@ +*** Settings *** +Documentation Check that you cannot retrieve a Context Source Registration, if the NGSI-LD endpoint does not know about the target context source registration, because there is no existing context source registration whose id (URI) is equivalent +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Test Case *** +Retrieve Unknown Context Source Registration + [Documentation] Check that you cannot retrieve a Context Source Registration, if the NGSI-LD endpoint does not know about the target context source registration, because there is no existing context source registration whose id (URI) is equivalent + [Tags] mandatory + + Retrieve Context Source Registration urn:ngsi-ld:ContextSourceRegistration:unknowRegistration + + Check Response Status Code Set To 404 + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_RESOURCE_NOT_FOUND} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} diff --git a/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_03.robot b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_03.robot new file mode 100644 index 00000000..c1fc4b2e --- /dev/null +++ b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_03.robot @@ -0,0 +1,35 @@ +*** Settings *** +Documentation Check that you can retrieve a Context Source Registration. Term to URI expansion of Attribute names shall be observed. +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Context Source Registration +Suite Teardown Delete Created Context Source Registration + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${expectation_file_path}= csourceRegistrations/expectations/context-source-registration-expanded-format.json + +*** Test Case *** +Retrieve Context Source Registration With Default Core Context + [Documentation] Check that you can retrieve a Context Source Registration. Term to URI expansion of Attribute names shall be observed. + [Tags] mandatory + + Retrieve Context Source Registration ${context_source_registration_id} + + Check Response Status Code Set To 200 + Check Response Body Containing Context Source Registration element ${expectation_file_path} ${context_source_registration_id} + +*** Keywords *** +Setup Initial Context Source Registration + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + Set Suite Variable ${context_source_registration_id} + +Delete Created Context Source Registration + Delete Context Source Registration ${context_source_registration_id} diff --git a/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_04.robot b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_04.robot new file mode 100644 index 00000000..3577a1e7 --- /dev/null +++ b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_04.robot @@ -0,0 +1,35 @@ +*** Settings *** +Documentation Check that you can retrieve a Context Source Registration +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Context Source Registration +Suite Teardown Delete Created Context Source Registration + +*** Variable *** +${context_source_registration_id_prefix}= urn:ngsi-ld:ContextSourceRegistration: +${context_source_registration_payload_file_path}= csourceRegistrations/context-source-registration-sample.jsonld +${expectation_file_path}= csourceRegistrations/expectations/context-source-registration.json + +*** Test Case *** +Retrieve Context Source Registration + [Documentation] Check that you can retrieve a Context Source Registration + [Tags] mandatory + + Retrieve Context Source Registration ${context_source_registration_id} context=${ngsild_test_suite_context} + + Check Response Status Code Set To 200 + Check Response Body Containing Context Source Registration element ${expectation_file_path} ${context_source_registration_id} + +*** Keywords *** +Setup Initial Context Source Registration + ${context_source_registration_id}= Generate Random Entity Id ${context_source_registration_id_prefix} + ${context_source_registration_payload}= Load Test Sample ${context_source_registration_payload_file_path} ${context_source_registration_id} + + Create Context Source Registration ${context_source_registration_payload} + + Set Suite Variable ${context_source_registration_id} + +Delete Created Context Source Registration + Delete Context Source Registration ${context_source_registration_id} diff --git a/data/csourceRegistrations/expectations/context-source-registration-expanded-format.json b/data/csourceRegistrations/expectations/context-source-registration-expanded-format.json new file mode 100644 index 00000000..f96e148a --- /dev/null +++ b/data/csourceRegistrations/expectations/context-source-registration-expanded-format.json @@ -0,0 +1,14 @@ +{ + "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 diff --git a/data/csourceRegistrations/expectations/context-source-registration.json b/data/csourceRegistrations/expectations/context-source-registration.json new file mode 100644 index 00000000..b4a6b06e --- /dev/null +++ b/data/csourceRegistrations/expectations/context-source-registration.json @@ -0,0 +1,14 @@ +{ + "id":"urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type":"ContextSourceRegistration", + "information":[ + { + "entities":[ + { + "type":"Building" + } + ] + } + ], + "endpoint":"http://my.csource.org:1026" +} \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 5a5c0ad7..bb305360 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -22,10 +22,10 @@ ${CONTEXT_SOURCE_REGISTRATION_SUBSCRIPTION_ENDPOINT_PATH} csourceSubscript ${CONTENT_TYPE_JSON} application/json ${CONTENT_TYPE_LD_JSON} application/ld+json -${ERROR_TYPE_BAD_REQUEST_DATA} http://uri.etsi.org/ngsi-ld/errors/BadRequestData -${ERROR_TYPE_INVALID_REQUEST} http://uri.etsi.org/ngsi-ld/errors/InvalidRequest -${ERROR_TYPE_RESOURCE_NOT_FOUND} http://uri.etsi.org/ngsi-ld/errors/ResourceNotFound -${ERROR_TYPE_ALREADY_EXISTS} http://uri.etsi.org/ngsi-ld/errors/AlreadyExists +${ERROR_TYPE_BAD_REQUEST_DATA} https://uri.etsi.org/ngsi-ld/errors/BadRequestData +${ERROR_TYPE_INVALID_REQUEST} https://uri.etsi.org/ngsi-ld/errors/InvalidRequest +${ERROR_TYPE_RESOURCE_NOT_FOUND} https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound +${ERROR_TYPE_ALREADY_EXISTS} https://uri.etsi.org/ngsi-ld/errors/AlreadyExists ${response} @@ -389,6 +389,17 @@ Delete Context Source Registration Set Suite Variable ${response} +Retrieve Context Source Registration + [Arguments] ${context_source_registration_id} ${context}=${EMPTY} + + &{headers}= Create Dictionary + Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" + ${response}= GET ${CONTEXT_SOURCE_REGISTRATION_ENDPOINT_PATH}/${context_source_registration_id} headers=${headers} + Output request + Output response + + Set Test Variable ${response} + Create Context Source Registration Subscription [Arguments] ${subscription_payload} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index c4a8c7a9..4fa93bf4 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -149,6 +149,14 @@ Check Response Body Containing Number Of Entities END Run Keyword Unless ${is_list} Should Be Equal ${response['body']['type']} ${expected_entity_type} +Check Response Body Containing Context Source Registration element + [Arguments] ${expectation_filename} ${context_source_registration_id} + ${context_source_registration_payload}= Load Json From File ${EXECDIR}/data/${expectation_filename} + ${context_source_registration}= Update Value To Json ${context_source_registration_payload} $..id ${context_source_registration_id} + ${ignored_keys}= Create List ${context_regex_expr} + ${comparaison_result}= Compare Dictionaries Ignoring Keys ${response['body']} ${context_source_registration} ${ignored_keys} + Should Be True ${comparaison_result} msg=Context Source Registration Comparaison Failed + Check Response Body Type When Using Session Request [Arguments] ${response} ${type} Should Be Equal ${response['type']} ${type} -- GitLab From 416af16538feb0c8b8390dc7c7678840aeca17cd Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Mon, 8 Feb 2021 18:38:31 +0100 Subject: [PATCH 2/3] feat: add missing permutation for tp 001_01 --- .../001_01.robot | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_01.robot b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_01.robot index 45c790b4..41981066 100644 --- a/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_01.robot +++ b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_01.robot @@ -4,12 +4,21 @@ Resource ${EXECDIR}/resources/ApiUtils.resource Resource ${EXECDIR}/resources/AssertionUtils.resource Resource ${EXECDIR}/resources/JsonUtils.resource -*** Test Case *** -Retrieve Context Source Registration With An Invalid Id +Test Template Retrieve Context Source Registration With A Not Present Or Invalid Id + +*** Test Cases *** ID +Not Present Id ${EMPTY} +Invalid Id invalidUri + +*** Keywords *** + +Retrieve Context Source Registration With A Not Present Or Invalid Id + [Arguments] ${id} + [Documentation] Check that you cannot a retrieve Context Source Registration, if the context source registration id is not present or it is not a valid URI [Tags] mandatory - Retrieve Context Source Registration invalidUri + Retrieve Context Source Registration ${id} Check Response Status Code Set To 400 Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} -- GitLab From f5d2d49e4ec781532728bc07e01db0616079cb3c Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Tue, 9 Feb 2021 11:44:11 +0100 Subject: [PATCH 3/3] fix: rename tps --- .../{001_01.robot => 036_01.robot} | 0 .../{001_02.robot => 036_02.robot} | 0 .../{001_03.robot => 036_03.robot} | 0 .../{001_04.robot => 036_04.robot} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/{001_01.robot => 036_01.robot} (100%) rename TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/{001_02.robot => 036_02.robot} (100%) rename TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/{001_03.robot => 036_03.robot} (100%) rename TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/{001_04.robot => 036_04.robot} (100%) diff --git a/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_01.robot b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_01.robot similarity index 100% rename from TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_01.robot rename to TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_01.robot diff --git a/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_02.robot b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_02.robot similarity index 100% rename from TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_02.robot rename to TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_02.robot diff --git a/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_03.robot b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_03.robot similarity index 100% rename from TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_03.robot rename to TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_03.robot diff --git a/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_04.robot b/TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_04.robot similarity index 100% rename from TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/001_04.robot rename to TP/NGSI-LD/ContextSource/Registration/RetrieveContextSourceRegistration/036_04.robot -- GitLab