diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 6efdb001..e5cd0794 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,3 +1,4 @@ +- Fix: check endpoint expression when execute http command - Fix: use config.defaultTransport (from config.js or IOTA_DEFAULT_TRANSPORT env var) instead of magic 'HTTP' at provision device - Add: X-Processing-Time response header with processing time (in milliseconds) expended by current HTTP measure (iotagent-node-lib#1650) - Add: print also IOTA_CONFIG_RETRIEVAL, IOTA_DEFAULT_KEY, IOTA_DEFAULT_TRANSPORT env var values at iotagent startup diff --git a/lib/bindings/HTTPBinding.js b/lib/bindings/HTTPBinding.js index 6ac7b6ff..59ea18a9 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); } diff --git a/test/unit/ngsiv2/HTTP_commands_test.js b/test/unit/ngsiv2/HTTP_commands_test.js index 26041529..4e4e820e 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: [ {