iotagent-node-lib 3.2.0 → 3.4.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/ISSUE_TEMPLATE/bug_report.yml +134 -0
- package/.github/ISSUE_TEMPLATE/config.yml +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +55 -0
- package/.github/advanced-issue-labeler.yml +30 -0
- package/.github/workflows/issue-labeler.yml +43 -0
- package/README.md +10 -11
- package/doc/README.md +16 -0
- package/doc/admin.md +565 -0
- package/doc/api.md +32 -85
- package/doc/deprecated.md +16 -10
- package/doc/{architecture.md → devel/architecture.md} +3 -3
- package/doc/{Contribution.md → devel/contribution-guidelines.md} +43 -35
- package/doc/devel/development.md +1879 -0
- package/doc/{northboundinteractions.md → devel/northboundinteractions.md} +18 -33
- package/doc/index.md +3 -5
- package/doc/requirements.txt +1 -1
- package/docker/Mosquitto/Dockerfile +1 -1
- package/docker/Mosquitto/README.md +1 -0
- package/lib/commonConfig.js +0 -5
- package/lib/fiware-iotagent-lib.js +1 -1
- package/lib/jexlTranformsMap.js +2 -1
- package/lib/model/Device.js +0 -1
- package/lib/model/Group.js +0 -1
- package/lib/model/dbConn.js +1 -7
- package/lib/plugins/jexlParser.js +1 -1
- package/lib/request-shim.js +2 -2
- package/lib/services/commands/commandService.js +1 -1
- package/lib/services/common/genericMiddleware.js +1 -1
- package/lib/services/common/iotManagerService.js +0 -1
- package/lib/services/devices/deviceRegistryMemory.js +2 -2
- package/lib/services/devices/deviceRegistryMongoDB.js +32 -19
- package/lib/services/devices/deviceService.js +44 -43
- package/lib/services/devices/devices-NGSI-LD.js +14 -2
- package/lib/services/devices/devices-NGSI-mixed.js +0 -2
- package/lib/services/devices/devices-NGSI-v2.js +23 -104
- package/lib/services/groups/groupService.js +1 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +3 -3
- package/lib/services/ngsi/entities-NGSI-v2.js +28 -19
- package/lib/services/northBound/deviceProvisioningServer.js +14 -8
- package/lib/templates/createDevice.json +0 -4
- package/lib/templates/createDeviceLax.json +0 -4
- package/lib/templates/deviceGroup.json +1 -5
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +11 -0
- package/mkdocs.yml +6 -11
- package/package.json +3 -3
- package/scripts/legacy_expression_tool/README.md +280 -0
- package/scripts/legacy_expression_tool/legacy_expression_tool.py +423 -0
- package/scripts/legacy_expression_tool/requirements.txt +3 -0
- package/test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice4.json +0 -1
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +5 -15
- package/test/unit/mongodb/mongodb-registry-test.js +1 -1
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +66 -65
- package/test/unit/ngsi-ld/general/https-support-test.js +1 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +8 -7
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +31 -30
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +12 -11
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +41 -39
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +122 -122
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +28 -28
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +18 -17
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +7 -7
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +8 -7
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +33 -37
- package/test/unit/ngsiv2/examples/contextRequests/updateContext.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext1.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext4.json +4 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContext5.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast1.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast3.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast4.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast5.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast6.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAutocast7.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandExpired.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCommandStatus2.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin13.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin31.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin33.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +2 -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/updateContextExpressionPlugin4.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin40.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -10
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +2 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +2 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionSkip.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityJexlExpressionPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin12.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin13.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin14.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin17.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin2.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +2 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin9.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin1.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributes.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestamp.json +3 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalse.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampFalseTimeInstant.json +12 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverride.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampOverrideWithoutMilis.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextTimestampTimezone.json +3 -1
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +144 -85
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +20 -53
- package/test/unit/ngsiv2/general/https-support-test.js +2 -6
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +4 -10
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +8 -24
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +146 -65
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +14 -21
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +3 -5
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +11 -20
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +20 -30
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +4 -6
- package/test/unit/ngsiv2/plugins/custom-plugin_test.js +1 -2
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +3 -5
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +2 -3
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +2 -3
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +13 -156
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +9 -13
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +4 -10
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -11
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -8
- package/test/unit/plugins/capture-provision-inPlugins_test.js +0 -6
- package/.nyc_output/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
- package/.nyc_output/processinfo/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/doc/config-basic-example.js +0 -20
- package/doc/development.md +0 -285
- package/doc/howto.md +0 -645
- package/doc/installationguide.md +0 -370
- package/doc/operations.md +0 -127
- package/doc/usermanual.md +0 -900
- package/lib/plugins/bidirectionalData.js +0 -356
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +0 -697
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +0 -599
- /package/doc/{NorthboundInteractions.postman_collection → devel/NorthboundInteractions.postman_collection} +0 -0
- /package/doc/{echo.js → devel/echo.js} +0 -0
- /package/doc/{finalResult.js → devel/finalResult.js} +0 -0
|
@@ -146,11 +146,10 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
146
146
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
147
147
|
.matchHeader('fiware-service', 'smartgondor')
|
|
148
148
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
149
|
-
.
|
|
150
|
-
'/v2/entities
|
|
149
|
+
.post(
|
|
150
|
+
'/v2/entities?options=upsert',
|
|
151
151
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin1.json')
|
|
152
152
|
)
|
|
153
|
-
.query({ type: 'Light' })
|
|
154
153
|
.reply(204);
|
|
155
154
|
});
|
|
156
155
|
|
|
@@ -177,11 +176,10 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
177
176
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
178
177
|
.matchHeader('fiware-service', 'smartgondor')
|
|
179
178
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
180
|
-
.
|
|
181
|
-
'/v2/entities
|
|
179
|
+
.post(
|
|
180
|
+
'/v2/entities?options=upsert',
|
|
182
181
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin2.json')
|
|
183
182
|
)
|
|
184
|
-
.query({ type: 'Light' })
|
|
185
183
|
.reply(204);
|
|
186
184
|
});
|
|
187
185
|
|
|
@@ -208,11 +206,10 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
208
206
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
209
207
|
.matchHeader('fiware-service', 'smartgondor')
|
|
210
208
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
211
|
-
.
|
|
212
|
-
'/v2/entities
|
|
209
|
+
.post(
|
|
210
|
+
'/v2/entities?options=upsert',
|
|
213
211
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json')
|
|
214
212
|
)
|
|
215
|
-
.query({ type: 'Light' })
|
|
216
213
|
.reply(204);
|
|
217
214
|
});
|
|
218
215
|
|
|
@@ -240,11 +237,10 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
240
237
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
241
238
|
.matchHeader('fiware-service', 'smartgondor')
|
|
242
239
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
243
|
-
.
|
|
244
|
-
'/v2/entities
|
|
240
|
+
.post(
|
|
241
|
+
'/v2/entities?options=upsert',
|
|
245
242
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin3.json')
|
|
246
243
|
)
|
|
247
|
-
.query({ type: 'Light' })
|
|
248
244
|
.reply(204);
|
|
249
245
|
});
|
|
250
246
|
|
|
@@ -272,11 +268,10 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
272
268
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
273
269
|
.matchHeader('fiware-service', 'smartgondor')
|
|
274
270
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
275
|
-
.
|
|
276
|
-
'/v2/entities
|
|
271
|
+
.post(
|
|
272
|
+
'/v2/entities?options=upsert',
|
|
277
273
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin4.json')
|
|
278
274
|
)
|
|
279
|
-
.query({ type: 'Light' })
|
|
280
275
|
.reply(204);
|
|
281
276
|
});
|
|
282
277
|
|
|
@@ -304,11 +299,10 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
304
299
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
305
300
|
.matchHeader('fiware-service', 'smartgondor')
|
|
306
301
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
307
|
-
.
|
|
308
|
-
'/v2/entities
|
|
302
|
+
.post(
|
|
303
|
+
'/v2/entities?options=upsert',
|
|
309
304
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin5.json')
|
|
310
305
|
)
|
|
311
|
-
.query({ type: 'Light' })
|
|
312
306
|
.reply(204);
|
|
313
307
|
});
|
|
314
308
|
|
|
@@ -336,11 +330,10 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
336
330
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
337
331
|
.matchHeader('fiware-service', 'smartgondor')
|
|
338
332
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
339
|
-
.
|
|
340
|
-
'/v2/entities
|
|
333
|
+
.post(
|
|
334
|
+
'/v2/entities?options=upsert',
|
|
341
335
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin6.json')
|
|
342
336
|
)
|
|
343
|
-
.query({ type: 'Light' })
|
|
344
337
|
.reply(204);
|
|
345
338
|
});
|
|
346
339
|
|
|
@@ -368,11 +361,10 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
368
361
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
369
362
|
.matchHeader('fiware-service', 'smartgondor')
|
|
370
363
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
371
|
-
.
|
|
372
|
-
'/v2/entities
|
|
364
|
+
.post(
|
|
365
|
+
'/v2/entities?options=upsert',
|
|
373
366
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin7.json')
|
|
374
367
|
)
|
|
375
|
-
.query({ type: 'Light' })
|
|
376
368
|
.reply(204);
|
|
377
369
|
});
|
|
378
370
|
|
|
@@ -400,11 +392,10 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
400
392
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
401
393
|
.matchHeader('fiware-service', 'smartgondor')
|
|
402
394
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
403
|
-
.
|
|
404
|
-
'/v2/entities
|
|
395
|
+
.post(
|
|
396
|
+
'/v2/entities?options=upsert',
|
|
405
397
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json')
|
|
406
398
|
)
|
|
407
|
-
.query({ type: 'Light' })
|
|
408
399
|
.reply(204);
|
|
409
400
|
});
|
|
410
401
|
|
|
@@ -432,11 +423,10 @@ describe('NGSI-v2 - Attribute alias plugin', function () {
|
|
|
432
423
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
433
424
|
.matchHeader('fiware-service', 'smartgondor')
|
|
434
425
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
435
|
-
.
|
|
436
|
-
'/v2/entities
|
|
426
|
+
.post(
|
|
427
|
+
'/v2/entities?options=upsert',
|
|
437
428
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin9.json')
|
|
438
429
|
)
|
|
439
|
-
.query({ type: 'Light' })
|
|
440
430
|
.reply(204);
|
|
441
431
|
});
|
|
442
432
|
|
|
@@ -153,13 +153,12 @@ describe('NGSI-v2 - Timestamp compression plugin', function () {
|
|
|
153
153
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
154
154
|
.matchHeader('fiware-service', 'smartgondor')
|
|
155
155
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
156
|
-
.
|
|
157
|
-
'/v2/entities
|
|
156
|
+
.post(
|
|
157
|
+
'/v2/entities?options=upsert',
|
|
158
158
|
utils.readExampleFile(
|
|
159
159
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp1.json'
|
|
160
160
|
)
|
|
161
161
|
)
|
|
162
|
-
.query({ type: 'Light' })
|
|
163
162
|
.reply(204);
|
|
164
163
|
});
|
|
165
164
|
|
|
@@ -198,13 +197,12 @@ describe('NGSI-v2 - Timestamp compression plugin', function () {
|
|
|
198
197
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
199
198
|
.matchHeader('fiware-service', 'smartgondor')
|
|
200
199
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
201
|
-
.
|
|
202
|
-
'/v2/entities
|
|
200
|
+
.post(
|
|
201
|
+
'/v2/entities?options=upsert',
|
|
203
202
|
utils.readExampleFile(
|
|
204
203
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextCompressTimestamp2.json'
|
|
205
204
|
)
|
|
206
205
|
)
|
|
207
|
-
.query({ type: 'Light' })
|
|
208
206
|
.reply(204);
|
|
209
207
|
});
|
|
210
208
|
|
|
@@ -111,8 +111,7 @@ describe('NGSI-v2 - Custom plugin', function () {
|
|
|
111
111
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
112
112
|
.matchHeader('fiware-service', 'smartgondor')
|
|
113
113
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
114
|
-
.
|
|
115
|
-
.query({ type: 'Light' })
|
|
114
|
+
.post('/v2/entities?options=upsert')
|
|
116
115
|
.reply(204);
|
|
117
116
|
});
|
|
118
117
|
|
|
@@ -508,7 +508,6 @@ const iotAgentConfig = {
|
|
|
508
508
|
},
|
|
509
509
|
GPS1: {
|
|
510
510
|
commands: [],
|
|
511
|
-
expressionLanguage: 'jexl',
|
|
512
511
|
type: 'GPS',
|
|
513
512
|
lazy: [],
|
|
514
513
|
active: [
|
|
@@ -601,7 +600,7 @@ const iotAgentConfig = {
|
|
|
601
600
|
|
|
602
601
|
describe('NGSI-v2 - Multi-entity plugin', function () {
|
|
603
602
|
beforeEach(function (done) {
|
|
604
|
-
logger.setLevel('
|
|
603
|
+
logger.setLevel('DEBUG');
|
|
605
604
|
|
|
606
605
|
iotAgentLib.activate(iotAgentConfig, function () {
|
|
607
606
|
iotAgentLib.clearAll(function () {
|
|
@@ -1672,9 +1671,8 @@ describe('NGSI-v2 - Multi-entity plugin is executed for a command update for a r
|
|
|
1672
1671
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1673
1672
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1674
1673
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1675
|
-
.
|
|
1676
|
-
|
|
1677
|
-
'/v2/entities/sensorCommand/attrs?type=SensorCommand',
|
|
1674
|
+
.post(
|
|
1675
|
+
'/v2/entities?options=upsert',
|
|
1678
1676
|
utils.readExampleFile(
|
|
1679
1677
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin4.json'
|
|
1680
1678
|
)
|
|
@@ -98,14 +98,13 @@ describe('NGSI-v2 - Timestamp processing plugin', function () {
|
|
|
98
98
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
99
99
|
.matchHeader('fiware-service', 'smartgondor')
|
|
100
100
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
101
|
-
.
|
|
102
|
-
'/v2/entities
|
|
101
|
+
.post(
|
|
102
|
+
'/v2/entities?options=upsert',
|
|
103
103
|
// this tests breaks jexlBasedTransformation-test with uses updateContextExpressionPlugin32 which do not includes Timestamp in metadata attributes
|
|
104
104
|
utils.readExampleFile(
|
|
105
105
|
'./test/unit/ngsiv2/examples/contextRequests/updateContextProcessTimestamp.json'
|
|
106
106
|
)
|
|
107
107
|
)
|
|
108
|
-
.query({ type: 'Light' })
|
|
109
108
|
.reply(204);
|
|
110
109
|
});
|
|
111
110
|
|
|
@@ -906,11 +906,10 @@ describe('NGSI-v2 - Device Group Configuration API', function () {
|
|
|
906
906
|
contextBrokerMock = nock('http://unexistentHost:1026')
|
|
907
907
|
.matchHeader('fiware-service', 'testservice')
|
|
908
908
|
.matchHeader('fiware-servicepath', '/testingPath')
|
|
909
|
-
.
|
|
910
|
-
'/v2/entities
|
|
909
|
+
.post(
|
|
910
|
+
'/v2/entities?options=upsert',
|
|
911
911
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContext3WithStatic.json')
|
|
912
912
|
)
|
|
913
|
-
.query({ type: 'SensorMachine' })
|
|
914
913
|
.reply(204, {});
|
|
915
914
|
async.series([async.apply(request, optionsCreation)], done);
|
|
916
915
|
});
|
|
@@ -100,15 +100,6 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
100
100
|
)
|
|
101
101
|
)
|
|
102
102
|
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
|
|
103
|
-
|
|
104
|
-
contextBrokerMock
|
|
105
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
106
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
107
|
-
.post(
|
|
108
|
-
'/v2/entities?options=upsert',
|
|
109
|
-
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createProvisionedDevice.json')
|
|
110
|
-
)
|
|
111
|
-
.reply(204);
|
|
112
103
|
});
|
|
113
104
|
|
|
114
105
|
const options = {
|
|
@@ -214,7 +205,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
214
205
|
});
|
|
215
206
|
});
|
|
216
207
|
|
|
217
|
-
it('should create the initial entity in the Context Broker', function (done) {
|
|
208
|
+
it('should not create the initial entity in the Context Broker', function (done) {
|
|
218
209
|
request(options, function (error, response, body) {
|
|
219
210
|
response.statusCode.should.equal(201);
|
|
220
211
|
iotAgentLib.listDevices('smartgondor', '/gardens', function (error, results) {
|
|
@@ -248,15 +239,6 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
248
239
|
|
|
249
240
|
beforeEach(function (done) {
|
|
250
241
|
nock.cleanAll();
|
|
251
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
252
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
253
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
254
|
-
.post(
|
|
255
|
-
'/v2/entities?options=upsert',
|
|
256
|
-
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createTimeinstantDevice.json')
|
|
257
|
-
)
|
|
258
|
-
.reply(204);
|
|
259
|
-
|
|
260
242
|
done();
|
|
261
243
|
});
|
|
262
244
|
|
|
@@ -292,15 +274,6 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
292
274
|
|
|
293
275
|
beforeEach(function (done) {
|
|
294
276
|
nock.cleanAll();
|
|
295
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
296
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
297
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
298
|
-
.post(
|
|
299
|
-
'/v2/entities?options=upsert',
|
|
300
|
-
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createTimeinstantDevice.json')
|
|
301
|
-
)
|
|
302
|
-
.reply(204);
|
|
303
|
-
|
|
304
277
|
done();
|
|
305
278
|
});
|
|
306
279
|
|
|
@@ -336,18 +309,8 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
336
309
|
|
|
337
310
|
beforeEach(function (done) {
|
|
338
311
|
nock.cleanAll();
|
|
339
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
340
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
341
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
342
|
-
.post(
|
|
343
|
-
'/v2/entities?options=upsert',
|
|
344
|
-
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createExplicitAttrsDevice.json')
|
|
345
|
-
)
|
|
346
|
-
.reply(204);
|
|
347
|
-
|
|
348
312
|
done();
|
|
349
313
|
});
|
|
350
|
-
|
|
351
314
|
it('should send the appropriate requests to the Context Broker', function (done) {
|
|
352
315
|
request(options, function (error, response, body) {
|
|
353
316
|
contextBrokerMock.done();
|
|
@@ -394,17 +357,6 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
394
357
|
|
|
395
358
|
beforeEach(function (done) {
|
|
396
359
|
nock.cleanAll();
|
|
397
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
398
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
399
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
400
|
-
.post(
|
|
401
|
-
'/v2/entities?options=upsert',
|
|
402
|
-
utils.readExampleFile(
|
|
403
|
-
'./test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json'
|
|
404
|
-
)
|
|
405
|
-
)
|
|
406
|
-
.reply(204);
|
|
407
|
-
|
|
408
360
|
done();
|
|
409
361
|
});
|
|
410
362
|
|
|
@@ -552,12 +504,12 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
552
504
|
done();
|
|
553
505
|
});
|
|
554
506
|
|
|
555
|
-
it('should store the device with static attributes provided in configuration', function (done) {
|
|
507
|
+
it('should not store the device with static attributes provided in configuration', function (done) {
|
|
556
508
|
request(groupCreation, function (error, response, body) {
|
|
557
509
|
request(options, function (error, response, body) {
|
|
558
510
|
iotAgentLib.listDevices('smartgondor', '/gardens', function (error, results) {
|
|
559
511
|
should.exist(results.devices[0].staticAttributes);
|
|
560
|
-
results.devices[0].staticAttributes
|
|
512
|
+
results.devices[0].staticAttributes.length.should.equal(0);
|
|
561
513
|
done();
|
|
562
514
|
});
|
|
563
515
|
});
|
|
@@ -692,12 +644,12 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
692
644
|
done();
|
|
693
645
|
});
|
|
694
646
|
|
|
695
|
-
it('should store the device with static attributes provided in
|
|
647
|
+
it('should store the device with static attributes provided in device but no in configuration', function (done) {
|
|
696
648
|
request(groupCreation, function (error, response, body) {
|
|
697
649
|
request(options, function (error, response, body) {
|
|
698
650
|
iotAgentLib.listDevices('smartgondor', '/gardens', function (error, results) {
|
|
699
651
|
should.exist(results.devices[0].staticAttributes);
|
|
700
|
-
results.devices[0].staticAttributes.length.should.equal(
|
|
652
|
+
results.devices[0].staticAttributes.length.should.equal(1);
|
|
701
653
|
done();
|
|
702
654
|
});
|
|
703
655
|
});
|
|
@@ -727,7 +679,6 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
727
679
|
/*jshint camelcase: false */
|
|
728
680
|
entity_type: 'MicroLights',
|
|
729
681
|
entityNameExp: "id + '__' + suffix_st",
|
|
730
|
-
expressionLanguage: 'jexl',
|
|
731
682
|
cbHost: 'http://192.168.1.1:1026',
|
|
732
683
|
static_attributes: [
|
|
733
684
|
{
|
|
@@ -861,31 +812,19 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
861
812
|
|
|
862
813
|
beforeEach(function (done) {
|
|
863
814
|
iotAgentLib.deactivate(function () {
|
|
864
|
-
iotAgentConfig.appendMode = false;
|
|
865
815
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
866
816
|
});
|
|
867
817
|
});
|
|
868
818
|
|
|
869
|
-
afterEach(function () {
|
|
870
|
-
iotAgentConfig.appendMode = false;
|
|
871
|
-
});
|
|
819
|
+
afterEach(function () {});
|
|
872
820
|
|
|
873
821
|
beforeEach(function (done) {
|
|
874
822
|
nock.cleanAll();
|
|
875
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
876
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
877
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
878
|
-
.post(
|
|
879
|
-
'/v2/entities?options=upsert',
|
|
880
|
-
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/createAutoprovisionDevice.json')
|
|
881
|
-
)
|
|
882
|
-
.reply(204);
|
|
883
823
|
done();
|
|
884
824
|
});
|
|
885
825
|
|
|
886
|
-
it('should
|
|
826
|
+
it('should should not appropriate requests to the Context Broker', function (done) {
|
|
887
827
|
request(options, function (error, response, body) {
|
|
888
|
-
contextBrokerMock.done();
|
|
889
828
|
done();
|
|
890
829
|
});
|
|
891
830
|
});
|
|
@@ -915,36 +854,11 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
915
854
|
|
|
916
855
|
beforeEach(function (done) {
|
|
917
856
|
nock.cleanAll();
|
|
918
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
919
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
920
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
921
|
-
.post('/v2/entities?options=upsert', function (body) {
|
|
922
|
-
const expectedBody = utils.readExampleFile(
|
|
923
|
-
'./test/unit/ngsiv2/examples/contextRequests/createTimeInstantMinimumDevice.json'
|
|
924
|
-
);
|
|
925
|
-
if (!body.TimeInstant.value) {
|
|
926
|
-
return false;
|
|
927
|
-
} else if (moment(body.TimeInstant.value, 'YYYY-MM-DDTHH:mm:ss.SSSZ').isValid()) {
|
|
928
|
-
const timeInstantDiff = moment().diff(body.TimeInstant.value, 'milliseconds');
|
|
929
|
-
if (timeInstantDiff < 500) {
|
|
930
|
-
delete body.TimeInstant;
|
|
931
|
-
|
|
932
|
-
return JSON.stringify(body) === JSON.stringify(expectedBody);
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
return false;
|
|
936
|
-
} else {
|
|
937
|
-
return false;
|
|
938
|
-
}
|
|
939
|
-
})
|
|
940
|
-
.reply(204);
|
|
941
|
-
|
|
942
857
|
done();
|
|
943
858
|
});
|
|
944
859
|
|
|
945
|
-
it('should send
|
|
860
|
+
it('should not send any requests to the Context Broker', function (done) {
|
|
946
861
|
request(options, function (error, response, body) {
|
|
947
|
-
contextBrokerMock.done();
|
|
948
862
|
done();
|
|
949
863
|
});
|
|
950
864
|
});
|
|
@@ -963,23 +877,11 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
963
877
|
|
|
964
878
|
beforeEach(function (done) {
|
|
965
879
|
nock.cleanAll();
|
|
966
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
967
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
968
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
969
|
-
.post(
|
|
970
|
-
'/v2/entities?options=upsert',
|
|
971
|
-
utils.readExampleFile(
|
|
972
|
-
'./test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json'
|
|
973
|
-
)
|
|
974
|
-
)
|
|
975
|
-
.reply(204);
|
|
976
|
-
|
|
977
880
|
done();
|
|
978
881
|
});
|
|
979
882
|
|
|
980
|
-
it('should send
|
|
883
|
+
it('should not send any requests to the Context Broker', function (done) {
|
|
981
884
|
request(options, function (error, response, body) {
|
|
982
|
-
contextBrokerMock.done();
|
|
983
885
|
done();
|
|
984
886
|
});
|
|
985
887
|
});
|
|
@@ -1022,23 +924,10 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
1022
924
|
|
|
1023
925
|
beforeEach(function (done) {
|
|
1024
926
|
nock.cleanAll();
|
|
1025
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1026
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
1027
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
1028
|
-
.post(
|
|
1029
|
-
'/v2/entities?options=upsert',
|
|
1030
|
-
utils.readExampleFile(
|
|
1031
|
-
'./test/unit/ngsiv2/examples/contextRequests/createGeopointProvisionedDevice.json'
|
|
1032
|
-
)
|
|
1033
|
-
)
|
|
1034
|
-
.reply(204);
|
|
1035
|
-
|
|
1036
927
|
done();
|
|
1037
928
|
});
|
|
1038
|
-
|
|
1039
|
-
it('should send the appropriate initial values to the Context Broker', function (done) {
|
|
929
|
+
it('should not send any initial values to the Context Broker', function (done) {
|
|
1040
930
|
request(options, function (error, response, body) {
|
|
1041
|
-
contextBrokerMock.done();
|
|
1042
931
|
done();
|
|
1043
932
|
});
|
|
1044
933
|
});
|
|
@@ -1057,23 +946,10 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
1057
946
|
|
|
1058
947
|
beforeEach(function (done) {
|
|
1059
948
|
nock.cleanAll();
|
|
1060
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
1061
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
1062
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
1063
|
-
.post(
|
|
1064
|
-
'/v2/entities?options=upsert',
|
|
1065
|
-
utils.readExampleFile(
|
|
1066
|
-
'./test/unit/ngsiv2/examples/contextRequests/createDatetimeProvisionedDevice.json'
|
|
1067
|
-
)
|
|
1068
|
-
)
|
|
1069
|
-
.reply(204);
|
|
1070
|
-
|
|
1071
949
|
done();
|
|
1072
950
|
});
|
|
1073
|
-
|
|
1074
|
-
it('should send the appropriate initial values to the Context Broker', function (done) {
|
|
951
|
+
it('should not send any initial values to the Context Broker', function (done) {
|
|
1075
952
|
request(options, function (error, response, body) {
|
|
1076
|
-
contextBrokerMock.done();
|
|
1077
953
|
done();
|
|
1078
954
|
});
|
|
1079
955
|
});
|
|
@@ -1170,23 +1046,13 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
1170
1046
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
1171
1047
|
.post('/v2/registrations')
|
|
1172
1048
|
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
|
|
1173
|
-
|
|
1174
|
-
// This mock does not check the payload since the aim of the test is not to verify
|
|
1175
|
-
// device provisioning functionality. Appropriate verification is done in tests under
|
|
1176
|
-
// provisioning folder
|
|
1177
|
-
contextBrokerMock
|
|
1178
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
1179
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
1180
|
-
.post('/v2/entities?options=upsert')
|
|
1181
|
-
.replyWithError({ message: 'Description of the error', code: 'STRING_CODE' });
|
|
1182
|
-
|
|
1183
1049
|
done();
|
|
1184
1050
|
});
|
|
1185
1051
|
|
|
1186
1052
|
it('should return a valid return code', function (done) {
|
|
1187
1053
|
request(options, function (error, response, body) {
|
|
1188
1054
|
should.not.exist(error);
|
|
1189
|
-
response.statusCode.should.equal(
|
|
1055
|
+
response.statusCode.should.equal(201);
|
|
1190
1056
|
|
|
1191
1057
|
done();
|
|
1192
1058
|
});
|
|
@@ -1213,22 +1079,13 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
1213
1079
|
.post('/v2/registrations')
|
|
1214
1080
|
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
|
|
1215
1081
|
|
|
1216
|
-
// This mock does not check the payload since the aim of the test is not to verify
|
|
1217
|
-
// device provisioning functionality. Appropriate verification is done in tests under
|
|
1218
|
-
// provisioning folder
|
|
1219
|
-
contextBrokerMock
|
|
1220
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
1221
|
-
.matchHeader('fiware-servicepath', '/gardens')
|
|
1222
|
-
.post('/v2/entities?options=upsert')
|
|
1223
|
-
.replyWithError({ message: 'Description of the error', code: 123456789 });
|
|
1224
|
-
|
|
1225
1082
|
done();
|
|
1226
1083
|
});
|
|
1227
1084
|
|
|
1228
1085
|
it('should return a valid return code (three character number)', function (done) {
|
|
1229
1086
|
request(options, function (error, response, body) {
|
|
1230
1087
|
should.not.exist(error);
|
|
1231
|
-
response.statusCode.should.equal(
|
|
1088
|
+
response.statusCode.should.equal(201);
|
|
1232
1089
|
|
|
1233
1090
|
done();
|
|
1234
1091
|
});
|
|
@@ -82,13 +82,15 @@ const device1 = {
|
|
|
82
82
|
id: 'light1',
|
|
83
83
|
type: 'Light',
|
|
84
84
|
service: 'smartgondor',
|
|
85
|
-
subservice: 'gardens'
|
|
85
|
+
subservice: 'gardens',
|
|
86
|
+
apikey: null
|
|
86
87
|
};
|
|
87
88
|
const device2 = {
|
|
88
89
|
id: 'term2',
|
|
89
90
|
type: 'Termometer',
|
|
90
91
|
service: 'smartgondor',
|
|
91
|
-
subservice: 'gardens'
|
|
92
|
+
subservice: 'gardens',
|
|
93
|
+
apikey: null
|
|
92
94
|
};
|
|
93
95
|
|
|
94
96
|
describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
@@ -112,11 +114,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
112
114
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
113
115
|
// device provisioning functionality. Appropriate verification is done in tests under
|
|
114
116
|
// provisioning folder
|
|
115
|
-
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
116
|
-
.matchHeader('fiware-service', 'smartgondor')
|
|
117
|
-
.matchHeader('fiware-servicepath', 'gardens')
|
|
118
|
-
.post('/v2/entities?options=upsert')
|
|
119
|
-
.reply(204);
|
|
117
|
+
contextBrokerMock = nock('http://192.168.1.1:1026');
|
|
120
118
|
|
|
121
119
|
const nockBody = utils.readExampleFile(
|
|
122
120
|
'./test/unit/ngsiv2/examples/contextAvailabilityRequests/registerIoTAgent1.json'
|
|
@@ -227,7 +225,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
227
225
|
|
|
228
226
|
it("should return all the device's information", function (done) {
|
|
229
227
|
iotAgentLib.register(device1, function (error) {
|
|
230
|
-
iotAgentLib.getDevice('light1', 'smartgondor', 'gardens', function (error, data) {
|
|
228
|
+
iotAgentLib.getDevice('light1', null, 'smartgondor', 'gardens', function (error, data) {
|
|
231
229
|
should.not.exist(error);
|
|
232
230
|
should.exist(data);
|
|
233
231
|
data.type.should.equal('Light');
|
|
@@ -258,7 +256,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
258
256
|
|
|
259
257
|
it('should return a ENTITY_NOT_FOUND error', function (done) {
|
|
260
258
|
iotAgentLib.register(device1, function (error) {
|
|
261
|
-
iotAgentLib.getDevice('lightUnexistent', 'smartgondor', 'gardens', function (error, data) {
|
|
259
|
+
iotAgentLib.getDevice('lightUnexistent', null, 'smartgondor', 'gardens', function (error, data) {
|
|
262
260
|
should.exist(error);
|
|
263
261
|
should.not.exist(data);
|
|
264
262
|
error.code.should.equal(404);
|
|
@@ -279,7 +277,6 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
279
277
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
280
278
|
// device provisioning functionality. Appropriate verification is done in tests under
|
|
281
279
|
// provisioning folder
|
|
282
|
-
contextBrokerMock.post('/v2/entities?options=upsert').reply(204);
|
|
283
280
|
|
|
284
281
|
contextBrokerMock
|
|
285
282
|
.post('/v2/registrations')
|
|
@@ -288,7 +285,6 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
288
285
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
289
286
|
// device provisioning functionality. Appropriate verification is done in tests under
|
|
290
287
|
// provisioning folder
|
|
291
|
-
contextBrokerMock.post('/v2/entities?options=upsert').reply(204);
|
|
292
288
|
|
|
293
289
|
contextBrokerMock
|
|
294
290
|
.delete('/v2/registrations/6319a7f5254b05844116584d', '')
|
|
@@ -307,7 +303,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
307
303
|
});
|
|
308
304
|
|
|
309
305
|
it('should update the devices information in Context Broker', function (done) {
|
|
310
|
-
iotAgentLib.unregister(device1.id, 'smartgondor', 'gardens', function (error) {
|
|
306
|
+
iotAgentLib.unregister(device1.id, null, 'smartgondor', 'gardens', function (error) {
|
|
311
307
|
should.not.exist(error);
|
|
312
308
|
contextBrokerMock.done();
|
|
313
309
|
done();
|
|
@@ -352,7 +348,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
352
348
|
|
|
353
349
|
it('should not remove the device from the internal registry');
|
|
354
350
|
it('should return a UNREGISTRATION_ERROR error to the caller', function (done) {
|
|
355
|
-
iotAgentLib.unregister(device1.id, 'smartgondor', 'gardens', function (error) {
|
|
351
|
+
iotAgentLib.unregister(device1.id, null, 'smartgondor', 'gardens', function (error) {
|
|
356
352
|
should.exist(error);
|
|
357
353
|
should.exist(error.name);
|
|
358
354
|
error.name.should.equal('UNREGISTRATION_ERROR');
|