iotagent-node-lib 3.4.4 → 4.0.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.
Files changed (93) hide show
  1. package/README.md +4 -0
  2. package/doc/admin.md +1 -13
  3. package/doc/api.md +116 -18
  4. package/doc/devel/architecture.md +0 -12
  5. package/doc/index.md +1 -1
  6. package/doc/roadmap.md +22 -10
  7. package/lib/commonConfig.js +0 -11
  8. package/lib/model/Device.js +2 -1
  9. package/lib/model/Group.js +2 -1
  10. package/lib/model/dbConn.js +22 -11
  11. package/lib/plugins/expressionPlugin.js +0 -5
  12. package/lib/plugins/jexlParser.js +15 -31
  13. package/lib/services/common/genericMiddleware.js +14 -2
  14. package/lib/services/common/iotManagerService.js +2 -1
  15. package/lib/services/devices/deviceRegistryMongoDB.js +3 -1
  16. package/lib/services/devices/deviceService.js +16 -21
  17. package/lib/services/devices/devices-NGSI-LD.js +5 -98
  18. package/lib/services/devices/devices-NGSI-mixed.js +0 -14
  19. package/lib/services/devices/devices-NGSI-v2.js +3 -0
  20. package/lib/services/groups/groupRegistryMemory.js +0 -25
  21. package/lib/services/groups/groupRegistryMongoDB.js +20 -19
  22. package/lib/services/groups/groupService.js +3 -14
  23. package/lib/services/ngsi/entities-NGSI-LD.js +81 -6
  24. package/lib/services/ngsi/entities-NGSI-v2.js +303 -698
  25. package/lib/services/ngsi/ngsiUtils.js +0 -30
  26. package/lib/services/northBound/deviceProvisioningServer.js +6 -3
  27. package/lib/templates/createDevice.json +4 -0
  28. package/lib/templates/createDeviceLax.json +4 -0
  29. package/lib/templates/deviceGroup.json +4 -0
  30. package/lib/templates/updateDevice.json +4 -0
  31. package/lib/templates/updateDeviceLax.json +4 -0
  32. package/package.json +6 -2
  33. package/test/functional/README.md +378 -0
  34. package/test/functional/config-test.js +70 -0
  35. package/test/functional/functional-tests-runner.js +126 -0
  36. package/test/functional/functional-tests.js +241 -0
  37. package/test/functional/testCases.js +2944 -0
  38. package/test/functional/testUtils.js +251 -0
  39. package/test/tools/utils.js +25 -0
  40. package/test/unit/mongodb/mongodb-connectionoptions-test.js +35 -22
  41. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +3 -34
  42. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +8 -1
  43. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
  44. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +1 -6
  45. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +67 -87
  46. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +7 -13
  47. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +43 -43
  48. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +19 -29
  49. package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -1
  50. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +35 -46
  51. package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +8 -9
  52. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +96 -221
  53. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +18 -27
  54. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +8 -16
  55. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +0 -13
  56. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +4 -4
  57. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29b.json +8 -0
  58. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +1 -1
  59. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +0 -6
  60. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +8 -0
  61. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json +14 -0
  62. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +1 -11
  63. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36b.json +13 -0
  64. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin37.json +8 -0
  65. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -11
  66. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json +37 -0
  67. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +0 -4
  68. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +0 -4
  69. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +0 -4
  70. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +4 -0
  71. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +0 -3
  72. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +10 -12
  73. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -4
  74. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -5
  75. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -12
  76. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +0 -4
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +0 -8
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +7 -1
  79. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +898 -28
  80. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +0 -4
  81. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +267 -0
  82. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +19 -21
  83. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +21 -24
  84. package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -21
  85. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +4 -6
  86. package/test/unit/ngsi-ld/ngsiService/autocast-test.js +0 -438
  87. package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +0 -381
  88. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +0 -311
  89. package/test/unit/ngsiv2/ngsiService/autocast-test.js +0 -325
  90. package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +0 -427
  91. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +0 -217
  92. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +0 -119
  93. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -309
