Skip to content

Commit

Permalink
Merge pull request #854 from telefonicaid/fix/check_endpoint_exp
Browse files Browse the repository at this point in the history
fix check endpoint expression for http commands
  • Loading branch information
fgalan authored Jan 20, 2025
2 parents e5f0442 + 3f689a4 commit df25c83
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions lib/bindings/HTTPBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -516,7 +516,6 @@ function setPollingAndDefaultTransport(device, group, callback) {
device.polling = !(group && group.endpoint);
}
}

callback(null, device);
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/ngsiv2/HTTP_commands_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down

0 comments on commit df25c83

Please sign in to comment.