Skip to content

Commit

Permalink
Merge pull request #1780 from telefonicaid/bug/1764_long_servicepath_…
Browse files Browse the repository at this point in the history
…component

Fix error with long servicepath component
  • Loading branch information
Ken Zangelin committed Feb 10, 2016
2 parents 2ae5f8a + 73fbb64 commit 20f0c02
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- Fix: '+' supported in entity ids and names in URLs (Issue #1675)
- Fix: libmicrohttpd 0.9.48 included in contextBroker as static lib (previous Orion versions used 0.9.22 as dynamic library) (Issue #1675)
- Fix: list of attribute names in URI param 'type' (Issue #1749)
- Fix: long servicepath when getting in NGSIv2 (#1423)
- Fix: long servicepath component in NGSIv2 (Issue #1423, #1764, #1774)
- Fix: syntax change in string query 'q' for exist and not-exist (Issue #1751)
- Fix: sanity check for string query 'q' - detect 'left-hand-side missing' (Issue #1754)
- Fix: more sanity checks for string query 'q' (q empty, parts of 'q' empty - parts of 'q' are separated by ';')
Expand Down
4 changes: 2 additions & 2 deletions src/lib/mongoBackend/MongoCommonUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2941,7 +2941,7 @@ static void updateEntity
}

// The servicePath of THIS object is entitySPath
char espath[SERVICE_NAME_MAX_LEN];
char espath[SERVICE_PATH_MAX_TOTAL];
slashEscape(entitySPath.c_str(), espath, sizeof(espath));

// servicePathString from earlier in this function
Expand Down Expand Up @@ -3126,7 +3126,7 @@ void processContextElement
servicePathV[0].c_str(),
action.c_str()));

char path[SERVICE_NAME_MAX_LEN];
char path[SERVICE_PATH_MAX_TOTAL];
slashEscape(servicePathV[0].c_str(), path, sizeof(path));

const std::string servicePathValue = std::string("^") + path + "$";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Copyright 2016 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--
Bug long servicepath component created, but not accesible

--SHELL-INIT--
dbInit CB
brokerStart CB

--SHELL--

#
# 01. POST /v2/entities to create entity
# 02. GET /v2/entities
# 03. PUT /v2/entities
# 04. DELETE /v2/entities
#

SP_LONG=/F_n_F4elhADVuCbEK4DDXlmi8lcV1b81OIhOpiubSD2jO6BZGM/9WNRpTC7Citc4c3qPbrHBUB7YhMxr1jenFM3JMhBHshBT5PcKl/2UAwWWAKBHI_0zU7sLfjozmcyhEcVle2c6mHQFZFkvswiyH2nb/6QaTP24vcPf4GozreIJnqZUN7WHYoOoCLz2dcgdVUOJ3sdiIh3/uf8uPlJanFCgkSiYnPwzTbIMc637zTK2ND_MsBK9BwMcEbQ9Xr/au_RXEqbjEMNRIelgPjosLpV_ZZ_JZqBg0UC1L8wlbsgYPLQEc/knywh8I1Ke41Cs1rcT4AZfoI0F6EsGyuVcgJTP3VJRqpRfTv7j/HTbaBPgyw4Z94_kzb40tCMzAWzYnerChJQmMeGND_kX6zXnBAO/QjyQLjX3OPyApIg0s4nwAqFGIoGmytUVOt2k4o0qpWNqvwxufg/RtEgL9yEQBp1wSX4bYwze7kf_BMh0sISAJBPNFnH5c9r6ydxsX

echo "01. POST /v2/entities to create entity"
echo "======================================"
payload='{
"id": "8787GHY",
"type": "Car",
"brand":{
"type": "string",
"value": "Mercedes Benz"
},
"speed":{
"type": "number",
"value" : "150"
},
"plateCountry": {
"value" : "ES"
},
"madeInCountry": {
"value" : "DE",
"type" : ""
},
"model" : {
"type": "myString",
"value" : "Klasse C"
}
}'
orionCurl --url /v2/entities --payload "$payload" --servicePath "$SP_LONG" --json
echo
echo


echo "02. GET /v2/entities/8787GHY"
echo "============================"
orionCurl --url "/v2/entities/8787GHY" --servicePath "$SP_LONG" --json
echo
echo


echo "03. PUT /v2/entities/8787GHY/attrs/speed"
echo "========================================"
payload='{
"value" : "999"
}'
orionCurl --url "/v2/entities/8787GHY/attrs/speed" --payload "$payload" --servicePath "$SP_LONG" --json -X PUT
echo
echo


echo "04. DELETE /v2/entities/8787GHY"
echo "==============================="
orionCurl --url "/v2/entities/8787GHY" --servicePath "$SP_LONG" --json -X DELETE
echo
echo


--REGEXPECT--
01. POST /v2/entities to create entity
======================================
HTTP/1.1 201 Created
Content-Length: 0
Location: /v2/entities/8787GHY
Date: REGEX(.*)



02. GET /v2/entities/8787GHY
============================
HTTP/1.1 200 OK
Content-Length: 321
Content-Type: application/json
Date: REGEX(.*)

{
"brand": {
"metadata": {},
"type": "string",
"value": "Mercedes Benz"
},
"id": "8787GHY",
"madeInCountry": {
"metadata": {},
"type": null,
"value": "DE"
},
"model": {
"metadata": {},
"type": "myString",
"value": "Klasse C"
},
"plateCountry": {
"metadata": {},
"type": null,
"value": "ES"
},
"speed": {
"metadata": {},
"type": "number",
"value": "150"
},
"type": "Car"
}


03. PUT /v2/entities/8787GHY/attrs/speed
========================================
HTTP/1.1 204 No Content
Content-Length: 0
Date: REGEX(.*)



04. DELETE /v2/entities/8787GHY
===============================
HTTP/1.1 204 No Content
Content-Length: 0
Date: REGEX(.*)



--TEARDOWN--
brokerStop CB
dbDrop CB

0 comments on commit 20f0c02

Please sign in to comment.