diff --git a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/028_05.robot b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/028_05.robot new file mode 100644 index 0000000000000000000000000000000000000000..9602eff7d2a1364df2395fc7b11ef9995763a2ff --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/028_05.robot @@ -0,0 +1,27 @@ +*** Settings *** +Documentation Check that you cannot create a subscription with invalid throttling + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource + +Test Template Create Subscription With Invalid Throttling + + +*** Test Cases *** FILENAME EXPECTED_STATUS +028_05_01 ThrottlingAndTimeIntervalConjunction + subscription-invalid-throttling-timeInterval-sample.jsonld ${ERROR_TYPE_BAD_REQUEST_DATA} +028_05_02 NegativeThrottling + subscription-invalid-negative-throttling-sample.jsonld ${ERROR_TYPE_BAD_REQUEST_DATA} + + +*** Keywords *** +Create Subscription With Invalid Throttling + [Documentation] Check that you cannot create a subscription with invalid throttling + [Tags] sub-create 5_8_1 + [Arguments] ${filename} ${expected_status} + ${response}= Create Subscription From File ${filename} + Check Response Status Code 400 ${response.status_code} + Check Response Body Containing ProblemDetails Element Containing Type Element set to + ... ${response.json()} + ... ${expected_status} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response.json()} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_15.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_15.robot new file mode 100644 index 0000000000000000000000000000000000000000..c1661f987e76cf97b4fcfd281836db793e96faee --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_15.robot @@ -0,0 +1,67 @@ +*** Settings *** +Documentation If a Subscription defines a throttling member, a Notification shall not be sent if the throttling specified (in seconds) has not elapsed yet. + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource + +Suite Setup Before Test +Suite Teardown After Test + + +*** Variables *** +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_payload_file_path}= subscriptions/subscription-valid-throttling-sample.jsonld +${building_id_prefix}= urn:ngsi-ld:Building: +${notification_server_send_url}= http://${notification_server_host}:${notification_server_port}/notify +${entity_building_filepath}= building-simple-attributes-sample.jsonld +${fragment_filename}= airQualityLevel-fragment.jsonld + + +*** Test Cases *** +046_15_01 Check that a notification is not sent if the throttling has not elapsed yet + [Documentation] If a Subscription defines a throttling member, a Notification shall not be sent if the throttling specified (in seconds) has not elapsed yet. + [Tags] sub-notification 5_8_6 + Setup Initial Subscriptions + + ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + + ${notification} ${headers}= Wait for notification timeout=${10} + + ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + + Wait for no notification + + +*** Keywords *** +Before Test + Start Local Server ${notification_server_host} ${notification_server_port} + +Setup Initial Subscriptions + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + ${subscription_payload}= Load Subscription Sample With Reachable Endpoint + ... ${subscription_payload_file_path} + ... ${subscription_id} + ... ${notification_server_send_url} + ${subscription_payload}= Set Entity Id In Subscription ${subscription_payload} ${entity_id} + Set Suite Variable ${entity_id} + Set Suite Variable ${subscription_id} + + Create Entity ${entity_building_filepath} ${entity_id} + Sleep 1s + Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Sleep 1s + +After Test + Delete Initial Subscriptions + Delete Initial Entity + Stop Local Server + +Delete Initial Subscriptions + Delete Subscription ${subscription_id} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/data/subscriptions/subscription-invalid-negative-throttling-sample.jsonld b/data/subscriptions/subscription-invalid-negative-throttling-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..19201f3a967f6e3e970c0954ecd6a79e8f77079c --- /dev/null +++ b/data/subscriptions/subscription-invalid-negative-throttling-sample.jsonld @@ -0,0 +1,17 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "throttling" : -30 +} \ No newline at end of file diff --git a/data/subscriptions/subscription-invalid-throttling-timeInterval-sample.jsonld b/data/subscriptions/subscription-invalid-throttling-timeInterval-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..f3e348663f48a199947bc3c1075530300741d915 --- /dev/null +++ b/data/subscriptions/subscription-invalid-throttling-timeInterval-sample.jsonld @@ -0,0 +1,18 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "timeInterval": 10, + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "throttling" : 30 +} \ No newline at end of file diff --git a/data/subscriptions/subscription-valid-throttling-sample.jsonld b/data/subscriptions/subscription-valid-throttling-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..94b95eaee6344d22c810c6dcdfb0b1fe21845756 --- /dev/null +++ b/data/subscriptions/subscription-valid-throttling-sample.jsonld @@ -0,0 +1,20 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID", + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "throttling" : 15, + "@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/doc/files/ContextInformation/Subscription/028_05.json b/doc/files/ContextInformation/Subscription/028_05.json new file mode 100644 index 0000000000000000000000000000000000000000..0d044943cde35a871ee9b4fac7ca4ca4ac29f98b --- /dev/null +++ b/doc/files/ContextInformation/Subscription/028_05.json @@ -0,0 +1,50 @@ +{ + "tp_id": "TP/NGSI-LD/CI/SUB/028_05", + "test_objective": "Check that you cannot create a subscription with invalid throttling", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.8.1", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_8_1", + "keywords": [], + "teardown": "None", + "initial_condition": "with {\n the SUT containing an initial state\n}", + "test_cases": [ + { + "name": "028_05_01 ThrottlingAndTimeIntervalConjunction", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/028_05_01", + "doc": "Check that you cannot create a subscription with invalid throttling", + "tags": [ + "sub-create", + "5_8_1" + ], + "setup": null, + "teardown": null, + "template": "Create Subscription With Invalid Throttling", + "then": "then {\n the SUT sends a valid Response for the operations:\n Create Subscription From File with Response Status Code set to 400 and\n Create Subscription From File with Response Body containing the type 'https://uri.etsi.org/ngsi-ld/errors/BadRequestData' and\n Create Subscription From File with Response body containing 'title' element\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/'\n method set to 'POST'\n Create Subscription Request with Header['Content-Type'] set to 'application/ld+json' and\n payload defined in file: 'subscription-invalid-throttling-timeInterval-sample.jsonld'\n}", + "http_verb": "POST", + "endpoint": "subscriptions/" + }, + { + "name": "028_05_02 NegativeThrottling", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/028_05_02", + "doc": "Check that you cannot create a subscription with invalid throttling", + "tags": [ + "sub-create", + "5_8_1" + ], + "setup": null, + "teardown": null, + "template": "Create Subscription With Invalid Throttling", + "then": "then {\n the SUT sends a valid Response for the operations:\n Create Subscription From File with Response Status Code set to 400 and\n Create Subscription From File with Response Body containing the type 'https://uri.etsi.org/ngsi-ld/errors/BadRequestData' and\n Create Subscription From File with Response body containing 'title' element\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/subscriptions/'\n method set to 'POST'\n Create Subscription Request with Header['Content-Type'] set to 'application/ld+json' and\n payload defined in file: 'subscription-invalid-negative-throttling-sample.jsonld'\n}", + "http_verb": "POST", + "endpoint": "subscriptions/" + } + ], + "permutations": [ + "when" + ], + "robotpath": "ContextInformation/Subscription/CreateSubscription", + "robotfile": "028_05" +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Subscription/046_15.json b/doc/files/ContextInformation/Subscription/046_15.json new file mode 100644 index 0000000000000000000000000000000000000000..bd6277b8a6eae28d5b26d02857ce168f0cd28a56 --- /dev/null +++ b/doc/files/ContextInformation/Subscription/046_15.json @@ -0,0 +1,35 @@ +{ + "tp_id": "TP/NGSI-LD/CI/SUB/046_15", + "test_objective": "If a Subscription defines a throttling member, a Notification shall not be sent if the throttling specified (in seconds) has not elapsed yet.", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.8.6", + "config_id": "", + "parent_release": "v1.3.1", + "pics_selection": "PICS_5_8_6", + "keywords": [ + "Before Test", + "After Test" + ], + "teardown": "After Test", + "initial_condition": "with {\n the SUT containing an initial state\n}", + "test_cases": [ + { + "name": "046_15_01 Check that a notification is not sent if the throttling has not elapsed yet", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/046_15_01", + "doc": "If a Subscription defines a throttling member, a Notification shall not be sent if the throttling specified (in seconds) has not elapsed yet.", + "tags": [ + "5_8_6", + "sub-notification" + ], + "setup": null, + "teardown": null, + "template": null, + "then": "then {\n the client at '${endpoint}' receives a valid Notification containing:\n Notification received After waiting '10' seconds and\n Notification received Waiting for no Notification data and\n Query Parameter: timeout set to '5'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to 'airQualityLevel-fragment.jsonld' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Subscription/SubscriptionNotificationBehaviour", + "robotfile": "046_15" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Subscription.py b/doc/tests/test_ContextInformation_Subscription.py index 215414cad4237214446a3b1b3bc8491f664eac3f..097a4a0a71db20fe54b3f209d0f85c86a7a5fd33 100644 --- a/doc/tests/test_ContextInformation_Subscription.py +++ b/doc/tests/test_ContextInformation_Subscription.py @@ -70,6 +70,13 @@ class TestCISubscription(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_028_05(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/028_05.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/028_05.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_028_05.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_032_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/DeleteSubscription/032_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/032_01.json' @@ -189,6 +196,13 @@ class TestCISubscription(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_046_15(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/046_15.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/046_15.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_046_15.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_031_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/QuerySubscriptions/031_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/031_01.json'