Commit 00938d13 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat: check whether notification payload contains system attributes or not...

parent 899ed252
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       The system generated attributes are included in the response payload body of a notification if sysAttrs parameter is set to true.

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-with-true-sysAttrs-parameter.jsonld
${building_id_prefix}                   urn:ngsi-ld:Building:
${entity_building_filepath}             building-simple-attributes.jsonld
${fragment_filename}                    airQualityLevel-fragment.jsonld
${notification_server_send_url}         http://${notification_server_host}:${notification_server_port}/notify


*** Test Cases ***
046_17_01 Check that the response payload body contains the system generated attributes if sysAttrs parameter is set to true
    [Documentation]    The system generated attributes are included in the response payload body of a notification if sysAttrs parameter is set to true.
    [Tags]    sub-notification    5_8_6    since_v1.6.1

    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}

    ${notification}    ${headers}=    Wait for notification    timeout=${10}

    ${notification_payload}=    Get Request Body

    ${notification}=    Evaluate    json.loads('''${notification_payload}''')    json

    Dictionary Should Contain Key    ${notification}[data][0]    createdAt
    Dictionary Should Contain Key    ${notification}[data][0]    modifiedAt


*** Keywords ***
Before Test
    Start Local Server    ${notification_server_host}    ${notification_server_port}
    Setup Initial Subscriptions

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}
+70 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       The system generated attributes are not included in the response payload body of a notification if sysAttrs parameter is set to false.

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-with-false-sysAttrs-parameter.jsonld
${building_id_prefix}                   urn:ngsi-ld:Building:
${entity_building_filepath}             building-simple-attributes.jsonld
${fragment_filename}                    airQualityLevel-fragment.jsonld
${notification_server_send_url}         http://${notification_server_host}:${notification_server_port}/notify


*** Test Cases ***
046_18_01 Check that the response payload body does not contain the system generated attributes if sysAttrs parameter is set to false
    [Documentation]    The system generated attributes are not included in the response payload body of a notification if sysAttrs parameter is set to false.
    [Tags]    sub-notification    5_8_6    since_v1.6.1

    ${response}=    Update Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}

    ${notification}    ${headers}=    Wait for notification    timeout=${10}

    ${notification_payload}=    Get Request Body

    ${notification}=    Evaluate    json.loads('''${notification_payload}''')    json

    Dictionary Should Not Contain Key    ${notification}[data][0]    createdAt
    Dictionary Should Not Contain Key    ${notification}[data][0]    modifiedAt


*** Keywords ***
Before Test
    Start Local Server    ${notification_server_host}    ${notification_server_port}
    Setup Initial Subscriptions

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}
+20 −0
Original line number Diff line number Diff line
{
   "id":"urn:ngsi-ld:Subscription:randomUUID",
   "type":"Subscription",
   "entities":[
      {
         "type":"Building"
      }
   ],
   "notification":{
      "format":"keyValues",
      "endpoint":{
         "uri":"http://my.endpoint.org/notify",
         "accept":"application/json"
      },
      "sysAttrs" : false
   },
   "@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
+20 −0
Original line number Diff line number Diff line
{
   "id":"urn:ngsi-ld:Subscription:randomUUID",
   "type":"Subscription",
   "entities":[
      {
         "type":"Building"
      }
   ],
   "notification":{
      "format":"keyValues",
      "endpoint":{
         "uri":"http://my.endpoint.org/notify",
         "accept":"application/json"
      },
      "sysAttrs" : true
   },
   "@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
+42 −0
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/CI/SUB/046_17",
  "test_objective": "The system generated attributes are included in the response payload body of a notification if sysAttrs parameter is set to true.",
  "reference": "ETSI GS CIM 009 V1.6.1 [], clause 5.8.6",
  "config_id": "",
  "parent_release": "v1.6.1",
  "clauses": [
    "5.8.6"
  ],
  "pics_selection": "",
  "keywords": [
    "Before Test",
    "Setup Initial Subscriptions",
    "After Test",
    "Delete Initial Subscriptions",
    "Delete Initial Entity"
  ],
  "teardown": "After Test",
  "initial_condition": "with {\n   the SUT containing an initial state\n}",
  "test_cases": [
    {
      "name": "046_17_01 Check that the response payload body contains the system generated attributes if sysAttrs parameter is set to true",
      "permutation_tp_id": "TP/NGSI-LD/CI/SUB/046_17_01",
      "doc": "The system generated attributes are included in the response payload body of a notification if sysAttrs parameter is set to true.",
      "tags": [
        "5_8_6",
        "since_v1.6.1",
        "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 The dictionary `${notification}[data][0]' should contain the key 'createdAt'     and\n        Notification received The dictionary `${notification}[data][0]' should contain the key 'modifiedAt'\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 '${fragment_filename}' 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_17"
}
 No newline at end of file
Loading