From 0028ebcda458d786c859795f123f7863542c45e5 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Wed, 17 Mar 2021 11:47:27 +0100 Subject: [PATCH 1/3] feat: add tcs for retrieve subscription --- .../RetrieveSubscription/030_01.robot | 22 +++++++++++++ .../RetrieveSubscription/030_02.robot | 15 +++++++++ .../RetrieveSubscription/030_03.robot | 33 +++++++++++++++++++ resources/ApiUtils.resource | 2 +- resources/variables.py | 2 +- 5 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_01.robot create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_02.robot create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_03.robot diff --git a/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_01.robot new file mode 100644 index 00000000..d039eb9f --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_01.robot @@ -0,0 +1,22 @@ +*** Settings *** +Documentation Check that you cannot retrieve a subscription: If the subscription Id is not present or it is not a valid URI, then an error of type BadRequestData shall be raised +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource + +Test Template Retrieve Subscription With Non present Or Invalid Id + +*** Test Cases *** id +NotPresentId ${EMPTY} +InvalidId InvalidUri + +*** Keywords *** +Retrieve Subscription With Non present Or Invalid Id + [Arguments] ${id} + [Documentation] Check that you cannot retrieve a subscription: If the subscription Id is not present or it is not a valid URI, then an error of type BadRequestData shall be raised + [Tags] mandatory + + Retrieve Subscription ${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} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_02.robot new file mode 100644 index 00000000..bca57022 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_02.robot @@ -0,0 +1,15 @@ +*** Settings *** +Documentation Check that you cannot retrieve a subscription: If the identifier provided does not correspond to any existing subscription in the system then an error of type ResourceNotFound shall be raised +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource + +*** Test Case *** +Retrieve Unknown Subscription + [Documentation] Check that you cannot retrieve a subscription: If the identifier provided does not correspond to any existing subscription in the system then an error of type ResourceNotFound shall be raised + [Tags] mandatory + + Retrieve Subscription unknownSubscription + + 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/ContextInformation/Subscription/RetrieveSubscription/030_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_03.robot new file mode 100644 index 00000000..1cfdfa2d --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_03.robot @@ -0,0 +1,33 @@ +*** Settings *** +Documentation Check that you can retrieve a subscription +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Suite Setup Setup Initial Subscriptions +Suite Teardown Delete Initial Subscriptions + +*** Variable *** +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_payload_file_path}= subscriptions/subscription-sample.jsonld + +*** Test Case *** +Retrieve Subscription + [Documentation] Check that you can retrieve a subscription + [Tags] mandatory + + Retrieve Subscription ${subscription_id} context=${ngsild_test_suite_context} + + Check Response Status Code Set To 200 + Check Response Body Containing Subscription element ${subscription_payload_file_path} ${subscription_id} + +*** Keywords *** +Setup Initial Subscriptions + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + + Create Subscription ${subscription_id} ${subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + + Set Suite Variable ${subscription_id} + +Delete Initial Subscriptions + Delete Subscription ${subscription_id} diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index c7156c82..3a024e6e 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -693,7 +693,7 @@ Delete Subscription [return] ${response} Query Subscriptions - [Arguments] ${limit}=${EMPTY} ${accept}=${EMPTY} + [Arguments] ${limit}=${EMPTY} ${accept}=${EMPTY} &{headers}= Create Dictionary &{params}= Create Dictionary Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} diff --git a/resources/variables.py b/resources/variables.py index 4890d76b..c5cac8e3 100644 --- a/resources/variables.py +++ b/resources/variables.py @@ -1,6 +1,6 @@ def get_variables(arg=None): variables = { - 'url': 'https://broker-ngsi-ld.demeter.ubiwhere.com/ngsi-ld/v1', + 'url': 'http://10.5.1.214:9090/ngsi-ld/v1/', 'ngsild_test_suite_context': 'https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld', 'notification_server_host': '0.0.0.0', 'notification_server_port': 8085, -- GitLab From f7c17d6c900d9411132fc55fc0f2c1b8363d4b4f Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Wed, 17 Mar 2021 11:52:34 +0100 Subject: [PATCH 2/3] fix: fix rebase --- resources/ApiUtils.resource | 4 +--- resources/variables.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 3a024e6e..3913746d 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -673,15 +673,13 @@ Create Subscription [return] ${response} Update Subscription - [Arguments] ${subscription_id} ${fragment_filename} ${content_type} ${accept}=${EMPTY} ${context}=${EMPTY} + [Arguments] ${subscription_id} ${fragment_filename} ${content_type} ${accept}=${EMPTY} &{headers}= Create Dictionary Content-Type=${content_type} Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} - Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" ${subscription_update_fragment}= Load Json From File ${EXECDIR}/data/${fragment_filename} ${response}= PATCH ${SUBSCRIPTION_ENDPOINT_PATH}${subscription_id} body=${subscription_update_fragment} headers=${headers} Output request Output response - Set Test Variable ${response} [return] ${response} Delete Subscription diff --git a/resources/variables.py b/resources/variables.py index c5cac8e3..4890d76b 100644 --- a/resources/variables.py +++ b/resources/variables.py @@ -1,6 +1,6 @@ def get_variables(arg=None): variables = { - 'url': 'http://10.5.1.214:9090/ngsi-ld/v1/', + 'url': 'https://broker-ngsi-ld.demeter.ubiwhere.com/ngsi-ld/v1', 'ngsild_test_suite_context': 'https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld', 'notification_server_host': '0.0.0.0', 'notification_server_port': 8085, -- GitLab From 299ba199740b6b8b4f744d7b09b901ccb72ec2fe Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Wed, 17 Mar 2021 13:36:38 +0100 Subject: [PATCH 3/3] fix: fix rebase --- resources/ApiUtils.resource | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 3913746d..3a024e6e 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -673,13 +673,15 @@ Create Subscription [return] ${response} Update Subscription - [Arguments] ${subscription_id} ${fragment_filename} ${content_type} ${accept}=${EMPTY} + [Arguments] ${subscription_id} ${fragment_filename} ${content_type} ${accept}=${EMPTY} ${context}=${EMPTY} &{headers}= Create Dictionary Content-Type=${content_type} Run Keyword If '${accept}'!='' Set To Dictionary ${headers} Accept ${accept} + Run Keyword If '${context}'!='' Set To Dictionary ${headers} Link=<${context}>; rel="http://www.w3.org/ns/json-ld#context";type="application/ld+json" ${subscription_update_fragment}= Load Json From File ${EXECDIR}/data/${fragment_filename} ${response}= PATCH ${SUBSCRIPTION_ENDPOINT_PATH}${subscription_id} body=${subscription_update_fragment} headers=${headers} Output request Output response + Set Test Variable ${response} [return] ${response} Delete Subscription -- GitLab