Skip to content

Commit

Permalink
Merge branch 'develop' into issue/1478-bis
Browse files Browse the repository at this point in the history
  • Loading branch information
kzangeli authored Nov 27, 2023
2 parents 37771e0 + 234453f commit 3edecda
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Fixed issues:
* #1451 - Bug fix - removed a trailing ampersand from the URI for the connection to mongodb
* #1418 - Performance - Faster startup when there are GeoProperties in DB
* #1478 - Fixed issue
* #1479 - Fixed problem with "operations" in registrations
1 change: 1 addition & 0 deletions src/lib/orionld/forwarding/regMatchForEntityGet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ DistOp* regMatchForEntityGet // FIXME: +entity-type
doP->detail = (char*) "A matching exclusive registration forbids the Operation";
doP->httpResponseCode = 409;
}
continue;
}

// Add extra info in DistOp, needed by forwardRequestSend
Expand Down
127 changes: 127 additions & 0 deletions test/functionalTest/cases/0000_ngsild/ngsild_issue_1479.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Copyright 2023 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--
Test for issue 1479

--SHELL-INIT--
dbInit CB
dbInit CP1
orionldStart CB -experimental -forwarding
orionldStart CP1 -experimental

--SHELL--

#
# 01. Create an Exclusive registration R1 with operations 'updateOps' (no GETs) on CB for CP1
# 02. Create a matching entity E1 in CP1
# 03. Attempt to retrieve E1 from CP1 (R1 does not support GETs) - see 404
#

echo "01. Create an Exclusive registration R1 with operations 'updateOps' (no GETs) on CB for CP1"
echo "==========================================================================================="
payload='{
"id": "urn:R1",
"type": "ContextSourceRegistration",
"endpoint": "http://localhost:'$CP1_PORT'",
"information": [
{
"entities": [
{
"id": "urn:E1",
"type": "T"
}
],
"propertyNames": [
"add",
"remove",
"refill"
]
}
],
"mode": "exclusive",
"operations": [ "updateOps" ]
}'
orionCurl --url /ngsi-ld/v1/csourceRegistrations --payload "$payload"
echo
echo


echo "02. Create a matching entity E1 in CP1"
echo "======================================"
payload='{
"id": "urn:E1",
"type": "T",
"add": "ADD",
"remove": "REMOVE",
"refill": "REFILL"
}'
orionCurl --url /ngsi-ld/v1/entities --payload "$payload" --port $CP1_PORT
echo
echo


echo "03. Attempt to retrieve E1 from CP1 (R1 does not support GETs) - see 404"
echo "========================================================================"
orionCurl --url /ngsi-ld/v1/entities/urn:E1
echo
echo


--REGEXPECT--
01. Create an Exclusive registration R1 with operations 'updateOps' (no GETs) on CB for CP1
===========================================================================================
HTTP/1.1 201 Created
Content-Length: 0
Date: REGEX(.*)
Location: /ngsi-ld/v1/csourceRegistrations/urn:R1



02. Create a matching entity E1 in CP1
======================================
HTTP/1.1 201 Created
Content-Length: 0
Date: REGEX(.*)
Location: /ngsi-ld/v1/entities/urn:E1



03. Attempt to retrieve E1 from CP1 (R1 does not support GETs) - see 404
========================================================================
HTTP/1.1 404 Not Found
Content-Length: 108
Content-Type: application/json
Date: REGEX(.*)

{
"detail": "urn:E1",
"title": "Entity Not Found",
"type": "https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound"
}


--TEARDOWN--
brokerStop CB
brokerStop CP1
dbDrop CB
dbDrop CP1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ orionldStart CP1 -experimental
#
# 08. DELETE the registration R1, to not introduce noise for the next steps
# 09. Create an exclusive registration R2 for CP1, on entity type T, not supporting entity deletions
# 10. Attempt to DELETE urn:E1 in local broker - see the 409 from CP1
# 10. Attempt to DELETE urn:E1 in local broker - see the 404 from CP1
#

echo "01. Create Entity urn:E1 (type T) in local broker"
Expand Down Expand Up @@ -157,7 +157,7 @@ echo
echo


echo "10. Attempt to DELETE urn:E1 in local broker - see the 409 from CP1"
echo "10. Attempt to DELETE urn:E1 in local broker - see the 404 from CP1"
echo "==================================================================="
orionCurl --url /ngsi-ld/v1/entities/urn:E1 -X DELETE
echo
Expand Down Expand Up @@ -261,18 +261,17 @@ Location: /ngsi-ld/v1/csourceRegistrations/urn:R2



10. Attempt to DELETE urn:E1 in local broker - see the 409 from CP1
10. Attempt to DELETE urn:E1 in local broker - see the 404 from CP1
===================================================================
HTTP/1.1 404 Not Found
Content-Length: 72
Content-Length: 108
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)

{
"detail": "urn:E1",
"registrationId": "urn:R2",
"title": "Entity not found"
"title": "Entity not found",
"type": "https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound"
}


Expand Down

0 comments on commit 3edecda

Please sign in to comment.