Skip to content

Commit

Permalink
FIX Issue telefonicaid#2948 - Update
Browse files Browse the repository at this point in the history
- Fixed HttpStatusCode of the response
- New test for the fixed issue added
- New entry in CHANGES_NEXT_RELEASE added
  • Loading branch information
arigliano committed Nov 6, 2017
1 parent 8d81141 commit 70855cb
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Add: CORS Preflight Requests support for /v2 and /v2/entities, -corsMaxAge switch (#501)
- Fix: case-sensitive header duplication (e.g. "Content-Type" and "Content-type") in custom notifications (#2893)
- Fix: bug in GTE and LTE operations in query filters (q/mq), both for GET operations and subscriptions (#2995)
- Fix: Wrong "max one service-path allowed for subscriptions" in NGSIv2 subscription operation (#2948)
3 changes: 2 additions & 1 deletion src/lib/serviceRoutines/postSubscribeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ std::string postSubscribeContext
{
char noOfV[STRING_SIZE_FOR_INT];
snprintf(noOfV, sizeof(noOfV), "%lu", ciP->servicePathV.size());
std::string details = std::string("max *one* service-path allowed for subscriptions (") + noOfV + " given";
ciP->httpStatusCode = SccBadRequest;
std::string details = std::string("max *one* service-path allowed for subscriptions (") + noOfV + " given";

alarmMgr.badInput(clientIp, details);

Expand Down
1 change: 1 addition & 0 deletions src/lib/serviceRoutinesV2/postSubscriptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extern std::string postSubscriptions
{
const size_t MSG_SIZE = 96; // strlen(msg) + enough room for digits
char errMsg[MSG_SIZE];
ciP->httpStatusCode = SccBadRequest;

snprintf(errMsg, MSG_SIZE, "max *one* service-path allowed for subscriptions (%lu given)",
(unsigned long) ciP->servicePathV.size());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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--
Wrong "max one service-path allowed for subscriptions" in NGSIv2 subscription operation

--SHELL-INIT--
dbInit CB
brokerStart CB

--SHELL--

#
# 01. Create subscription for E1 with multiple service paths header

#

echo "01. Create subscription for E1 with multiple service paths header"
echo "=============================================================="
payload='{
"subject": {
"entities": [
{
"id" : "E1"
}
],
"condition": {
"attrs": []
}
},
"notification": {
"httpCustom": {
"url": "http://localhost:1028/accumulate"
}
}
}'
orionCurl --url /v2/subscriptions --payload "$payload" --header "Fiware-ServicePath:/Madrid/Gardens/ParqueNorte, /Madrid/Gardens/ParqueOeste"
echo
echo


--REGEXPECT--
01. Create subscription for E1 with multiple service paths header
==============================================================
HTTP/1.1 400 Bad Request
Content-Length: 86
Content-Type: application/json
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Date: REGEX(.*)

{
"description": "max one service-path allowed for subscriptions",
"error": "Bad Request"
}


--TEARDOWN--
brokerStop CB
dbDrop CB

0 comments on commit 70855cb

Please sign in to comment.