forked from telefonicaid/fiware-orion
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug/crash in patch entity attrs when relationship without object rele…
…ase branch (#314) * New version string for develop branch (#312) * bug/crash-in-patch-entity-attrs-when-relationship-without-object (#313) * Implemented attribute check in incoming payload data for PATCH /entities/*/attrs - avoided a crash * Fixed a stupid mistake * new alpha bugfix number: 0.1.1
- Loading branch information
Showing
3 changed files
with
202 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...ases/0000_ngsild/ngsild_crash-in-patch-entity-attrs-when-relationship-without-object.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Copyright 2019 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-- | ||
Crash in PATCH /entities/*/attrs when relationship without object | ||
|
||
--SHELL-INIT-- | ||
export BROKER=orionld | ||
dbInit CB | ||
brokerStart CB | ||
|
||
--SHELL-- | ||
|
||
# | ||
# 01. Create an entity urn:ngsi-ld:T:001, with a relationship R1 | ||
# 02. Update the attribute R1 using PATCH /ngsi-ld/v1/entities/urn:ngsi-ld:T:001/attrs, but without 'object' - see error and make sure no crash | ||
# | ||
|
||
echo "01. Create an entity urn:ngsi-ld:T:001, with a relationship R1" | ||
echo "==============================================================" | ||
payload='{ | ||
"id": "urn:ngsi-ld:T:001", | ||
"type": "T", | ||
"R1": { | ||
"type": "Relationship", | ||
"object": "http://a.b.c/hola" | ||
} | ||
}' | ||
orionCurl --url /ngsi-ld/v1/entities -X POST --payload "$payload" | ||
echo | ||
echo | ||
|
||
|
||
echo "02. Update the attribute R1 using PATCH /ngsi-ld/v1/entities/urn:ngsi-ld:T:001/attrs, but without 'object' - see error and make sure no crash" | ||
echo "=============================================================================================================================================" | ||
payload='{ | ||
"R1": { | ||
"type": "Relationship", | ||
"value": "http://a.b.c/hola2" | ||
} | ||
}' | ||
orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:T:001/attrs -X PATCH --payload "$payload" | ||
echo | ||
echo | ||
|
||
|
||
--REGEXPECT-- | ||
01. Create an entity urn:ngsi-ld:T:001, with a relationship R1 | ||
============================================================== | ||
HTTP/1.1 201 Created | ||
Content-Length: 0 | ||
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" | ||
Location: /ngsi-ld/v1/entities/urn:ngsi-ld:T:001 | ||
Date: REGEX(.*) | ||
|
||
|
||
|
||
02. Update the attribute R1 using PATCH /ngsi-ld/v1/entities/urn:ngsi-ld:T:001/attrs, but without 'object' - see error and make sure no crash | ||
============================================================================================================================================= | ||
HTTP/1.1 400 Bad Request | ||
Content-Length: 126 | ||
Content-Type: application/json | ||
Date: REGEX(.*) | ||
|
||
{ | ||
"detail": "Relationship object", | ||
"title": "Mandatory field missing", | ||
"type": "https://uri.etsi.org/ngsi-ld/errors/BadRequestData" | ||
} | ||
|
||
|
||
--TEARDOWN-- | ||
brokerStop CB | ||
dbDrop CB |