@@ -96,14 +96,6 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
96
96
  )
97
97
  )
98
98
  .reply(201, null, { Location: '/ngsi-ld/v1/csourceRegistrations/6319a7f5254b05844116584d' });
99
-
100
- contextBrokerMock
101
- .matchHeader('fiware-service', 'smartgondor')
102
- .post(
103
- '/ngsi-ld/v1/entityOperations/upsert/',
104
- utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/createProvisionedDevice.json')
105
- )
106
- .reply(204);
107
99
  });
108
100
 
109
101
  const options = {
@@ -208,16 +200,16 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
208
200
  });
209
201
  });
210
202
  });
211
- // FIXME: disabled test by #1421
212
- // it('should create the initial entity in the Context Broker', function (done) {
213
- // request(options, function (error, response, body) {
214
- // response.statusCode.should.equal(201);
215
- // iotAgentLib.listDevices('smartgondor', '/gardens', function (error, results) {
216
- // contextBrokerMock.done();
217
- // done();
218
- // });
219
- // });
220
- // });
203
+
204
+ it('should not send requests to the Context Broker', function (done) {
205
+ request(options, function (error, response, body) {
206
+ response.statusCode.should.equal(201);
207
+ iotAgentLib.listDevices('smartgondor', '/gardens', function (error, results) {
208
+ contextBrokerMock.done();
209
+ done();
210
+ });
211
+ });
212
+ });
221
213
  });
