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 0000000000000000000000000000000000000000..8b5a464ca5faf6b34e6ac3d4859cec9779f59b0f --- /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] 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} + + ${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 0000000000000000000000000000000000000000..120b7fd2e96b1b685d83c14d2afc17ce04be4368 --- /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] sub-create 5_8_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 0000000000000000000000000000000000000000..661afb526a9cea781442c822bbc7097380c9a5f5 --- /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] sub-create 5_8_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 0000000000000000000000000000000000000000..76d279d79572de0aa3feae4173e10947eb8e3762 --- /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] 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} + + ${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/data/subscriptions/subscription-empty-sample.jsonld b/data/subscriptions/subscription-empty-sample.jsonld new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /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 0000000000000000000000000000000000000000..bf9772f9ed7e452da2d97b75109baa73dab0a2ba --- /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 36efc472587d0db513cd9061cf3356f66b854047..78163f0bbcfd6e9311a623fa7e598c2eda1e30e8 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -691,6 +691,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}