diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 7c02e058e7..ed70f91e8b 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -11,3 +11,4 @@ - Fix: With NGSIv2 replace operations the geolocalization field is inconsistent in DB (#1142) (#3167) - Fix: duplicated attribute/metadata keys in JSON response in some cases for dateCreated/dateModified/actionType - Fix: proper management of user attributes/metadata which name matches the one of a builtin (the user defined shadows the builtin for rendering but not for filtering) +- Fix: dateCreated and dateModified included in initial notification (#3182) diff --git a/test/functionalTest/cases/3182_builtin_dates_in_initial_notif/builtin_dates_in_initial_notif.test b/test/functionalTest/cases/3182_builtin_dates_in_initial_notif/builtin_dates_in_initial_notif.test new file mode 100644 index 0000000000..0cb8edb5ac --- /dev/null +++ b/test/functionalTest/cases/3182_builtin_dates_in_initial_notif/builtin_dates_in_initial_notif.test @@ -0,0 +1,218 @@ +# Copyright 2018 Telefonica Investigacion y Desarrollo, S.A.U +# +# This file is part of Orion Context Broker. +# +# Orion Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# iot_support at tid dot es + +# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh + +--NAME-- +Check that dateModified and dateCreated are included in inital notification + +--SHELL-INIT-- +dbInit CB +brokerStart CB +accumulatorStart --pretty-print + +--SHELL-- + +echo "01.Create entity E1/T" +echo "=====================" +payload='{ + "id": "E1", + "type": "T", + "A": { + "value": "foo", + "type": "Text" + } +}' +orionCurl --url '/v2/entities' --payload "$payload" +echo +echo + + +echo "02. Create sub E.*/T with with dateModified and dateCreated in notification.attrs" +echo "=================================================================================" +payload='{ + "subject": { + "entities": [ + { + "idPattern": ".*", + "type": "T" + } + ] + }, + "notification": { + "http": {"url": "http://localhost:'$LISTENER_PORT'/notify"}, + "attrs": [ "dateModified", "dateCreated", "*" ] + } +}' +orionCurl --url /v2/subscriptions --payload "$payload" +echo +echo + +SUB_ID=$(echo "$_responseHeaders" | grep Location | awk -F/ '{ print $4 }' | tr -d "\r\n") + + +echo "03. Dump & reset accumulator and check dateModified and dateCreated are included" +echo "================================================================================" +accumulatorDump +accumulatorReset +echo +echo + + +echo "04. Update subscription" +echo "=======================" +payload='{ + "subject": { + "entities": [ + { + "id": "E1", + "type": "T" + } + ] + }, + "notification": { + "http": {"url": "http://localhost:'$LISTENER_PORT'/notify"}, + "attrs": [ "dateModified", "dateCreated", "*" ] + } +}' +orionCurl --url /v2/subscriptions/$SUB_ID -X PATCH --payload "$payload" +echo +echo + + +echo "03. Dump & reset accumulator and check dateModified and dateCreated are included" +echo "================================================================================" +accumulatorDump +accumulatorReset +echo +echo + + +--REGEXPECT-- +01.Create entity E1/T +===================== +HTTP/1.1 201 Created +Content-Length: 0 +Location: /v2/entities/E1?type=T +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Date: REGEX(.*) + + + +02. Create sub E.*/T with with dateModified and dateCreated in notification.attrs +================================================================================= +HTTP/1.1 201 Created +Content-Length: 0 +Location: /v2/subscriptions/REGEX([0-9a-f]{24}) +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Date: REGEX(.*) + + + +03. Dump & reset accumulator and check dateModified and dateCreated are included +================================================================================ +POST http://localhost:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 290 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: localhost:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Text", + "value": "foo" + }, + "dateCreated": { + "metadata": {}, + "type": "DateTime", + "value": "REGEX(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\dZ)" + }, + "dateModified": { + "metadata": {}, + "type": "DateTime", + "value": "REGEX(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\dZ)" + }, + "id": "E1", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= + + +04. Update subscription +======================= +HTTP/1.1 204 No Content +Content-Length: 0 +Fiware-Correlator: REGEX([0-9a-f\-]{36}) +Date: REGEX(.*) + + + +03. Dump & reset accumulator and check dateModified and dateCreated are included +================================================================================ +POST http://localhost:REGEX(\d+)/notify +Fiware-Servicepath: / +Content-Length: 290 +User-Agent: orion/REGEX(\d+\.\d+\.\d+.*) +Ngsiv2-Attrsformat: normalized +Host: localhost:REGEX(\d+) +Accept: application/json +Content-Type: application/json; charset=utf-8 +Fiware-Correlator: REGEX([0-9a-f\-]{36}) + +{ + "data": [ + { + "A": { + "metadata": {}, + "type": "Text", + "value": "foo" + }, + "dateCreated": { + "metadata": {}, + "type": "DateTime", + "value": "REGEX(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\dZ)" + }, + "dateModified": { + "metadata": {}, + "type": "DateTime", + "value": "REGEX(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\dZ)" + }, + "id": "E1", + "type": "T" + } + ], + "subscriptionId": "REGEX([0-9a-f]{24})" +} +======================================= + + +--TEARDOWN-- +brokerStop CB +dbDrop CB