iotagent-node-lib 2.18.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +1 -2
- package/.nyc_output/76bc24ff-5fac-4b5a-997d-de2799342eb0.json +1 -0
- package/.nyc_output/processinfo/76bc24ff-5fac-4b5a-997d-de2799342eb0.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/.readthedocs.yml +3 -1
- package/CHANGES_NEXT_RELEASE +1 -0
- package/README.md +5 -56
- package/doc/advanced-topics.md +121 -85
- package/doc/api.md +63 -54
- package/doc/development.md +8 -9
- package/doc/expressionLanguage.md +517 -316
- package/doc/installationguide.md +66 -64
- package/doc/northboundinteractions.md +40 -33
- package/doc/requirements.txt +4 -0
- package/{docs → doc}/roadmap.md +21 -6
- package/doc/usermanual.md +50 -18
- package/docker/Mosquitto/Dockerfile +28 -11
- package/docker/Mosquitto/README.md +8 -6
- package/docker/Mosquitto/startMosquitto.sh +14 -4
- package/lib/fiware-iotagent-lib.js +4 -2
- package/lib/jexlTranformsMap.js +11 -1
- package/lib/model/Device.js +4 -1
- package/lib/model/Group.js +19 -1
- package/lib/plugins/expressionParser.js +6 -4
- package/lib/plugins/expressionPlugin.js +63 -22
- package/lib/plugins/jexlParser.js +3 -1
- package/lib/plugins/multiEntity.js +2 -21
- package/lib/request-shim.js +111 -0
- package/lib/services/common/domain.js +6 -2
- package/lib/services/common/genericMiddleware.js +6 -2
- package/lib/services/common/iotManagerService.js +1 -1
- package/lib/services/common/securityServiceKeystone.js +1 -1
- package/lib/services/common/securityServiceOAuth2.js +3 -2
- package/lib/services/devices/deviceRegistryMemory.js +13 -2
- package/lib/services/devices/deviceRegistryMongoDB.js +16 -7
- package/lib/services/devices/deviceService.js +26 -2
- package/lib/services/devices/devices-NGSI-LD.js +1 -1
- package/lib/services/devices/devices-NGSI-v2.js +2 -6
- package/lib/services/devices/registrationUtils.js +0 -2
- package/lib/services/ngsi/entities-NGSI-LD.js +97 -11
- package/lib/services/ngsi/entities-NGSI-v2.js +95 -8
- package/lib/services/ngsi/ngsiService.js +5 -4
- package/lib/services/northBound/contextServer-NGSI-LD.js +3 -2
- package/lib/services/northBound/contextServer-NGSI-v2.js +32 -27
- package/lib/services/northBound/contextServerUtils.js +1 -1
- package/lib/services/northBound/deviceProvisioningServer.js +31 -6
- package/lib/services/northBound/northboundServer.js +2 -0
- package/lib/services/northBound/restUtils.js +1 -1
- package/lib/templates/createDevice.json +12 -0
- package/lib/templates/updateDevice.json +12 -0
- package/package.json +9 -15
- package/test/tools/utils.js +2 -0
- package/test/unit/expressions/jexlExpression-test.js +5 -5
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +1 -1
- package/test/unit/general/deviceService-test.js +2 -5
- package/test/unit/general/loglevel-api_test.js +6 -11
- package/test/unit/general/startup-test.js +1 -0
- package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +1 -0
- package/test/unit/mongodb/mongodb-group-registry-test.js +1 -1
- package/test/unit/mongodb/mongodb-registry-test.js +2 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin12a.json +7 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin13.json +13 -13
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin31.json +15 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +17 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin33.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin34.json +17 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin4a.json +36 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin7.json +16 -16
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin8a.json +18 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1018 -0
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
- package/test/unit/ngsi-ld/general/deviceService-test.js +1 -1
- package/test/unit/ngsi-ld/general/https-support-test.js +2 -1
- package/test/unit/ngsi-ld/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsi-ld/general/startup-test.js +1 -0
- package/test/unit/ngsi-ld/lazyAndCommands/active-devices-attribute-update-test.js +3 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsi-ld/lazyAndCommands/lazy-devices-test.js +2 -6
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +2 -1
- package/test/unit/ngsi-ld/ngsiService/active-devices-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +1 -0
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +4 -3
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +1 -0
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +3 -2
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +61 -0
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +3 -2
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +1 -0
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +42 -54
- package/test/unit/ngsi-ld/provisioning/provisionDeviceMultientity-test.js +2 -1
- package/test/unit/ngsi-ld/provisioning/removeProvisionedDevice-test.js +4 -4
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +3 -5
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +12 -18
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin17.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +16 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +22 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36.json +1 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +25 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +25 -0
- package/test/unit/ngsiv2/expressions/expressionBasedTransformations-test.js +4 -4
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +561 -0
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +3 -2
- package/test/unit/ngsiv2/general/deviceService-test.js +9 -8
- package/test/unit/ngsiv2/general/https-support-test.js +2 -1
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +2 -1
- package/test/unit/ngsiv2/general/startup-test.js +1 -0
- package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +3 -1
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +2 -1
- package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +14 -18
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +3 -1
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +1 -0
- package/test/unit/ngsiv2/ngsiService/queryDeviceInformationInCb-test.js +0 -1
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +4 -3
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +3 -2
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +210 -0
- package/test/unit/ngsiv2/plugins/translation-inPlugins_test.js +1 -1
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +3 -2
- package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +2 -1
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +2 -1
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +3 -2
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +4 -3
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +42 -53
- package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +2 -1
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +4 -4
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +3 -4
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +13 -19
- package/test/unit/plugins/capture-configuration-inPlugins_test.js +3 -1
- package/test/unit/plugins/capture-provision-inPlugins_test.js +2 -1
- package/bin/agentConsole.js +0 -257
- package/bin/iotAgentTester.js +0 -44
- package/lib/command/commandLine.js +0 -918
- package/lib/command/migration.js +0 -176
- package/test/unit/general/migration-test.js +0 -256
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin20.json +0 -25
|
@@ -34,6 +34,7 @@ const context = {
|
|
|
34
34
|
};
|
|
35
35
|
const apply = async.apply;
|
|
36
36
|
let provisioningHandler;
|
|
37
|
+
let updatingHandler;
|
|
37
38
|
let removeDeviceHandler;
|
|
38
39
|
let updateDeviceTemplate;
|
|
39
40
|
let createDeviceTemplate;
|
|
@@ -53,6 +54,7 @@ const provisioningAPITranslation = {
|
|
|
53
54
|
protocol: 'protocol',
|
|
54
55
|
transport: 'transport',
|
|
55
56
|
endpoint: 'endpoint',
|
|
57
|
+
polling: 'polling',
|
|
56
58
|
attributes: 'active',
|
|
57
59
|
commands: 'commands',
|
|
58
60
|
lazy: 'lazy',
|
|
@@ -182,6 +184,8 @@ function attributeToProvisioningAPIFormat(attribute) {
|
|
|
182
184
|
entity_name: attribute.entity_name,
|
|
183
185
|
entity_type: attribute.entity_type,
|
|
184
186
|
mqtt: attribute.mqtt,
|
|
187
|
+
payloadType: attribute.payloadType,
|
|
188
|
+
contentType: attribute.contentType,
|
|
185
189
|
metadata: attribute.metadata
|
|
186
190
|
};
|
|
187
191
|
}
|
|
@@ -204,6 +208,7 @@ function toProvisioningAPIFormat(device) {
|
|
|
204
208
|
timezone: device.timezone,
|
|
205
209
|
timestamp: device.timestamp,
|
|
206
210
|
endpoint: device.endpoint,
|
|
211
|
+
polling: device.polling,
|
|
207
212
|
transport: device.transport,
|
|
208
213
|
attributes: device.active ? device.active.map(attributeToProvisioningAPIFormat) : undefined,
|
|
209
214
|
lazy: device.lazy ? device.lazy.map(attributeToProvisioningAPIFormat) : undefined,
|
|
@@ -317,6 +322,14 @@ function handleRemoveDevice(req, res, next) {
|
|
|
317
322
|
* This middleware handles updates in the provisioning devices. The only attribute
|
|
318
323
|
*/
|
|
319
324
|
function handleUpdateDevice(req, res, next) {
|
|
325
|
+
function applyUpdatingHandler(device, callback) {
|
|
326
|
+
if (updatingHandler) {
|
|
327
|
+
updatingHandler(device, callback);
|
|
328
|
+
} else {
|
|
329
|
+
callback(null, device);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
320
333
|
if (req.body.device_id) {
|
|
321
334
|
next(new errors.BadRequest("Can't change the ID of a preprovisioned device"));
|
|
322
335
|
} else {
|
|
@@ -338,12 +351,19 @@ function handleUpdateDevice(req, res, next) {
|
|
|
338
351
|
if (req.body.entity_name || req.body.entity_type) {
|
|
339
352
|
isTypeOrNameUpdated = true;
|
|
340
353
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
354
|
+
async.waterfall([apply(applyUpdatingHandler, newDevice)], function handleUpdating(
|
|
355
|
+
error,
|
|
356
|
+
newDeviceUpdated
|
|
357
|
+
) {
|
|
358
|
+
deviceService.updateRegister(newDeviceUpdated, isTypeOrNameUpdated, function handleDeviceUpdate(
|
|
359
|
+
error
|
|
360
|
+
) {
|
|
361
|
+
if (error) {
|
|
362
|
+
next(error);
|
|
363
|
+
} else {
|
|
364
|
+
res.status(204).json({});
|
|
365
|
+
}
|
|
366
|
+
});
|
|
347
367
|
});
|
|
348
368
|
} else {
|
|
349
369
|
next(new errors.DeviceNotFound(req.params.deviceId));
|
|
@@ -392,6 +412,10 @@ function setProvisioningHandler(newHandler) {
|
|
|
392
412
|
provisioningHandler = newHandler;
|
|
393
413
|
}
|
|
394
414
|
|
|
415
|
+
function setUpdatingHandler(newHandler) {
|
|
416
|
+
updatingHandler = newHandler;
|
|
417
|
+
}
|
|
418
|
+
|
|
395
419
|
function setRemoveDeviceHandler(newHandler) {
|
|
396
420
|
removeDeviceHandler = newHandler;
|
|
397
421
|
}
|
|
@@ -409,6 +433,7 @@ function clear(callback) {
|
|
|
409
433
|
exports.setConfiguration = setConfiguration;
|
|
410
434
|
exports.loadContextRoutes = intoTrans(context, loadContextRoutes);
|
|
411
435
|
exports.setProvisioningHandler = intoTrans(context, setProvisioningHandler);
|
|
436
|
+
exports.setUpdatingHandler = intoTrans(context, setUpdatingHandler);
|
|
412
437
|
exports.setRemoveDeviceHandler = intoTrans(context, setRemoveDeviceHandler);
|
|
413
438
|
exports.addDeviceProvisionMiddleware = addDeviceProvisionMiddleware;
|
|
414
439
|
exports.clear = clear;
|
|
@@ -31,6 +31,7 @@ const domainUtils = require('../common/domain');
|
|
|
31
31
|
const middlewares = require('../common/genericMiddleware');
|
|
32
32
|
const intoTrans = domainUtils.intoTrans;
|
|
33
33
|
const deviceProvisioning = require('./deviceProvisioningServer');
|
|
34
|
+
const deviceUpdating = require('./deviceProvisioningServer');
|
|
34
35
|
const groupProvisioning = require('./deviceGroupAdministrationServer');
|
|
35
36
|
const logger = require('logops');
|
|
36
37
|
const context = {
|
|
@@ -116,6 +117,7 @@ exports.setNotificationHandler = intoTrans(context, contextServer.setNotificatio
|
|
|
116
117
|
exports.setConfigurationHandler = intoTrans(context, groupProvisioning.setConfigurationHandler);
|
|
117
118
|
exports.setRemoveConfigurationHandler = intoTrans(context, groupProvisioning.setRemoveConfigurationHandler);
|
|
118
119
|
exports.setProvisioningHandler = intoTrans(context, deviceProvisioning.setProvisioningHandler);
|
|
120
|
+
exports.setUpdatingHandler = intoTrans(context, deviceUpdating.setUpdatingHandler);
|
|
119
121
|
exports.setRemoveDeviceHandler = intoTrans(context, deviceProvisioning.setRemoveDeviceHandler);
|
|
120
122
|
exports.addDeviceProvisionMiddleware = deviceProvisioning.addDeviceProvisionMiddleware;
|
|
121
123
|
exports.addConfigurationProvisionMiddleware = groupProvisioning.addConfigurationProvisionMiddleware;
|
|
@@ -35,7 +35,7 @@ const context = {
|
|
|
35
35
|
op: 'IoTAgentNGSI.RestUtils'
|
|
36
36
|
};
|
|
37
37
|
const _ = require('underscore');
|
|
38
|
-
const request = require('request');
|
|
38
|
+
const request = require('../../request-shim');
|
|
39
39
|
const async = require('async');
|
|
40
40
|
const apply = async.apply;
|
|
41
41
|
const ngsiService = require('../ngsi/ngsiService');
|
|
@@ -173,6 +173,18 @@
|
|
|
173
173
|
"type": "string",
|
|
174
174
|
"pattern": "^([^<>();'=\"]+)*$"
|
|
175
175
|
},
|
|
176
|
+
"expression": {
|
|
177
|
+
"description": "Optional expression for command transformation",
|
|
178
|
+
"type": "string"
|
|
179
|
+
},
|
|
180
|
+
"payloadType": {
|
|
181
|
+
"description": "Payload type",
|
|
182
|
+
"type": "string"
|
|
183
|
+
},
|
|
184
|
+
"contentType": {
|
|
185
|
+
"description": "Content type",
|
|
186
|
+
"type": "string"
|
|
187
|
+
},
|
|
176
188
|
"mqtt": {
|
|
177
189
|
"description": "Mqtt properties",
|
|
178
190
|
"type": "object",
|
|
@@ -158,6 +158,18 @@
|
|
|
158
158
|
"type": "string",
|
|
159
159
|
"pattern": "^([^<>();'=\"]+)*$"
|
|
160
160
|
},
|
|
161
|
+
"expression": {
|
|
162
|
+
"description": "Optional expression for command transformation",
|
|
163
|
+
"type": "string"
|
|
164
|
+
},
|
|
165
|
+
"payloadType": {
|
|
166
|
+
"description": "Payload type",
|
|
167
|
+
"type": "string"
|
|
168
|
+
},
|
|
169
|
+
"contentType": {
|
|
170
|
+
"description": "Content type",
|
|
171
|
+
"type": "string"
|
|
172
|
+
},
|
|
161
173
|
"mqtt": {
|
|
162
174
|
"description": "Mqtt properties",
|
|
163
175
|
"type": "object",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "iotagent-node-lib",
|
|
3
3
|
"license": "AGPL-3.0-only",
|
|
4
4
|
"description": "IoT Agent library to interface with NGSI Context Broker",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.21.0",
|
|
6
6
|
"homepage": "https://github.com/telefonicaid/iotagent-node-lib",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"fiware",
|
|
@@ -21,22 +21,18 @@
|
|
|
21
21
|
"bugs": {
|
|
22
22
|
"url": "https://github.com/telefonicaid/iotagent-node-lib/issues"
|
|
23
23
|
},
|
|
24
|
-
"bin": {
|
|
25
|
-
"agentConsole": "bin/agentConsole.js",
|
|
26
|
-
"iotAgentTester": "bin/iotAgentTester.js"
|
|
27
|
-
},
|
|
28
24
|
"main": "lib/fiware-iotagent-lib",
|
|
29
25
|
"engines": {
|
|
30
26
|
"node": ">=12"
|
|
31
27
|
},
|
|
32
28
|
"scripts": {
|
|
33
29
|
"clean": "rm -rf package-lock.json && rm -rf node_modules && rm -rf coverage",
|
|
34
|
-
"lint": "eslint lib/
|
|
30
|
+
"lint": "eslint lib/ test/ --cache --fix",
|
|
35
31
|
"lint:md": "remark -f '*.md' 'doc/*.md'",
|
|
36
32
|
"lint:text": "textlint '*.md' 'doc/*.md'",
|
|
37
33
|
"prettier": "prettier --config .prettierrc.json --write '**/**/**/**/*.js' '**/**/**/*.js' '**/**/*.js' '**/*.js' '*.js'",
|
|
38
34
|
"prettier:text": "prettier 'README.md' 'doc/*.md' 'doc/**/*.md' --no-config --tab-width 4 --print-width 120 --write --prose-wrap always",
|
|
39
|
-
"test": "nyc --reporter=text mocha --recursive 'test/**/*.js' --reporter spec --timeout
|
|
35
|
+
"test": "nyc --reporter=text mocha --recursive 'test/**/*.js' --reporter spec --timeout 8000 --ui bdd --exit --color true",
|
|
40
36
|
"test:expression": "nyc --reporter=text mocha --recursive 'test/unit/expressions/*.js' --reporter spec --timeout 5000 --ui bdd --exit --color true",
|
|
41
37
|
"test:multientity": "nyc --reporter=text mocha --recursive 'test/unit/ngsiv2/plugins/multientity-plugin_test.js' --reporter spec --timeout 5000 --ui bdd --exit --color true",
|
|
42
38
|
"test:debug": "mocha --recursive 'test/**/*.js' --reporter spec --inspect-brk --timeout 30000 --ui bdd --exit",
|
|
@@ -46,20 +42,18 @@
|
|
|
46
42
|
"watch": "watch 'npm test && npm run lint' ./lib ./test"
|
|
47
43
|
},
|
|
48
44
|
"dependencies": {
|
|
49
|
-
"async": "2.6.
|
|
45
|
+
"async": "2.6.4",
|
|
50
46
|
"body-parser": "~1.19.0",
|
|
51
|
-
"command-shell-lib": "1.0.0",
|
|
52
47
|
"express": "~4.16.4",
|
|
48
|
+
"got": "~11.8.2",
|
|
53
49
|
"jexl": "2.3.0",
|
|
54
50
|
"jison": "0.4.18",
|
|
55
|
-
"logops": "2.1.
|
|
56
|
-
"moment": "~2.
|
|
51
|
+
"logops": "2.1.2",
|
|
52
|
+
"moment": "~2.29.2",
|
|
57
53
|
"moment-timezone": "~0.5.25",
|
|
58
|
-
"mongodb": "3.6.
|
|
59
|
-
"mongoose": "5.7.
|
|
60
|
-
"mu2": "~0.5.20",
|
|
54
|
+
"mongodb": "3.6.12",
|
|
55
|
+
"mongoose": "5.7.14",
|
|
61
56
|
"query-string": "6.5.0",
|
|
62
|
-
"request": "2.88.0",
|
|
63
57
|
"revalidator": "~0.3.1",
|
|
64
58
|
"underscore": "~1.12.1",
|
|
65
59
|
"uuid": "~3.3.2"
|
package/test/tools/utils.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
const fs = require('fs');
|
|
25
|
+
const request = require('../../lib/fiware-iotagent-lib').request;
|
|
25
26
|
|
|
26
27
|
function readExampleFile(name, raw) {
|
|
27
28
|
let text = null;
|
|
@@ -36,3 +37,4 @@ function readExampleFile(name, raw) {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
exports.readExampleFile = readExampleFile;
|
|
40
|
+
exports.request = request;
|
|
@@ -269,7 +269,7 @@ describe('Jexl expression interpreter', function () {
|
|
|
269
269
|
const noMap = "I'm not what you expect";
|
|
270
270
|
|
|
271
271
|
it('it should detect when it is not a map', function (done) {
|
|
272
|
-
|
|
272
|
+
const [error, message, resultMap] = expressionParser.checkTransformationMap(noMap);
|
|
273
273
|
should.exist(error);
|
|
274
274
|
message.should.equal('No trasformations were added to JEXL Parser');
|
|
275
275
|
resultMap.should.eql({});
|
|
@@ -277,7 +277,7 @@ describe('Jexl expression interpreter', function () {
|
|
|
277
277
|
});
|
|
278
278
|
|
|
279
279
|
it('it should be empty {}', function (done) {
|
|
280
|
-
|
|
280
|
+
const [error, message, resultMap] = expressionParser.checkTransformationMap({});
|
|
281
281
|
should.not.exist(error);
|
|
282
282
|
message.should.equal('No trasformations were added to JEXL Parser');
|
|
283
283
|
resultMap.should.eql({});
|
|
@@ -285,7 +285,7 @@ describe('Jexl expression interpreter', function () {
|
|
|
285
285
|
});
|
|
286
286
|
|
|
287
287
|
it('it should be empty null', function (done) {
|
|
288
|
-
|
|
288
|
+
const [error, message, resultMap] = expressionParser.checkTransformationMap(null);
|
|
289
289
|
should.not.exist(error);
|
|
290
290
|
message.should.equal('No trasformations were added to JEXL Parser');
|
|
291
291
|
resultMap.should.eql({});
|
|
@@ -293,7 +293,7 @@ describe('Jexl expression interpreter', function () {
|
|
|
293
293
|
});
|
|
294
294
|
|
|
295
295
|
it('it should detect wrong transformations (not a funtion)', function (done) {
|
|
296
|
-
|
|
296
|
+
const [error, message, resultMap] = expressionParser.checkTransformationMap(wrongMap);
|
|
297
297
|
should.not.exist(error);
|
|
298
298
|
message.should.equal('wrongTransformation1,wrongTransformation2 must be a function');
|
|
299
299
|
should.not.exist(resultMap.wrongTransformation1);
|
|
@@ -303,7 +303,7 @@ describe('Jexl expression interpreter', function () {
|
|
|
303
303
|
});
|
|
304
304
|
|
|
305
305
|
it('it should be correct (map of funtions)', function (done) {
|
|
306
|
-
|
|
306
|
+
const [error, message, resultMap] = expressionParser.checkTransformationMap(niceMap);
|
|
307
307
|
should.not.exist(error);
|
|
308
308
|
message.should.equal('Trasformations can be added to JEXL parser');
|
|
309
309
|
resultMap.should.eql(niceMap);
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
|
|
26
26
|
const iotAgentLib = require('../../../lib/fiware-iotagent-lib');
|
|
27
27
|
const utils = require('../../tools/utils');
|
|
28
|
+
const request = utils.request;
|
|
28
29
|
const should = require('should');
|
|
29
30
|
const logger = require('logops');
|
|
30
31
|
const nock = require('nock');
|
|
31
|
-
const request = require('request');
|
|
32
32
|
let contextBrokerMock;
|
|
33
33
|
let keystoneMock;
|
|
34
34
|
const iotAgentConfig = {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
|
|
26
26
|
const iotAgentLib = require('../../../lib/fiware-iotagent-lib');
|
|
27
27
|
const utils = require('../../tools/utils');
|
|
28
|
+
const request = utils.request;
|
|
28
29
|
const should = require('should');
|
|
29
30
|
const nock = require('nock');
|
|
30
|
-
const request = require('request');
|
|
31
31
|
const logger = require('logops');
|
|
32
32
|
const async = require('async');
|
|
33
33
|
const iotAgentConfig = {
|
|
@@ -187,14 +187,12 @@ describe('NGSI-v2 - Device Service: utils', function () {
|
|
|
187
187
|
.post('/v2/registrations')
|
|
188
188
|
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
|
|
189
189
|
|
|
190
|
-
|
|
191
190
|
contextBrokerMock
|
|
192
191
|
.matchHeader('fiware-service', 'testservice')
|
|
193
192
|
.matchHeader('fiware-servicepath', '/testingPath')
|
|
194
193
|
.post('/v2/entities?options=upsert')
|
|
195
194
|
.reply(204);
|
|
196
195
|
|
|
197
|
-
|
|
198
196
|
async.series([request.bind(request, groupCreation), request.bind(request, deviceCreation)], function (
|
|
199
197
|
error,
|
|
200
198
|
results
|
|
@@ -222,11 +220,10 @@ describe('NGSI-v2 - Device Service: utils', function () {
|
|
|
222
220
|
.post('/v2/registrations')
|
|
223
221
|
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
|
|
224
222
|
|
|
225
|
-
|
|
226
223
|
contextBrokerMock
|
|
227
224
|
.matchHeader('fiware-service', 'testservice')
|
|
228
225
|
.matchHeader('fiware-servicepath', '/testingPath')
|
|
229
|
-
|
|
226
|
+
.post('/v2/entities?options=upsert')
|
|
230
227
|
.reply(204);
|
|
231
228
|
|
|
232
229
|
async.series([request.bind(request, groupCreation)], function (error, results) {
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
const iotAgentLib = require('../../../lib/fiware-iotagent-lib');
|
|
27
27
|
const should = require('should');
|
|
28
28
|
const logger = require('logops');
|
|
29
|
-
const
|
|
29
|
+
const utils = require('../../tools/utils');
|
|
30
|
+
const request = utils.request;
|
|
30
31
|
const iotAgentConfig = {
|
|
31
32
|
contextBroker: {
|
|
32
33
|
host: '192.168.1.1',
|
|
@@ -129,10 +130,8 @@ describe('Log level API', function () {
|
|
|
129
130
|
|
|
130
131
|
it('should return the current log level', function (done) {
|
|
131
132
|
request(options, function (error, response, body) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
should.exist(parsedBody.level);
|
|
135
|
-
parsedBody.level.should.equal('FATAL');
|
|
133
|
+
should.exist(body.level);
|
|
134
|
+
body.level.should.equal('FATAL');
|
|
136
135
|
|
|
137
136
|
done();
|
|
138
137
|
});
|
|
@@ -158,9 +157,7 @@ describe('Log level API', function () {
|
|
|
158
157
|
response.statusCode.should.equal(400);
|
|
159
158
|
should.exist(body);
|
|
160
159
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
parsedBody.error.should.equal('invalid log level');
|
|
160
|
+
body.error.should.equal('invalid log level');
|
|
164
161
|
|
|
165
162
|
done();
|
|
166
163
|
});
|
|
@@ -183,9 +180,7 @@ describe('Log level API', function () {
|
|
|
183
180
|
response.statusCode.should.equal(400);
|
|
184
181
|
should.exist(body);
|
|
185
182
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
parsedBody.error.should.equal('log level missing');
|
|
183
|
+
body.error.should.equal('log level missing');
|
|
189
184
|
|
|
190
185
|
done();
|
|
191
186
|
});
|
|
@@ -28,6 +28,7 @@ const iotAgentLib = require('../../../lib/fiware-iotagent-lib');
|
|
|
28
28
|
const should = require('should');
|
|
29
29
|
const nock = require('nock');
|
|
30
30
|
const utils = require('../../tools/utils');
|
|
31
|
+
const request = utils.request;
|
|
31
32
|
const config = require('../../../lib/commonConfig');
|
|
32
33
|
const _ = require('underscore');
|
|
33
34
|
const iotAgentConfig = {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
const iotAgentLib = require('../../../lib/fiware-iotagent-lib');
|
|
29
29
|
const _ = require('underscore');
|
|
30
30
|
const utils = require('../../tools/utils');
|
|
31
|
+
const request = utils.request;
|
|
31
32
|
const async = require('async');
|
|
32
|
-
const request = require('request');
|
|
33
33
|
const should = require('should');
|
|
34
34
|
const iotAgentConfig = {
|
|
35
35
|
logLevel: 'FATAL',
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
const iotAgentLib = require('../../../lib/fiware-iotagent-lib');
|
|
27
27
|
const utils = require('../../tools/utils');
|
|
28
|
+
const request = utils.request;
|
|
28
29
|
const should = require('should');
|
|
29
30
|
const logger = require('logops');
|
|
30
31
|
const mongo = require('mongodb').MongoClient;
|
|
@@ -375,7 +376,7 @@ describe('NGSI-v2 - MongoDB Device Registry', function () {
|
|
|
375
376
|
|
|
376
377
|
contextBrokerMock.post('/v2/entities?options=upsert').reply(204);
|
|
377
378
|
|
|
378
|
-
contextBrokerMock.delete('/v2/registrations/6319a7f5254b05844116584d').reply(204);
|
|
379
|
+
contextBrokerMock.delete('/v2/registrations/6319a7f5254b05844116584d', '').reply(204);
|
|
379
380
|
|
|
380
381
|
iotAgentLib.activate(iotAgentConfig, function (error) {
|
|
381
382
|
async.series(
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"consumption_x": {
|
|
5
|
+
"type": "Property",
|
|
6
|
+
"value": 200
|
|
7
|
+
},
|
|
8
|
+
"pressure": {
|
|
9
|
+
"type": "Property",
|
|
10
|
+
"value": 10
|
|
11
|
+
},
|
|
12
|
+
"id": "urn:ngsi-ld:Light:light1",
|
|
13
|
+
"type": "Light"
|
|
14
|
+
}
|
|
15
15
|
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"pressure": {
|
|
5
|
+
"type": "Property",
|
|
6
|
+
"value": 1040
|
|
7
|
+
},
|
|
8
|
+
"weather": {
|
|
9
|
+
"type": "Property",
|
|
10
|
+
"value": {
|
|
11
|
+
"@type": "Summary",
|
|
12
|
+
"@value": "Humidity NaN and pressure 1040"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"id": "urn:ngsi-ld:WeatherStation:ws1",
|
|
16
|
+
"type": "WeatherStation"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"pressure": {
|
|
5
|
+
"type": "Property",
|
|
6
|
+
"value": 1040
|
|
7
|
+
},
|
|
8
|
+
"weather": {
|
|
9
|
+
"type": "Property",
|
|
10
|
+
"value": {
|
|
11
|
+
"@type": "Summary",
|
|
12
|
+
"@value": "Humidity NaN and pressure 1040"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"id": "urn:ngsi-ld:WeatherStation:ws1",
|
|
16
|
+
"type": "WeatherStation"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"location": {
|
|
5
|
+
"type": "GeoProperty",
|
|
6
|
+
"value": {
|
|
7
|
+
"coordinates": [
|
|
8
|
+
13,
|
|
9
|
+
52
|
|
10
|
+
],
|
|
11
|
+
"type": "Point"
|
|
12
|
+
},
|
|
13
|
+
"observedAt": "2015-08-05T07:35:01.468Z"
|
|
14
|
+
},
|
|
15
|
+
"id": "urn:ngsi-ld:GPS:gps1",
|
|
16
|
+
"type": "GPS"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"pressure25": {
|
|
5
|
+
"type": "Property",
|
|
6
|
+
"value": 52
|
|
7
|
+
},
|
|
8
|
+
"humidity12": {
|
|
9
|
+
"type": "Property",
|
|
10
|
+
"value": {
|
|
11
|
+
"@type": "Percentage",
|
|
12
|
+
"@value": "12"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"weather": {
|
|
16
|
+
"type": "Property",
|
|
17
|
+
"value": {
|
|
18
|
+
"@type": "Summary",
|
|
19
|
+
"@value": "Humidity 6 and pressure 1040"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"alive": {
|
|
23
|
+
"type": "Property",
|
|
24
|
+
"value": {
|
|
25
|
+
"@type": "None",
|
|
26
|
+
"@value": "undefined"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"updated": {
|
|
30
|
+
"type": "Property",
|
|
31
|
+
"value": true
|
|
32
|
+
},
|
|
33
|
+
"id": "urn:ngsi-ld:WeatherStation:ws1",
|
|
34
|
+
"type": "WeatherStation"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
{
|
|
3
|
+
"@context": "http://context.json-ld",
|
|
4
|
+
"revisions": {
|
|
5
|
+
"type": "Property",
|
|
6
|
+
"value": {
|
|
7
|
+
"@type": "Array",
|
|
8
|
+
"@value": [
|
|
9
|
+
"v0.1",
|
|
10
|
+
"v0.2",
|
|
11
|
+
"v0.3"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"id": "urn:ngsi-ld:Light:light1",
|
|
16
|
+
"type": "Light"
|
|
17
|
+
}
|
|
18
18
|
]
|