From 30a9599b13df31d7ad39229eb2b87539039245e3 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Mon, 22 Mar 2021 11:18:23 +0100 Subject: [PATCH 1/4] fix: fix unknown subscription id --- .../Subscription/DeleteSubscription/032_02.robot | 2 +- .../Subscription/RetrieveSubscription/030_02.robot | 2 +- .../Subscription/UpdateSubscription/029_02.robot | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TP/NGSI-LD/ContextInformation/Subscription/DeleteSubscription/032_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/DeleteSubscription/032_02.robot index 5600e7a6..c83fdc6a 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/DeleteSubscription/032_02.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/DeleteSubscription/032_02.robot @@ -8,7 +8,7 @@ Delete Unknown Subscription [Documentation] Check that you cannot delete a subscription: If the subscription id provided does not correspond to any existing subscription in the system then an error of type ResourceNotFound shall be raised [Tags] mandatory - Delete Subscription unknownSubscription + Delete Subscription urn:ngsi-ld:Subscription:unknowSubscription Check Response Status Code Set To 404 Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_RESOURCE_NOT_FOUND} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_02.robot index bca57022..7c77ef6b 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_02.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_02.robot @@ -8,7 +8,7 @@ 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 + Retrieve Subscription urn:ngsi-ld:Subscription:unknowSubscription Check Response Status Code Set To 404 Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_RESOURCE_NOT_FOUND} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/029_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/029_02.robot index 3c64d310..2ad714bc 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/029_02.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/029_02.robot @@ -12,7 +12,7 @@ Update Unknown Subscription [Documentation] Check that you cannot update a subscription: If the NGSI-LD System does not know about the target Subscription, because there is no existing Subscription whose id (URI) is equivalent, an error of type ResourceNotFound shall be raised [Tags] mandatory - Update Subscription unknownSubscription ${subscription_update_fragment_file_path} ${CONTENT_TYPE_JSON} + Update Subscription urn:ngsi-ld:Subscription:unknowSubscription ${subscription_update_fragment_file_path} ${CONTENT_TYPE_JSON} Check Response Status Code Set To 404 Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_RESOURCE_NOT_FOUND} -- GitLab From ef5c215ba236cafd6cf2f589ddda498db68bb965 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Mon, 22 Mar 2021 12:06:49 +0100 Subject: [PATCH 2/4] fix: add ignored keys for subscription comparison --- resources/AssertionUtils.resource | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 4573716b..92388f3c 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -8,6 +8,7 @@ ${notification_timestamps_regex_expr}= root\\['last.*'\\] ${notification_endpoint_uri_regex_expr}= root\\['endpoint'\\]\\['uri'\\] ${context_regex_expr}= root\\['@context'\\] ${status_regex_expr}= root\\['status'\\] +${isActive_regex_expr}= root\\['isActive'\\] *** Keywords *** Check Response Status Code @@ -135,7 +136,7 @@ Check Response Body Containing Subscription element [Arguments] ${expectation_filename} ${subscription_id} ${subscription_payload}= Load Json From File ${EXECDIR}/data/${expectation_filename} ${subscription}= Update Value To Json ${subscription_payload} $..id ${subscription_id} - ${ignored_keys}= Create List ${status_regex_expr} ${context_regex_expr} + ${ignored_keys}= Create List ${status_regex_expr} ${isActive_regex_expr} ${context_regex_expr} ${comparison_result}= Compare Dictionaries Ignoring Keys ${response['body']} ${subscription} ${ignored_keys} Should Be True ${comparison_result} msg=Subscription Comparison Failed @@ -147,7 +148,8 @@ Check Response Body Containing List Containing Subscription elements ${subscription_payload}= Update Value To Json ${subscription_payload} $.[${index}]..id ${subscription_id} ${index}= Evaluate ${index} + 1 END - ${comparison_result}= Compare Dictionaries Ignoring Keys ${response['body']} ${subscription_payload} ${EMPTY} + ${ignored_keys}= Create List ${isActive_regex_expr} ${context_regex_expr} + ${comparison_result}= Compare Dictionaries Ignoring Keys ${response['body']} ${subscription_payload} ${ignored_keys} Should Be True ${comparison_result} msg=Subscription Comparison Failed # Since response body can be a json object if it contains one element -- GitLab From 14a01698e0406deb50f06e6fe56f5f56c09983cd Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Mon, 22 Mar 2021 14:32:57 +0100 Subject: [PATCH 3/4] fix: fix subscription expectation --- .../RetrieveSubscription/030_03.robot | 3 ++- .../subscriptions-030-03-expectation.json | 18 ++++++++++++++++++ .../subscriptions-031-01-expectation.json | 3 +++ resources/AssertionUtils.resource | 6 ++---- 4 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 data/subscriptions/expectations/subscriptions-030-03-expectation.json diff --git a/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_03.robot index 1cfdfa2d..79aaaf51 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_03.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/RetrieveSubscription/030_03.robot @@ -10,6 +10,7 @@ Suite Teardown Delete Initial Subscriptions *** Variable *** ${subscription_id_prefix}= urn:ngsi-ld:Subscription: ${subscription_payload_file_path}= subscriptions/subscription-sample.jsonld +${expectation_file_path}= subscriptions/expectations/subscriptions-030-03-expectation.json *** Test Case *** Retrieve Subscription @@ -19,7 +20,7 @@ Retrieve Subscription 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} + Check Response Body Containing Subscription element ${expectation_file_path} ${subscription_id} *** Keywords *** Setup Initial Subscriptions diff --git a/data/subscriptions/expectations/subscriptions-030-03-expectation.json b/data/subscriptions/expectations/subscriptions-030-03-expectation.json new file mode 100644 index 00000000..6ebc6092 --- /dev/null +++ b/data/subscriptions/expectations/subscriptions-030-03-expectation.json @@ -0,0 +1,18 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "isActive": true, + "status": "active" +} \ No newline at end of file diff --git a/data/subscriptions/expectations/subscriptions-031-01-expectation.json b/data/subscriptions/expectations/subscriptions-031-01-expectation.json index cd952e1f..a4ee40eb 100644 --- a/data/subscriptions/expectations/subscriptions-031-01-expectation.json +++ b/data/subscriptions/expectations/subscriptions-031-01-expectation.json @@ -14,6 +14,7 @@ "accept":"application/json" } }, + "isActive": true, "status": "active" }, { @@ -35,6 +36,7 @@ "accept":"application/json" } }, + "isActive": true, "status": "active" }, { @@ -52,6 +54,7 @@ "accept":"application/json" } }, + "isActive": false, "status": "paused" } ] \ No newline at end of file diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 92388f3c..a3384939 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -7,8 +7,6 @@ ${instance_id_regex_expr}= root\\[.*\\]\\['instanceId'\\] ${notification_timestamps_regex_expr}= root\\['last.*'\\] ${notification_endpoint_uri_regex_expr}= root\\['endpoint'\\]\\['uri'\\] ${context_regex_expr}= root\\['@context'\\] -${status_regex_expr}= root\\['status'\\] -${isActive_regex_expr}= root\\['isActive'\\] *** Keywords *** Check Response Status Code @@ -136,7 +134,7 @@ Check Response Body Containing Subscription element [Arguments] ${expectation_filename} ${subscription_id} ${subscription_payload}= Load Json From File ${EXECDIR}/data/${expectation_filename} ${subscription}= Update Value To Json ${subscription_payload} $..id ${subscription_id} - ${ignored_keys}= Create List ${status_regex_expr} ${isActive_regex_expr} ${context_regex_expr} + ${ignored_keys}= Create List ${context_regex_expr} ${comparison_result}= Compare Dictionaries Ignoring Keys ${response['body']} ${subscription} ${ignored_keys} Should Be True ${comparison_result} msg=Subscription Comparison Failed @@ -148,7 +146,7 @@ Check Response Body Containing List Containing Subscription elements ${subscription_payload}= Update Value To Json ${subscription_payload} $.[${index}]..id ${subscription_id} ${index}= Evaluate ${index} + 1 END - ${ignored_keys}= Create List ${isActive_regex_expr} ${context_regex_expr} + ${ignored_keys}= Create List ${context_regex_expr} ${comparison_result}= Compare Dictionaries Ignoring Keys ${response['body']} ${subscription_payload} ${ignored_keys} Should Be True ${comparison_result} msg=Subscription Comparison Failed -- GitLab From 56130b4eff1e6cb20b9e99789b5ba6c17ffd6f62 Mon Sep 17 00:00:00 2001 From: Houcem Kacem Date: Mon, 22 Mar 2021 14:42:09 +0100 Subject: [PATCH 4/4] feat: rename expectations files --- .../UpdateSubscription/029_05.robot | 4 ++-- .../040_01.robot | 3 ++- .../subscriptions-040-01-expectation.json | 18 ++++++++++++++++++ ...iption-vehicle-expanded-types-sample.jsonld | 0 .../subscription-vehicle-sample.jsonld | 0 5 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 data/csourceSubscriptions/expectations/subscriptions-040-01-expectation.json rename data/subscriptions/{expected => expectations}/subscription-vehicle-expanded-types-sample.jsonld (100%) rename data/subscriptions/{expected => expectations}/subscription-vehicle-sample.jsonld (100%) diff --git a/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/029_05.robot b/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/029_05.robot index 60aca577..08d3fc89 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/029_05.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/029_05.robot @@ -11,8 +11,8 @@ Suite Teardown Delete Initial Subscriptions ${subscription_id_prefix}= urn:ngsi-ld:Subscription: ${subscription_payload_file_path}= subscriptions/subscription-sample.jsonld ${subscription_update_fragment_file_path}= subscriptions/fragments/subscription-vehicle-entities-sample.json -${expected_subscription_payload_file_path}= subscriptions/expected/subscription-vehicle-sample.jsonld -${expected_expanded_subscription_payload_file_path}= subscriptions/expected/subscription-vehicle-expanded-types-sample.jsonld +${expected_subscription_payload_file_path}= subscriptions/expectations/subscription-vehicle-sample.jsonld +${expected_expanded_subscription_payload_file_path}= subscriptions/expectations/subscription-vehicle-expanded-types-sample.jsonld *** Test Case *** Update Subscription With Term to Uri Expansion diff --git a/TP/NGSI-LD/ContextSource/RegistrationSubscription/RetrieveContextSourceRegistrationSubscription/040_01.robot b/TP/NGSI-LD/ContextSource/RegistrationSubscription/RetrieveContextSourceRegistrationSubscription/040_01.robot index 065e4771..0da3e65b 100644 --- a/TP/NGSI-LD/ContextSource/RegistrationSubscription/RetrieveContextSourceRegistrationSubscription/040_01.robot +++ b/TP/NGSI-LD/ContextSource/RegistrationSubscription/RetrieveContextSourceRegistrationSubscription/040_01.robot @@ -10,6 +10,7 @@ Suite Teardown Delete Created Context Source Registration Subscription *** Variable *** ${subscription_id_prefix}= urn:ngsi-ld:Subscription: ${subscription_payload_file_path}= csourceSubscriptions/subscription-sample.jsonld +${expectation_file_path}= csourceSubscriptions/expectations/subscriptions-040-01-expectation.json *** Test Case *** Retrieve Context Source Registration Subscription @@ -19,7 +20,7 @@ Retrieve Context Source Registration Subscription Retrieve Context Source Registration 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} + Check Response Body Containing Subscription element ${expectation_file_path} ${subscription_id} *** Keywords *** Setup Initial Context Source Registration Subscription diff --git a/data/csourceSubscriptions/expectations/subscriptions-040-01-expectation.json b/data/csourceSubscriptions/expectations/subscriptions-040-01-expectation.json new file mode 100644 index 00000000..6ebc6092 --- /dev/null +++ b/data/csourceSubscriptions/expectations/subscriptions-040-01-expectation.json @@ -0,0 +1,18 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "isActive": true, + "status": "active" +} \ No newline at end of file diff --git a/data/subscriptions/expected/subscription-vehicle-expanded-types-sample.jsonld b/data/subscriptions/expectations/subscription-vehicle-expanded-types-sample.jsonld similarity index 100% rename from data/subscriptions/expected/subscription-vehicle-expanded-types-sample.jsonld rename to data/subscriptions/expectations/subscription-vehicle-expanded-types-sample.jsonld diff --git a/data/subscriptions/expected/subscription-vehicle-sample.jsonld b/data/subscriptions/expectations/subscription-vehicle-sample.jsonld similarity index 100% rename from data/subscriptions/expected/subscription-vehicle-sample.jsonld rename to data/subscriptions/expectations/subscription-vehicle-sample.jsonld -- GitLab