From 18d958ed49d0961637267db9fcc051e6d8f660c2 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Tue, 16 Mar 2021 14:16:57 +0000 Subject: [PATCH 1/3] folders setup --- .../CreateSubscription/001_01.robot | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 TP/NGSI-LD/ContextInformation/Subscriptions/CreateSubscription/001_01.robot diff --git a/TP/NGSI-LD/ContextInformation/Subscriptions/CreateSubscription/001_01.robot b/TP/NGSI-LD/ContextInformation/Subscriptions/CreateSubscription/001_01.robot new file mode 100644 index 00000000..7f4ed1cc --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscriptions/CreateSubscription/001_01.robot @@ -0,0 +1,30 @@ +*** Settings *** +Documentation Check that you can create an entity +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Template Create Entity Scenarios + +*** Variable *** +${building_id_prefix}= urn:ngsi-ld:Building: + +*** Test Cases *** FILENAME CONTENT_TYPE +001_01_01_MinimalEntity building-minimal-without-context-sample.jsonld application/json +001_01_02_EntityWithSimpleProperties building-simple-attributes-sample.jsonld application/ld+json +001_01_03_EntityWithRelationshipsProperties building-relationship-of-property-sample.jsonld application/ld+json +001_01_04_EntityWithLocationAttribute building-location-attribute-sample.jsonld application/ld+json + +*** Keywords *** +Create Entity Scenarios + [Arguments] ${filename} ${content_type} + [Documentation] Check that you can create an entity + [Tags] /entities/ 5_6_1 + + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} + Check Response Status Code 201 ${response['status']} + Check Response Headers Containing URI set to ${request['path']} ${entity_id} ${response} + + [Teardown] Delete Entity by Id ${entity_id} \ No newline at end of file -- GitLab From 659daf1f44a45da80cca81689644b9e585301b12 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Mon, 22 Mar 2021 14:59:03 +0000 Subject: [PATCH 2/3] added create subscriptions suite --- .../PartialAttribute/012_02.robot | 10 +++---- .../CreateSubscription/031_01.robot | 24 +++++++++++++++ .../CreateSubscription/031_02.robot | 22 ++++++++++++++ .../CreateSubscription/031_03.robot | 28 +++++++++++++++++ .../CreateSubscription/031_04.robot | 26 ++++++++++++++++ .../CreateSubscription/001_01.robot | 30 ------------------- .../subscription-empty-sample.jsonld | 2 ++ .../subscription-invalid-json-sample.jsonld | 19 ++++++++++++ resources/ApiUtils.resource | 7 +++++ 9 files changed, 133 insertions(+), 35 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_01.robot create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_02.robot create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_03.robot create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_04.robot delete mode 100644 TP/NGSI-LD/ContextInformation/Subscriptions/CreateSubscription/001_01.robot create mode 100644 data/subscriptions/subscription-empty-sample.jsonld create mode 100644 data/subscriptions/subscription-invalid-json-sample.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/PartialAttribute/012_02.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/PartialAttribute/012_02.robot index c01c314b..9dd3a92c 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/PartialAttribute/012_02.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/PartialAttribute/012_02.robot @@ -13,12 +13,12 @@ ${filename}= vehicle-two-datasetid-attributes-sample.jsonld ${status_code}= 400 *** Test Cases *** ENTITY_ID ATTRIBUTE_ID FRAGMENT_FILENAME -#012_02_01_Make a partial attribute update if the Entity Id is not present ${EMPTY} speed vehicle-speed-equal-datasetid-fragment.jsonld -#012_02_02_Make a partial attribute update if the Entity Id is not a valid URI thisisaninvaliduri speed vehicle-speed-equal-datasetid-fragment.jsonld +012_02_01_Make a partial attribute update if the Entity Id is not present ${EMPTY} speed vehicle-speed-equal-datasetid-fragment.jsonld +012_02_02_Make a partial attribute update if the Entity Id is not a valid URI thisisaninvaliduri speed vehicle-speed-equal-datasetid-fragment.jsonld 012_02_03_Make a partial attribute update if the Attribute Name is not present ${valid_entity_id} speed vehicle-speed-wrong-name-fragment.jsonld -#012_02_04_Make a partial attribute update if the Attribute Id is invalid ${valid_entity_id} invalid vehicle-speed-equal-datasetid-fragment.jsonld -#012_02_05_Make a partial attribute update if the Attribute type does not match ${valid_entity_id} speed vehicle-speed-equal-datasetid-different-type-fragment.jsonld -#012_02_06_Make a partial attribute update if the entity fragment is empty ${valid_entity_id} speed empty-fragment.jsonld +012_02_04_Make a partial attribute update if the Attribute Id is invalid ${valid_entity_id} invalid vehicle-speed-equal-datasetid-fragment.jsonld +012_02_05_Make a partial attribute update if the Attribute type does not match ${valid_entity_id} speed vehicle-speed-equal-datasetid-different-type-fragment.jsonld +012_02_06_Make a partial attribute update if the entity fragment is empty ${valid_entity_id} speed empty-fragment.jsonld *** Keywords *** Update Attributes diff --git a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_01.robot new file mode 100644 index 00000000..948a9696 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_01.robot @@ -0,0 +1,24 @@ +*** Settings *** +Documentation Check that you can create a subscription +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_payload_file_path}= subscriptions/subscription-sample.jsonld + +*** Test Cases *** +Create Subscription + [Documentation] Check that you can create a subscription + [Tags] /entities/ 5_6_1 + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + + Create Subscription ${subscription_id} ${subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + + ${created_subscription}= Load Test Sample ${subscription_payload_file_path} ${subscription_id} + Retrieve Subscription ${subscription_id} context=${ngsild_test_suite_context} + Check Created Resource Set To ${created_subscription} + + [Teardown] Delete Subscription ${subscription_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_02.robot new file mode 100644 index 00000000..41c18c20 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_02.robot @@ -0,0 +1,22 @@ +*** Settings *** +Documentation Check that you cannot create a subscription with an invalid request +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource + +Test Template Create Subscription With Invalid Request + +*** Test Cases *** FILENAME +031_02_01_InvalidJson subscription-invalid-json-sample.jsonld +031_02_02_EmptyJson subscription-empty-sample.jsonld + +*** Keywords *** +Create Subscription With Invalid Request + [Arguments] ${filename} + [Documentation] Check that you cannot create a subscription with an invalid request + [Tags] /entities/ 5_6_1 + + Create Subscription From File ${filename} + + Check RL Response Status Code Set To Expected Code 400 + Check RL Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} + Check RL Response Body Containing ProblemDetails Element Containing Title Element ${response} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_03.robot new file mode 100644 index 00000000..6553c3a7 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_03.robot @@ -0,0 +1,28 @@ +*** Settings *** +Documentation Check that you cannot create a subscription with an invalid/empty id +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Template Create Subscription With Invalid/Empty Id + +*** Variables *** +${subscription_payload_file_path}= subscriptions/subscription-sample.jsonld + +*** Test Cases *** ID +031_03_01_InvalidId invalidId +031_03_02_EmptyId ${EMPTY} + +*** Keywords *** +Create Subscription With Invalid/Empty Id + [Arguments] ${subscription_id} + [Documentation] Check that you cannot create a subscription with an invalid/empty id + [Tags] /entities/ 5_6_1 + + ${response}= Create Subscription ${subscription_id} ${subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + + Check Response Status Code 400 ${response['status']} + 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} + + [Teardown] Delete Subscription ${subscription_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_04.robot b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_04.robot new file mode 100644 index 00000000..0590c7d7 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_04.robot @@ -0,0 +1,26 @@ +*** Settings *** +Documentation Check that you cannot create a subscription with an existing id +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${subscription_id_prefix}= urn:ngsi-ld:Subscription: +${subscription_payload_file_path}= subscriptions/subscription-sample.jsonld + +*** Test Case *** +Create a subscription with an id known to the system + [Documentation] Check that you cannot create a subscription with an existing id + [Tags] /entities/ 5_6_1 + + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + Create Subscription ${subscription_id} ${subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + + ${response}= Create Subscription ${subscription_id} ${subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} + + Check Response Status Code 409 ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_ALREADY_EXISTS} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + + [Teardown] Delete Subscription ${subscription_id} + diff --git a/TP/NGSI-LD/ContextInformation/Subscriptions/CreateSubscription/001_01.robot b/TP/NGSI-LD/ContextInformation/Subscriptions/CreateSubscription/001_01.robot deleted file mode 100644 index 7f4ed1cc..00000000 --- a/TP/NGSI-LD/ContextInformation/Subscriptions/CreateSubscription/001_01.robot +++ /dev/null @@ -1,30 +0,0 @@ -*** Settings *** -Documentation Check that you can create an entity -Resource ${EXECDIR}/resources/ApiUtils.resource -Resource ${EXECDIR}/resources/AssertionUtils.resource -Resource ${EXECDIR}/resources/JsonUtils.resource - -Test Template Create Entity Scenarios - -*** Variable *** -${building_id_prefix}= urn:ngsi-ld:Building: - -*** Test Cases *** FILENAME CONTENT_TYPE -001_01_01_MinimalEntity building-minimal-without-context-sample.jsonld application/json -001_01_02_EntityWithSimpleProperties building-simple-attributes-sample.jsonld application/ld+json -001_01_03_EntityWithRelationshipsProperties building-relationship-of-property-sample.jsonld application/ld+json -001_01_04_EntityWithLocationAttribute building-location-attribute-sample.jsonld application/ld+json - -*** Keywords *** -Create Entity Scenarios - [Arguments] ${filename} ${content_type} - [Documentation] Check that you can create an entity - [Tags] /entities/ 5_6_1 - - ${entity_id}= Generate Random Entity Id ${building_id_prefix} - - ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} - Check Response Status Code 201 ${response['status']} - Check Response Headers Containing URI set to ${request['path']} ${entity_id} ${response} - - [Teardown] Delete Entity by Id ${entity_id} \ No newline at end of file diff --git a/data/subscriptions/subscription-empty-sample.jsonld b/data/subscriptions/subscription-empty-sample.jsonld new file mode 100644 index 00000000..7a73a41b --- /dev/null +++ b/data/subscriptions/subscription-empty-sample.jsonld @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/data/subscriptions/subscription-invalid-json-sample.jsonld b/data/subscriptions/subscription-invalid-json-sample.jsonld new file mode 100644 index 00000000..bf9772f9 --- /dev/null +++ b/data/subscriptions/subscription-invalid-json-sample.jsonld @@ -0,0 +1,19 @@ +{ + "id":"urn:ngsi-ld:Subscription:randomUUID",, + "type":"Subscription", + "entities":[ + { + "type":"Building" + } + ], + "notification":{ + "format":"keyValues", + "endpoint":{ + "uri":"http://my.endpoint.org/notify", + "accept":"application/json" + } + }, + "@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" + ] +} \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 218eaf1e..3d29e442 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -672,6 +672,13 @@ Create Subscription Output response [return] ${response} +Create Subscription From File + [Arguments] ${filename} + ${file_content}= Get File ${EXECDIR}/data/subscriptions/${filename} + Create Session SubscriptionCreateRequest ${url} + ${response}= PATCH On Session SubscriptionCreateRequest ${SUBSCRIPTION_ENDPOINT_PATH} data=${file_content} expected_status=any + Set Test Variable ${response} + Update Subscription [Arguments] ${subscription_id} ${fragment_filename} ${content_type} ${accept}=${EMPTY} ${context}=${EMPTY} &{headers}= Create Dictionary Content-Type=${content_type} -- GitLab From c58f5c7baca3de19f704be481d569da82966ebba Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Thu, 1 Apr 2021 18:11:27 +0100 Subject: [PATCH 3/3] added tags --- .../Subscription/CreateSubscription/031_01.robot | 2 +- .../Subscription/CreateSubscription/031_02.robot | 2 +- .../Subscription/CreateSubscription/031_03.robot | 2 +- .../Subscription/CreateSubscription/031_04.robot | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_01.robot index 948a9696..8b5a464c 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_01.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_01.robot @@ -11,7 +11,7 @@ ${subscription_payload_file_path}= subscriptions/subscription-sample.jsonld *** Test Cases *** Create Subscription [Documentation] Check that you can create a subscription - [Tags] /entities/ 5_6_1 + [Tags] sub-create 5_8_1 ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_02.robot index 41c18c20..120b7fd2 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_02.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_02.robot @@ -13,7 +13,7 @@ Test Template Create Subscription With Invalid Request Create Subscription With Invalid Request [Arguments] ${filename} [Documentation] Check that you cannot create a subscription with an invalid request - [Tags] /entities/ 5_6_1 + [Tags] sub-create 5_8_1 Create Subscription From File ${filename} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_03.robot index 6553c3a7..661afb52 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_03.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_03.robot @@ -17,7 +17,7 @@ ${subscription_payload_file_path}= subscriptions/subscription-sample.jsonld Create Subscription With Invalid/Empty Id [Arguments] ${subscription_id} [Documentation] Check that you cannot create a subscription with an invalid/empty id - [Tags] /entities/ 5_6_1 + [Tags] sub-create 5_8_1 ${response}= Create Subscription ${subscription_id} ${subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_04.robot b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_04.robot index 0590c7d7..76d279d7 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_04.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/CreateSubscription/031_04.robot @@ -11,7 +11,7 @@ ${subscription_payload_file_path}= subscriptions/subscription-sample.jsonld *** Test Case *** Create a subscription with an id known to the system [Documentation] Check that you cannot create a subscription with an existing id - [Tags] /entities/ 5_6_1 + [Tags] sub-create 5_8_1 ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} Create Subscription ${subscription_id} ${subscription_payload_file_path} ${CONTENT_TYPE_LD_JSON} -- GitLab