Skip to content

Commit

Permalink
ADD test case for #3182 (already solved in a previous PR)
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalan committed Sep 21, 2018
1 parent a5dcf0f commit 32dadeb
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 32dadeb

Please sign in to comment.