222
214
  describe('When a device provisioning request with a TimeInstant attribute arrives to the IoTA', function () {
223
215
  const options = {
@@ -243,23 +235,15 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
243
235
 
244
236
  beforeEach(function (done) {
245
237
  nock.cleanAll();
246
- contextBrokerMock = nock('http://192.168.1.1:1026')
247
- .matchHeader('fiware-service', 'smartgondor')
248
- .post(
249
- '/ngsi-ld/v1/entityOperations/upsert/',
250
- utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/createTimeinstantDevice.json')
251
- )
252
- .reply(204);
253
-
254
238
  done();
255
239
  });
256
- // FIXME: disabled test by #1421
257
- // it('should send the appropriate requests to the Context Broker', function (done) {
258
- // request(options, function (error, response, body) {
259
- // contextBrokerMock.done();
260
- // done();
261
- // });
262
- // });
240
+
241
+ it('should not send requests to the Context Broker', function (done) {
242
+ request(options, function (error, response, body) {
243
+ contextBrokerMock.done();
244
+ done();
245
+ });
246
+ });
263
247
  });
264
248
 
265
249
  describe('When a device provisioning request with a timestamp provision attribute arrives to the IoTA', function () {
@@ -286,66 +270,49 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
286
270
 
287
271
  beforeEach(function (done) {
288
272
  nock.cleanAll();
289
- contextBrokerMock = nock('http://192.168.1.1:1026')
290
- .matchHeader('fiware-service', 'smartgondor')
291
- .post(
292
- '/ngsi-ld/v1/entityOperations/upsert/',
293
- utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/createTimeinstantDevice.json')
294
- )
295
- .reply(204);
296
-
297
273
  done();
298
274
  });
299
- // FIXME: disabled test by #1421
300
- // it('should send the appropriate requests to the Context Broker', function (done) {
301
- // request(options, function (error, response, body) {
302
- // contextBrokerMock.done();
303
- // done();
304
- // });
305
- // });
275
+
276
+ it('should not send requests to the Context Broker', function (done) {
277
+ request(options, function (error, response, body) {
278
+ done();
279
+ });
280
+ });
306
281
  });
307
282
 
308
- // describe('When a device provisioning request with a autoprovision attribute arrives to the IoTA', function () {
309
- // const options = {
310
- // url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices',
311
- // method: 'POST',
312
- // json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionAutoprovision.json'),
313
- // headers: {
314
- // 'fiware-service': 'smartgondor',
315
- // 'fiware-servicepath': '/gardens'
316
- // }
317
- // };
318
-
319
- // beforeEach(function (done) {
320
- // iotAgentLib.deactivate(function () {
321
- // iotAgentConfig.appendMode = false;
322
- // iotAgentLib.activate(iotAgentConfig, done);
323
- // });
324
- // });
325
-
326
- // afterEach(function () {
327
- // iotAgentConfig.appendMode = false;
328
- // });
329
-
330
- // beforeEach(function (done) {
331
- // nock.cleanAll();
332
- // contextBrokerMock = nock('http://192.168.1.1:1026')
333
- // .matchHeader('fiware-service', 'smartgondor')
334
- // .post(
335
- // '/ngsi-ld/v1/entityOperations/upsert/',
336
- // utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/createAutoprovisionDevice.json')
337
- // )
338
- // .reply(204);
339
- // done();
340
- // });
341
-
342
- // it('should send the appropriate requests to the Context Broker', function (done) {
343
- // request(options, function (error, response, body) {
344
- // contextBrokerMock.done();
345
- // done();
346
- // });
347
- // });
348
- // });
283
+ describe('When a device provisioning request with a autoprovision attribute arrives to the IoTA', function () {
284
+ const options = {
285
+ url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices',
286
+ method: 'POST',
287
+ json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionAutoprovision.json'),
288
+ headers: {
289
+ 'fiware-service': 'smartgondor',
290
+ 'fiware-servicepath': '/gardens'
291
+ }
292
+ };
293
+
294
+ beforeEach(function (done) {
295
+ iotAgentLib.deactivate(function () {
296
+ iotAgentConfig.appendMode = false;
297
+ iotAgentLib.activate(iotAgentConfig, done);
298
+ });
299
+ });
300
+
301
+ afterEach(function () {
302
+ iotAgentConfig.appendMode = false;
303
+ });
304
+
305
+ beforeEach(function (done) {
306
+ nock.cleanAll();
307
+ done();
308
+ });
309
+
310
+ it('should not send requests to the Context Broker', function (done) {
311
+ request(options, function (error, response, body) {
312
+ done();
313
+ });
314
+ });
315
+ });
349
316
 
350
317
  describe('When a device provisioning request arrives to the IoTAand timestamp is enabled in configuration', function () {
351
318
  const options = {
@@ -371,25 +338,15 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
371
338
 
372
339
  beforeEach(function (done) {
373
340
  nock.cleanAll();
374
- contextBrokerMock = nock('http://192.168.1.1:1026')
375
- .matchHeader('fiware-service', 'smartgondor')
376
- .post(
377
- '/ngsi-ld/v1/entityOperations/upsert/',
378
- utils.readExampleFile(
379
- './test/unit/ngsi-ld/examples/contextRequests/createTimeInstantMinimumDevice.json'
380
- )
381
- )
382
- .reply(204);
383
341
 
384
342
  done();
385
343
  });
386
- // FIXME: disabled test by #1421
387
- // it('should send the appropriate requests to the Context Broker', function (done) {
388
- // request(options, function (error, response, body) {
389
- // contextBrokerMock.done();
390
- // done();
391
- // });
392
- // });
344
+
345
+ it('should not send requests to the Context Broker', function (done) {
346
+ request(options, function (error, response, body) {
347
+ done();
348
+ });
349
+ });
393
350
  });
394
351
 
395
352
  describe('When a device provisioning request with the minimum required data arrives to the IoT Agent', function () {
@@ -405,25 +362,14 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
405
362
 
406
363
  beforeEach(function (done) {
407
364
  nock.cleanAll();
408
- contextBrokerMock = nock('http://192.168.1.1:1026')
409
- .matchHeader('fiware-service', 'smartgondor')
410
- .post(
411
- '/ngsi-ld/v1/entityOperations/upsert/',
412
- utils.readExampleFile(
413
- './test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json'
414
- )
415
- )
416
- .reply(204);
417
-
418
365
  done();
419
366
  });
420
- // FIXME: disabled test by #1421
421
- // it('should send the appropriate requests to the Context Broker', function (done) {
422
- // request(options, function (error, response, body) {
423
- // contextBrokerMock.done();
424
- // done();
425
- // });
426
- // });
367
+
368
+ it('should not send requests to the Context Broker', function (done) {
369
+ request(options, function (error, response, body) {
370
+ done();
371
+ });
372
+ });
427
373
 
428
374
  it('should add the device to the devices list', function (done) {
429
375
  request(options, function (error, response, body) {
@@ -463,25 +409,14 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
463
409
 
464
410
  beforeEach(function (done) {
465
411
  nock.cleanAll();
466
- contextBrokerMock = nock('http://192.168.1.1:1026')
467
- .matchHeader('fiware-service', 'smartgondor')
468
- .post(
469
- '/ngsi-ld/v1/entityOperations/upsert/',
470
- utils.readExampleFile(
471
- './test/unit/ngsi-ld/examples/contextRequests/createGeopointProvisionedDevice.json'
472
- )
473
- )
474
- .reply(204);
475
-
476
412
  done();
477
413
  });
478
- // FIXME: disabled test by #1421
479
- // it('should send the appropriate initial values to the Context Broker', function (done) {
480
- // request(options, function (error, response, body) {
481
- // contextBrokerMock.done();
482
- // done();
483
- // });
484
- // });
414
+
415
+ it('should not send any initial values to the Context Broker', function (done) {
416
+ request(options, function (error, response, body) {
417
+ done();
418
+ });
419
+ });
485
420
  });
486
421
 
487
422
  describe('When a device provisioning request with DateTime attributes arrives', function () {
@@ -497,25 +432,14 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
497
432
 
498
433
  beforeEach(function (done) {
499
434
  nock.cleanAll();
500
- contextBrokerMock = nock('http://192.168.1.1:1026')
501
- .matchHeader('fiware-service', 'smartgondor')
502
- .post(
503
- '/ngsi-ld/v1/entityOperations/upsert/',
504
- utils.readExampleFile(
505
- './test/unit/ngsi-ld/examples/contextRequests/createDatetimeProvisionedDevice.json'
506
- )
507
- )
508
- .reply(204);
509
-
510
435
  done();
511
436
  });
512
- // FIXME: disabled test by #1421
513
- // it('should send the appropriate initial values to the Context Broker', function (done) {
514
- // request(options, function (error, response, body) {
515
- // contextBrokerMock.done();
516
- // done();
517
- // });
518
- // });
437
+
438
+ it('should not send any initial values to the Context Broker', function (done) {
439
+ request(options, function (error, response, body) {
440
+ done();
441
+ });
442
+ });
519
443
  });
520
444
 
521
445
  describe('When two devices with the same ID but different services arrive to the agent', function () {
@@ -590,46 +514,6 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
590
514
  });
591
515
  });
592
516
 
593
- describe('When the Context Broker returns an unrecognized status code provisioning an entity', function () {
594
- const options = {
595
- url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices',
596
- method: 'POST',
597
- json: utils.readExampleFile('./test/unit/examples/deviceProvisioningRequests/provisionMinimumDevice.json'),
598
- headers: {
599
- 'fiware-service': 'smartgondor',
600
- 'fiware-servicepath': '/gardens'
601
- }
602
- };
603
-
604
- beforeEach(function (done) {
605
- nock.cleanAll();
606
- contextBrokerMock = nock('http://192.168.1.1:1026')
607
- .matchHeader('fiware-service', 'smartgondor')
608
- .post(
609
- '/ngsi-ld/v1/entityOperations/upsert/',
610
- utils.readExampleFile(
611
- './test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json'
612
- )
613
- )
614
- .reply(207);
615
-
616
- done();
617
- });
618
- // FIXME: disabled test by #1421
619
- // it('should return an error message in the response body', function (done) {
620
- // request(options, function (error, response, body) {
621
- // should.not.exist(error);
622
- // response.body.name.should.equal('ENTITY_GENERIC_ERROR');
623
- // response.body.message.should.equal(
624
- // 'Error accesing entity data for device: MicroLight1 of type: MicroLights'
625
- // );
626
- // response.statusCode.should.equal(200);
627
-
628
- // done();
629
- // });
630
- // });
631
- });
632
-
633
517
  describe('When the Context Broker returns a 200 status code (NGSI-LD v1.2.1) provisioning an entity', function () {
634
518
  const options = {
635
519
  url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices',
@@ -733,15 +617,15 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
733
617
 
734
618
  done();
735
619
  });
736
- // FIXME: disabled test by #1421
737
- // it('should return a valid return code', function (done) {
738
- // request(options, function (error, response, body) {
739
- // should.not.exist(error);
740
- // response.statusCode.should.equal(500);
741
620
 
742
- // done();
743
- // });
744
- // });
621
+ it('should return a valid return code', function (done) {
622
+ request(options, function (error, response, body) {
623
+ should.not.exist(error);
624
+ response.statusCode.should.equal(201);
625
+
626
+ done();
627
+ });
628
+ });
745
629
  });
746
630
 
747
631
  describe('When there is a connection error with a Number code connecting the CB', function () {
@@ -761,27 +645,18 @@ describe('NGSI-LD - Device provisioning API: Provision devices', function () {
761
645
  contextBrokerMock = nock('http://192.168.1.1:1026')
762
646
  .matchHeader('fiware-service', 'smartgondor')
763
647
  .post('/ngsi-ld/v1/csourceRegistrations/')
764
- .reply(201, null, { Location: '/ngsi-ld/v1/csourceRegistrations/6319a7f5254b05844116584d' });
765
-
766
- // This mock does not check the payload since the aim of the test is not to verify
767
- // device provisioning functionality. Appropriate verification is done in tests under
768
- // provisioning folder
769
- contextBrokerMock
770
- .matchHeader('fiware-service', 'smartgondor')
771
- .post('/ngsi-ld/v1/entityOperations/upsert/')
772
- .replyWithError({ message: 'Description of the error', code: 123456789 });
648
+ .reply(400, null, { Location: '/ngsi-ld/v1/csourceRegistrations/6319a7f5254b05844116584d' });
773
649
 
774
650
  done();
775
651
  });
776
- // FIXME: disabled test by #1421
777
- // it('should return a valid return code (three character number)', function (done) {
778
- // request(options, function (error, response, body) {
779
- // should.not.exist(error);
780
- // response.statusCode.should.equal(500);
781
652
 
782
- // done();
783
- // });
784
- // });
653
+ it('should return a valid return code (three character number)', function (done) {
654
+ request(options, function (error, response, body) {
655
+ should.not.exist(error);
656
+ response.statusCode.should.equal(201);
657
+ done();
658
+ });
659
+ });
785
660
  });
786
661
 
787
662
  describe('When a device provisioning request with missing data arrives to the IoT Agent', function () {
@@ -109,19 +109,10 @@ describe('NGSI-LD - IoT Agent Device Registration', function () {
109
109
  describe('When a new device is connected to the IoT Agent', function () {
110
110
  beforeEach(function (done) {
111
111
  nock.cleanAll();
112
-
113
- // This mock does not check the payload since the aim of the test is not to verify
114
- // device provisioning functionality. Appropriate verification is done in tests under
115
- // provisioning folder
116
- contextBrokerMock = nock('http://192.168.1.1:1026')
117
- .matchHeader('fiware-service', 'smartgondor')
118
- .post('/ngsi-ld/v1/entityOperations/upsert/')
119
- .reply(204);
120
-
121
112
  const nockBody = utils.readExampleFile(
122
113
  './test/unit/ngsi-ld/examples/contextAvailabilityRequests/registerIoTAgent1.json'
123
114
  );
124
- contextBrokerMock
115
+ contextBrokerMock = nock('http://192.168.1.1:1026')
125
116
  .matchHeader('fiware-service', 'smartgondor')
126
117
  .post('/ngsi-ld/v1/csourceRegistrations/', nockBody)
127
118
  .reply(201, null, { Location: '/ngsi-ld/v1/csourceRegistrations/6319a7f5254b05844116584d' });
@@ -130,14 +121,14 @@ describe('NGSI-LD - IoT Agent Device Registration', function () {
130
121
  iotAgentLib.clearAll(done);
131
122
  });
132
123
  });
133
- // FIXME: disabled test by #1421
134
- // it('should register as ContextProvider of its lazy attributes', function (done) {
135
- // iotAgentLib.register(device1, function (error) {
136
- // should.not.exist(error);
137
- // contextBrokerMock.done();
138
- // done();
139
- // });
140
- // });
124
+
125
+ it('should register as ContextProvider of its lazy attributes', function (done) {
126
+ iotAgentLib.register(device1, function (error) {
127
+ should.not.exist(error);
128
+ contextBrokerMock.done();
129
+ done();
130
+ });
131
+ });
141
132
  });
142
133
 
143
134
  describe('When the Context Broker returns a NGSI error while registering a device', function () {
@@ -156,15 +147,15 @@ describe('NGSI-LD - IoT Agent Device Registration', function () {
156
147
  iotAgentLib.clearAll(done);
157
148
  });
158
149
  });
159
- // FIXME: disabled test by #1421
160
- // it('should register as ContextProvider of its lazy attributes', function (done) {
161
- // iotAgentLib.register(device1, function (error) {
162
- // should.exist(error);
163
- // error.name.should.equal('BAD_REQUEST');
164
- // contextBrokerMock.done();
165
- // done();
166
- // });
167
- // });
150
+
151
+ it('should register as ContextProvider of its lazy attributes', function (done) {
152
+ iotAgentLib.register(device1, function (error) {
153
+ should.exist(error);
154
+ error.name.should.equal('BAD_REQUEST');
155
+ contextBrokerMock.done();
156
+ done();
157
+ });
158
+ });
168
159
  });
169
160
 
170
161
  describe('When the Context Broker returns an HTTP transport error while registering a device', function () {
@@ -148,14 +148,6 @@ describe('NGSI-LD - IoT Agent Device Update Registration', function () {
148
148
  .post('/ngsi-ld/v1/csourceRegistrations/')
149
149
  .reply(201, null, { Location: '/ngsi-ld/v1/csourceRegistrations/6319a7f5254b05844116584d' });
150
150
 
151
- // This mock does not check the payload since the aim of the test is not to verify
152
- // device provisioning functionality. Appropriate verification is done in tests under
153
- // provisioning folder
154
- contextBrokerMock
155
- .matchHeader('fiware-service', 'smartgondor')
156
- .post('/ngsi-ld/v1/entityOperations/upsert/')
157
- .reply(204);
158
-
159
151
  iotAgentLib.activate(iotAgentConfig, function (error) {
160
152
  iotAgentLib.register(device1, function (error) {
161
153
  done();
@@ -192,14 +184,14 @@ describe('NGSI-LD - IoT Agent Device Update Registration', function () {
192
184
  )
193
185
  .reply(201, null, { Location: '/ngsi-ld/v1/csourceRegistrations/6319a7f5254b05844116584d' });
194
186
  });
195
- // FIXME: disabled test by #1421
196
- // it('should register as ContextProvider of its lazy attributes', function (done) {
197
- // iotAgentLib.updateRegister(deviceUpdated, false, function (error) {
198
- // should.not.exist(error);
199
- // contextBrokerMock.done();
200
- // done();
201
- // });
202
- // });
187
+
188
+ it('should register as ContextProvider of its lazy attributes', function (done) {
189
+ iotAgentLib.updateRegister(deviceUpdated, false, function (error) {
190
+ should.not.exist(error);
191
+ contextBrokerMock.done();
192
+ done();
193
+ });
194
+ });
203
195
  it('should store the new values in the registry', function (done) {
204
196
  iotAgentLib.updateRegister(deviceUpdated, false, function (error, data) {
205
197
  iotAgentLib.getDevice(deviceUpdated.id, null, 'smartgondor', 'gardens', function (error, deviceResult) {
@@ -322,11 +322,6 @@ describe('NGSI-LD - Device provisioning API: Update provisioned devices', functi
322
322
  // device provisioning functionality. Appropriate verification is done in tests under
323
323
  // provisioning folder
324
324
  contextBrokerMock = nock('http://192.168.1.1:1026')
325
- .matchHeader('fiware-service', 'smartgondor')
326
- .post('/ngsi-ld/v1/entityOperations/upsert/')
327
- .reply(204);
328
-
329
- contextBrokerMock
330
325
  .matchHeader('fiware-service', 'smartgondor')
331
326
  .post(
332
327
  '/ngsi-ld/v1/entityOperations/upsert/?options=update',
@@ -358,14 +353,6 @@ describe('NGSI-LD - Device provisioning API: Update provisioned devices', functi
358
353
  });
359
354
  });
360
355
  });
361
- // FIXME: disabled test by #1421
362
- // it('should create the initial values for the attributes in the Context Broker', function (done) {
363
- // request(optionsUpdate, function (error, response, body) {
364
- // should.not.exist(error);
365
- // contextBrokerMock.done();
366
- // done();
367
- // });
368
- // });
369
356
  });
370
357
 
371
358
  describe('When a device is updated to add static attributes', function () {
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "id":"light1",
3
3
  "type":"Light",
4
- "configuration": {
5
- "type": "Object",
6
- "value": {"firmware": {"version": "1.1.0","hash": "cf23df2207d99a74fbe169e3eba035e633b65d94"}}
7
- }
4
+ "configuration": {
5
+ "type": "Object",
6
+ "value": {"firmware": {"version": "1.1.0","hash": "cf23df2207d99a74fbe169e3eba035e633b65d94"}}
7
+ }
8
8
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "1234",
3
+ "type": "WeatherStation",
4
+ "pressure": {
5
+ "value": 1040,
6
+ "type": "Number"
7
+ }
8
+ }
@@ -3,6 +3,6 @@
3
3
  "type": "Light",
4
4
  "pressure": {
5
5
  "type": "Number",
6
- "value": 1040
6
+ "value": null
7
7
  }
8
8
  }
@@ -9,12 +9,6 @@
9
9
  52
10
10
  ],
11
11
  "type": "Point"
12
- },
13
- "metadata": {
14
- "TimeInstant": {
15
- "type": "DateTime",
16
- "value": "1970-01-01T00:00:00.001Z"
17
- }
18
12
  }
19
13
  },
20
14
  "TimeInstant": {
@@ -1,6 +1,14 @@
1
1
  {
2
2
  "id":"gps1",
3
3
  "type":"GPS",
4
+ "lat": {
5
+ "type": "Number",
6
+ "value": 52
7
+ },
8
+ "lon": {
9
+ "type": "Number",
10
+ "value": 13
11
+ },
4
12
  "location": {
5
13
  "type": "geo:json",
6
14
  "value": {
@@ -0,0 +1,14 @@
1
+ {
2
+ "id":"gps1",
3
+ "type":"GPS",
4
+ "location": {
5
+ "type": "geo:json",
6
+ "value": {
7
+ "coordinates": [
8
+ 13,
9
+ 52
10
+ ],
11
+ "type": "Point"
12
+ }
13
+ }
14
+ }
@@ -1,10 +1,6 @@
1
1
  {
2
2
  "id":"gps1",
3
3
  "type":"GPS",
4
- "TimeInstant": {
5
- "type": "DateTime",
6
- "value": "2015-08-05T07:35:01.468+00:00"
7
- },
8
4
  "location": {
9
5
  "value": {
10
6
  "coordinates": [
@@ -13,12 +9,6 @@
13
9
  ],
14
10
  "type": "Point"
15
11
  },
16
- "type": "geo:json",
17
- "metadata": {
18
- "TimeInstant": {
19
- "type": "DateTime",
20
- "value": "2015-08-05T07:35:01.468+00:00"
21
- }
22
- }
12
+ "type": "geo:json"
23
13
  }
24
14
  }