From 765e69570ece8d41770025a402b7751d57a9e2e0 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 16 Jan 2025 16:30:19 +0100 Subject: [PATCH 1/3] fix check endpoint expresison --- lib/bindings/HTTPBinding.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/bindings/HTTPBinding.js b/lib/bindings/HTTPBinding.js index bfb64b4ed..2f61fcc42 100644 --- a/lib/bindings/HTTPBinding.js +++ b/lib/bindings/HTTPBinding.js @@ -214,7 +214,7 @@ function executeCommand(apiKey, group, device, cmdName, serializedPayload, conte 'content-type': contentType } }; - if (options.endpoint) { + if (options.url) { // endpoint could be an expression const parser = iotAgentLib.dataPlugins.expressionTransformation; let attrList = iotAgentLib.dataPlugins.utils.getIdTypeServSubServiceFromDevice(device); @@ -224,11 +224,11 @@ function executeCommand(apiKey, group, device, cmdName, serializedPayload, conte // expression result will be the full command payload let endpointRes = null; try { - endpointRes = parser.applyExpression(options.endpoint, ctxt, device); + endpointRes = parser.applyExpression(options.url, ctxt, device); } catch (e) { // no error should be reported } - options.url = endpointRes ? endpointRes : options.endpoint; + options.url = endpointRes ? endpointRes : options.url; } if (config.getConfig().http.timeout) { options.timeout = config.getConfig().http.timeout; @@ -516,7 +516,6 @@ function setPollingAndDefaultTransport(device, group, callback) { device.polling = !(group && group.endpoint); } } - callback(null, device); } From 0b56fb1877193ff1c65d1e5e7fb6b6476459e664 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Fri, 17 Jan 2025 10:09:34 +0100 Subject: [PATCH 2/3] Update CHANGES_NEXT_RELEASE --- CHANGES_NEXT_RELEASE | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 89a933723..0dbecb4a9 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1 +1,2 @@ +- Fix: check endpoint expression when execute http command - Add: X-Processing-Time response header with processing time (in milliseconds) expended by current HTTP measure (iotagent-node-lib#1650) From 9cbeac8c7d4ddcc82b796944ebb3d618d735ccb0 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Fri, 17 Jan 2025 10:15:44 +0100 Subject: [PATCH 3/3] update test --- test/unit/ngsiv2/HTTP_commands_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/ngsiv2/HTTP_commands_test.js b/test/unit/ngsiv2/HTTP_commands_test.js index 260415292..4e4e820ed 100644 --- a/test/unit/ngsiv2/HTTP_commands_test.js +++ b/test/unit/ngsiv2/HTTP_commands_test.js @@ -45,7 +45,7 @@ const groupCreation = { resource: '/iot/json', apikey: 'KL223HHV8732SFL1', entity_type: 'TheLightType', - endpoint: 'http://localhost:9876/command', + endpoint: '"http://localhost:9876/" + "command"', transport: 'HTTP', commands: [ {