From efcb52a26e0d4721a36b0e85daefa1fe65610423 Mon Sep 17 00:00:00 2001 From: Ken Zangelin Date: Thu, 18 Jan 2024 15:22:48 +0100 Subject: [PATCH] Fixed issue #1535 --- .../notifications/subCacheAlterationMatch.cpp | 5 +- .../cases/0000_ngsild/ngsild_issue_1532.test | 165 ++++++++++++++++++ ...gsild_new_notifications_entity_delete.test | 1 + 3 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 test/functionalTest/cases/0000_ngsild/ngsild_issue_1532.test diff --git a/src/lib/orionld/notifications/subCacheAlterationMatch.cpp b/src/lib/orionld/notifications/subCacheAlterationMatch.cpp index c6383f5a9f..0eba4d8e80 100644 --- a/src/lib/orionld/notifications/subCacheAlterationMatch.cpp +++ b/src/lib/orionld/notifications/subCacheAlterationMatch.cpp @@ -1175,7 +1175,10 @@ OrionldAlterationMatch* subCacheAlterationMatch(OrionldAlteration* alterationLis if ((subP->qP == NULL) && (subP->ldContext != "") && (subP->qText != NULL)) subP->qP = qBuild(subP->qText, NULL, NULL, NULL, false, false); - if (subP->qP != NULL) + // + // Check the "q" filter, BUT not if the verb is DELETE + // + if ((subP->qP != NULL) && (orionldState.verb != HTTP_DELETE)) { if (qMatch(subP->qP, altP) == false) { diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_issue_1532.test b/test/functionalTest/cases/0000_ngsild/ngsild_issue_1532.test new file mode 100644 index 0000000000..39555a8615 --- /dev/null +++ b/test/functionalTest/cases/0000_ngsild/ngsild_issue_1532.test @@ -0,0 +1,165 @@ +# Copyright 2024 FIWARE Foundation e.V. +# +# This file is part of Orion-LD Context Broker. +# +# Orion-LD 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-LD 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-LD Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# orionld at fiware dot org + +# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh + +--NAME-- +No port in notification Host header + +--SHELL-INIT-- +dbInit CB +dbInit CB openiot +orionldStart CB -experimental -multiservice +accumulatorStart --pretty-print + +--SHELL-- + +# +# 01. Create a subscription, according to issue #1532 +# 02. Do an upsert/update creating an entity, provoking a notification +# 03. Dump/Reset the accumulator, see Host header and the port +# + +echo "01. Create a subscription, according to issue #1532" +echo "===================================================" +payload='{ + "id": "urn:S1", + "type": "Subscription", + "description": "Notify me of all feedstock changes", + "entities": [{"type": "FillingLevelSensor"}], + "watchedAttributes": ["filling"], + "notification": { + "attributes": ["filling", "location"], + "format": "normalized", + "endpoint": { + "uri": "http://127.0.0.1:9997/notify", + "accept": "application/json", + "receiverInfo": [ + { + "key": "fiware-service", + "value": "openiot" + } + ] + } + } +}' +orionCurl --url /ngsi-ld/v1/subscriptions --payload "$payload" --tenant openiot +echo +echo + + +echo "02. Do an upsert/update creating an entity, provoking a notification" +echo "====================================================================" +payload='[ + { + "id": "urn:ngsi-ld:Device:filling002", + "type": "FillingLevelSensor", + "filling": { + "type": "Property", + "value": 0.96, + "unitCode": "C62", + "accuracy": { + "type": "Property", + "value": 0.05 + }, + "observedAt": "2024-01-12T13:28:33.867Z" + } + } +]' +orionCurl --url /ngsi-ld/v1/entityOperations/upsert?options=update --payload "$payload" -H "Authorization: $Authorization" --tenant openiot +echo +echo + + +echo "03. Dump/Reset the accumulator, see Host header and the port" +echo "============================================================" +accumulatorDump +accumulatorReset +echo +echo + + +--REGEXPECT-- +01. Create a subscription, according to issue #1532 +=================================================== +HTTP/1.1 201 Created +Content-Length: 0 +Date: REGEX(.*) +Location: /ngsi-ld/v1/subscriptions/urn:S1 +NGSILD-Tenant: openiot + + + +02. Do an upsert/update creating an entity, provoking a notification +==================================================================== +HTTP/1.1 201 Created +Content-Length: 33 +Content-Type: application/json +Date: REGEX(.*) +NGSILD-Tenant: openiot + +[ + "urn:ngsi-ld:Device:filling002" +] + + +03. Dump/Reset the accumulator, see Host header and the port +============================================================ +POST http://127.0.0.1:9997/notify?subscriptionId=urn:S1 +Content-Length: 378 +User-Agent: orionld/REGEX(.*) +Host: 127.0.0.1:9997 +Accept: application/json +Fiware-Service: openiot +Ngsild-Tenant: openiot +Content-Type: application/json +Link: