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.
- package/README.md +4 -0
- package/doc/admin.md +1 -13
- package/doc/api.md +116 -18
- package/doc/devel/architecture.md +0 -12
- package/doc/index.md +1 -1
- package/doc/roadmap.md +22 -10
- package/lib/commonConfig.js +0 -11
- package/lib/model/Device.js +2 -1
- package/lib/model/Group.js +2 -1
- package/lib/model/dbConn.js +22 -11
- package/lib/plugins/expressionPlugin.js +0 -5
- package/lib/plugins/jexlParser.js +15 -31
- package/lib/services/common/genericMiddleware.js +14 -2
- package/lib/services/common/iotManagerService.js +2 -1
- package/lib/services/devices/deviceRegistryMongoDB.js +3 -1
- package/lib/services/devices/deviceService.js +16 -21
- package/lib/services/devices/devices-NGSI-LD.js +5 -98
- package/lib/services/devices/devices-NGSI-mixed.js +0 -14
- package/lib/services/devices/devices-NGSI-v2.js +3 -0
- package/lib/services/groups/groupRegistryMemory.js +0 -25
- package/lib/services/groups/groupRegistryMongoDB.js +20 -19
- package/lib/services/groups/groupService.js +3 -14
- package/lib/services/ngsi/entities-NGSI-LD.js +81 -6
- package/lib/services/ngsi/entities-NGSI-v2.js +303 -698
- package/lib/services/ngsi/ngsiUtils.js +0 -30
- package/lib/services/northBound/deviceProvisioningServer.js +6 -3
- package/lib/templates/createDevice.json +4 -0
- package/lib/templates/createDeviceLax.json +4 -0
- package/lib/templates/deviceGroup.json +4 -0
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +4 -0
- package/package.json +6 -2
- package/test/functional/README.md +378 -0
- package/test/functional/config-test.js +70 -0
- package/test/functional/functional-tests-runner.js +126 -0
- package/test/functional/functional-tests.js +241 -0
- package/test/functional/testCases.js +2944 -0
- package/test/functional/testUtils.js +251 -0
- package/test/tools/utils.js +25 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +35 -22
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +3 -34
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +8 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +1 -6
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +67 -87
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +7 -13
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +43 -43
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +19 -29
- package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -1
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +35 -46
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +8 -9
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +96 -221
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +18 -27
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +8 -16
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +0 -13
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +4 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29b.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +0 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json +14 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +1 -11
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36b.json +13 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin37.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -11
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json +37 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +4 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +0 -3
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +10 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -5
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +7 -1
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +898 -28
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +0 -4
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +267 -0
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +19 -21
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +21 -24
- package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -21
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +4 -6
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +0 -438
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +0 -381
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +0 -311
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +0 -325
- package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +0 -427
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +0 -217
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +0 -119
- 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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
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
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
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
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
"configuration": {
|
|
5
|
+
"type": "Object",
|
|
6
|
+
"value": {"firmware": {"version": "1.1.0","hash": "cf23df2207d99a74fbe169e3eba035e633b65d94"}}
|
|
7
|
+
}
|
|
8
8
|
}
|
|
@@ -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
|
}
|