iotagent-node-lib 3.3.0 → 3.4.1

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 (80) hide show
  1. package/CHANGES_NEXT_RELEASE +1 -0
  2. package/README.md +10 -11
  3. package/doc/README.md +16 -0
  4. package/doc/admin.md +565 -0
  5. package/doc/api.md +9 -5
  6. package/doc/deprecated.md +16 -14
  7. package/doc/{architecture.md → devel/architecture.md} +3 -3
  8. package/doc/{Contribution.md → devel/contribution-guidelines.md} +43 -35
  9. package/doc/devel/development.md +1879 -0
  10. package/doc/{northboundinteractions.md → devel/northboundinteractions.md} +18 -33
  11. package/doc/index.md +3 -5
  12. package/docker/Mosquitto/README.md +1 -0
  13. package/lib/commonConfig.js +0 -5
  14. package/lib/fiware-iotagent-lib.js +1 -1
  15. package/lib/jexlTranformsMap.js +2 -1
  16. package/lib/request-shim.js +2 -2
  17. package/lib/services/commands/commandService.js +1 -1
  18. package/lib/services/common/genericMiddleware.js +1 -1
  19. package/lib/services/devices/deviceRegistryMemory.js +2 -2
  20. package/lib/services/devices/deviceRegistryMongoDB.js +22 -9
  21. package/lib/services/devices/deviceService.js +36 -30
  22. package/lib/services/devices/devices-NGSI-LD.js +14 -2
  23. package/lib/services/devices/devices-NGSI-mixed.js +0 -2
  24. package/lib/services/devices/devices-NGSI-v2.js +22 -100
  25. package/lib/services/groups/groupService.js +1 -1
  26. package/lib/services/ngsi/entities-NGSI-v2.js +14 -27
  27. package/lib/services/northBound/deviceProvisioningServer.js +14 -5
  28. package/mkdocs.yml +6 -11
  29. package/package.json +3 -3
  30. package/scripts/legacy_expression_tool/README.md +56 -38
  31. package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -2
  32. package/test/unit/mongodb/mongodb-registry-test.js +1 -1
  33. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +66 -65
  34. package/test/unit/ngsi-ld/general/https-support-test.js +1 -1
  35. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +8 -7
  36. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +12 -11
  37. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +41 -39
  38. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +122 -122
  39. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +28 -28
  40. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +18 -17
  41. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +7 -7
  42. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +8 -7
  43. package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +2 -0
  44. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +0 -12
  45. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +0 -4
  46. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +1 -5
  47. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +0 -12
  48. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +0 -12
  49. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +0 -4
  50. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +0 -10
  51. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +0 -4
  52. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +0 -4
  53. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +0 -4
  54. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +0 -12
  55. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +0 -4
  56. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +1 -5
  57. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +13 -12
  58. package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
  59. package/test/unit/ngsiv2/general/https-support-test.js +1 -1
  60. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +3 -8
  61. package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +10 -10
  62. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +8 -103
  63. package/test/unit/ngsiv2/provisioning/device-registration_test.js +8 -6
  64. package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +2 -1
  65. package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -1
  66. package/.nyc_output/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
  67. package/.nyc_output/processinfo/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
  68. package/.nyc_output/processinfo/index.json +0 -1
  69. package/doc/config-basic-example.js +0 -20
  70. package/doc/development.md +0 -285
  71. package/doc/howto.md +0 -641
  72. package/doc/installationguide.md +0 -365
  73. package/doc/operations.md +0 -127
  74. package/doc/usermanual.md +0 -900
  75. package/lib/plugins/bidirectionalData.js +0 -356
  76. package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +0 -697
  77. package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +0 -536
  78. /package/doc/{NorthboundInteractions.postman_collection → devel/NorthboundInteractions.postman_collection} +0 -0
  79. /package/doc/{echo.js → devel/echo.js} +0 -0
  80. /package/doc/{finalResult.js → devel/finalResult.js} +0 -0
@@ -1,536 +0,0 @@
1
- /*
2
- * Copyright 2016 Telefonica Investigación y Desarrollo, S.A.U
3
- *
4
- * This file is part of fiware-iotagent-lib
5
- *
6
- * fiware-iotagent-lib is free software: you can redistribute it and/or
7
- * modify it under the terms of the GNU Affero General Public License as
8
- * published by the Free Software Foundation, either version 3 of the License,
9
- * or (at your option) any later version.
10
- *
11
- * fiware-iotagent-lib is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
- * See the GNU Affero General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Affero General Public
17
- * License along with fiware-iotagent-lib.
18
- * If not, see http://www.gnu.org/licenses/.
19
- *
20
- * For those usages not covered by the GNU Affero General Public License
21
- * please contact with::daniel.moranjimenez@telefonica.com
22
- *
23
- * Modified by: Daniel Calvo - ATOS Research & Innovation
24
- */
25
-
26
- /* eslint-disable no-unused-vars */
27
-
28
- const iotAgentLib = require('../../../../lib/fiware-iotagent-lib');
29
- const utils = require('../../../tools/utils');
30
- const request = utils.request;
31
- const should = require('should');
32
- const logger = require('logops');
33
- const nock = require('nock');
34
-
35
- let contextBrokerMock;
36
- const iotAgentConfig = {
37
- contextBroker: {
38
- host: '192.168.1.1',
39
- port: '1026',
40
- ngsiVersion: 'v2'
41
- },
42
- server: {
43
- port: 4041,
44
- host: 'localhost'
45
- },
46
- types: {},
47
- service: 'smartgondor',
48
- subservice: 'gardens',
49
- providerUrl: 'http://smartgondor.com'
50
- };
51
-
52
- describe('NGSI-v2 - Bidirectional data plugin', function () {
53
- const options = {
54
- url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices',
55
- method: 'POST',
56
- json: utils.readExampleFile(
57
- './test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json'
58
- ),
59
- headers: {
60
- 'fiware-service': 'smartgondor',
61
- 'fiware-servicepath': '/gardens'
62
- }
63
- };
64
-
65
- beforeEach(function (done) {
66
- logger.setLevel('FATAL');
67
-
68
- iotAgentLib.activate(iotAgentConfig, function () {
69
- iotAgentLib.clearAll(function () {
70
- iotAgentLib.addDeviceProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.deviceProvision);
71
- iotAgentLib.addConfigurationProvisionMiddleware(
72
- iotAgentLib.dataPlugins.bidirectionalData.groupProvision
73
- );
74
- iotAgentLib.addNotificationMiddleware(iotAgentLib.dataPlugins.bidirectionalData.notification);
75
- done();
76
- });
77
- });
78
- });
79
-
80
- afterEach(function (done) {
81
- iotAgentLib.clearAll(function () {
82
- iotAgentLib.deactivate(done);
83
- });
84
- });
85
-
86
- describe('When a new provisioning request arrives to the IoTA with bidirectionality', function () {
87
- beforeEach(function () {
88
- contextBrokerMock = nock('http://192.168.1.1:1026')
89
- .matchHeader('fiware-service', 'smartgondor')
90
- .matchHeader('fiware-servicepath', '/gardens')
91
- .post(
92
- '/v2/subscriptions',
93
- utils.readExampleFile(
94
- './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json'
95
- )
96
- )
97
- .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' });
98
- });
99
-
100
- it('should subscribe to the modification of the combined attribute with all the variables', function (done) {
101
- request(options, function (error, response, body) {
102
- should.not.exist(error);
103
- contextBrokerMock.done();
104
- done();
105
- });
106
- });
107
- });
108
-
109
- describe('When a device with bidirectionality subscriptions is removed', function () {
110
- const deleteRequest = {
111
- url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices/Light1',
112
- method: 'DELETE',
113
- headers: {
114
- 'fiware-service': 'smartgondor',
115
- 'fiware-servicepath': '/gardens'
116
- }
117
- };
118
-
119
- beforeEach(function () {
120
- contextBrokerMock
121
- .matchHeader('fiware-service', 'smartgondor')
122
- .matchHeader('fiware-servicepath', '/gardens')
123
- .post(
124
- '/v2/subscriptions',
125
- utils.readExampleFile(
126
- './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json'
127
- )
128
- )
129
- .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' });
130
-
131
- contextBrokerMock
132
- .matchHeader('fiware-service', 'smartgondor')
133
- .matchHeader('fiware-servicepath', '/gardens')
134
- .delete('/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8', '')
135
- .reply(204);
136
- });
137
-
138
- it('should remove its subscriptions from the Context Broker', function (done) {
139
- request(options, function (error, response, body) {
140
- request(deleteRequest, function (error, response, body) {
141
- should.not.exist(error);
142
- contextBrokerMock.done();
143
- done();
144
- });
145
- });
146
- });
147
- });
148
-
149
- describe('When a notification arrives for a bidirectional attribute', function () {
150
- const notificationOptions = {
151
- url: 'http://localhost:' + iotAgentConfig.server.port + '/notify',
152
- method: 'POST',
153
- json: utils.readExampleFile(
154
- './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotification.json'
155
- ),
156
- headers: {
157
- 'fiware-service': 'smartgondor',
158
- 'fiware-servicepath': '/gardens'
159
- }
160
- };
161
- let executedHandler = false;
162
-
163
- beforeEach(function () {
164
- contextBrokerMock
165
- .matchHeader('fiware-service', 'smartgondor')
166
- .matchHeader('fiware-servicepath', '/gardens')
167
- .post(
168
- '/v2/subscriptions',
169
- utils.readExampleFile(
170
- './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json'
171
- )
172
- )
173
- .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' });
174
- });
175
-
176
- afterEach(function () {
177
- iotAgentLib.setNotificationHandler();
178
- });
179
-
180
- it('should execute the original handler', function (done) {
181
- function mockedHandler(device, notification, callback) {
182
- executedHandler = true;
183
- callback();
184
- }
185
-
186
- iotAgentLib.setNotificationHandler(mockedHandler);
187
-
188
- request(options, function (error, response, body) {
189
- request(notificationOptions, function (error, response, body) {
190
- executedHandler.should.equal(true);
191
- contextBrokerMock.done();
192
- done();
193
- });
194
- });
195
- });
196
-
197
- it('should return a 200 OK', function (done) {
198
- function mockedHandler(device, notification, callback) {
199
- executedHandler = true;
200
- callback();
201
- }
202
-
203
- iotAgentLib.setNotificationHandler(mockedHandler);
204
-
205
- request(options, function (error, response, body) {
206
- request(notificationOptions, function (error, response, body) {
207
- response.statusCode.should.equal(200);
208
- contextBrokerMock.done();
209
- done();
210
- });
211
- });
212
- });
213
-
214
- it('should return the transformed values', function (done) {
215
- let transformedHandler = false;
216
-
217
- function mockedHandler(device, values, callback) {
218
- let latitudeFound = false;
219
- let longitudeFound = false;
220
-
221
- for (let i = 0; i < values.length; i++) {
222
- if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
223
- latitudeFound = true;
224
- }
225
-
226
- if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
227
- longitudeFound = true;
228
- }
229
- }
230
-
231
- transformedHandler = values.length >= 2 && longitudeFound && latitudeFound;
232
- callback();
233
- }
234
-
235
- iotAgentLib.setNotificationHandler(mockedHandler);
236
-
237
- request(options, function (error, response, body) {
238
- request(notificationOptions, function (error, response, body) {
239
- contextBrokerMock.done();
240
- transformedHandler.should.equal(true);
241
- done();
242
- });
243
- });
244
- });
245
- });
246
-
247
- describe('When a notification with metadata arrives for a bidirectional attribute', function () {
248
- const notificationOptions = {
249
- url: 'http://localhost:' + iotAgentConfig.server.port + '/notify',
250
- method: 'POST',
251
- json: utils.readExampleFile(
252
- './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json'
253
- ),
254
- headers: {
255
- 'fiware-service': 'smartgondor',
256
- 'fiware-servicepath': '/gardens'
257
- }
258
- };
259
- let executedHandler = false;
260
-
261
- beforeEach(function () {
262
- contextBrokerMock
263
- .matchHeader('fiware-service', 'smartgondor')
264
- .matchHeader('fiware-servicepath', '/gardens')
265
- .post(
266
- '/v2/subscriptions',
267
- utils.readExampleFile(
268
- './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json'
269
- )
270
- )
271
- .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' });
272
- });
273
-
274
- afterEach(function () {
275
- iotAgentLib.setNotificationHandler();
276
- });
277
-
278
- it('should execute the original handler', function (done) {
279
- function mockedHandler(device, notification, callback) {
280
- notification[0].name.should.equal('location');
281
- notification[0].value.should.equal('12.4, -9.6');
282
- notification[0].metadata.qos.value.should.equal(1);
283
-
284
- executedHandler = true;
285
- callback();
286
- }
287
-
288
- iotAgentLib.setNotificationHandler(mockedHandler);
289
-
290
- request(options, function (error, response, body) {
291
- request(notificationOptions, function (error, response, body) {
292
- executedHandler.should.equal(true);
293
- contextBrokerMock.done();
294
- done();
295
- });
296
- });
297
- });
298
-
299
- it('should return a 200 OK', function (done) {
300
- function mockedHandler(device, notification, callback) {
301
- executedHandler = true;
302
- callback();
303
- }
304
-
305
- iotAgentLib.setNotificationHandler(mockedHandler);
306
-
307
- request(options, function (error, response, body) {
308
- request(notificationOptions, function (error, response, body) {
309
- response.statusCode.should.equal(200);
310
- contextBrokerMock.done();
311
- done();
312
- });
313
- });
314
- });
315
-
316
- it('should return the transformed values', function (done) {
317
- let transformedHandler = false;
318
-
319
- function mockedHandler(device, values, callback) {
320
- let latitudeFound = false;
321
- let longitudeFound = false;
322
-
323
- for (let i = 0; i < values.length; i++) {
324
- if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
325
- latitudeFound = true;
326
- }
327
-
328
- if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
329
- longitudeFound = true;
330
- }
331
- }
332
-
333
- transformedHandler = values.length >= 2 && longitudeFound && latitudeFound;
334
- callback();
335
- }
336
-
337
- iotAgentLib.setNotificationHandler(mockedHandler);
338
-
339
- request(options, function (error, response, body) {
340
- request(notificationOptions, function (error, response, body) {
341
- contextBrokerMock.done();
342
- transformedHandler.should.equal(true);
343
- done();
344
- });
345
- });
346
- });
347
- });
348
-
349
- describe('When a new Group provisioning request arrives with bidirectional attributes', function () {
350
- const provisionGroup = {
351
- url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services',
352
- method: 'POST',
353
- json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json'),
354
- headers: {
355
- 'fiware-service': 'smartgondor',
356
- 'fiware-servicepath': '/gardens'
357
- }
358
- };
359
- const provisionDevice = {
360
- url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices',
361
- method: 'POST',
362
- json: utils.readExampleFile(
363
- './test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json'
364
- ),
365
- headers: {
366
- 'fiware-service': 'smartgondor',
367
- 'fiware-servicepath': '/gardens'
368
- }
369
- };
370
-
371
- beforeEach(function () {
372
- contextBrokerMock
373
- .matchHeader('fiware-service', 'smartgondor')
374
- .matchHeader('fiware-servicepath', '/gardens')
375
- .post(
376
- '/v2/subscriptions',
377
- utils.readExampleFile(
378
- './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json'
379
- )
380
- )
381
- .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' });
382
- });
383
- it('should subscribe to the modification of the combined attribute with all the variables', function (done) {
384
- request(provisionGroup, function (error, response, body) {
385
- request(provisionDevice, function (error, response, body) {
386
- should.not.exist(error);
387
- contextBrokerMock.done();
388
- done();
389
- });
390
- });
391
- });
392
- });
393
-
394
- describe('When a notification arrives for a bidirectional attribute in a Configuration Group', function () {
395
- const provisionGroup = {
396
- url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services',
397
- method: 'POST',
398
- json: utils.readExampleFile('./test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json'),
399
- headers: {
400
- 'fiware-service': 'smartgondor',
401
- 'fiware-servicepath': '/gardens'
402
- }
403
- };
404
- const notificationOptions = {
405
- url: 'http://localhost:' + iotAgentConfig.server.port + '/notify',
406
- method: 'POST',
407
- json: utils.readExampleFile(
408
- './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotification.json'
409
- ),
410
- headers: {
411
- 'fiware-service': 'smartgondor',
412
- 'fiware-servicepath': '/gardens'
413
- }
414
- };
415
- const provisionDevice = {
416
- url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices',
417
- method: 'POST',
418
- json: utils.readExampleFile(
419
- './test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json'
420
- ),
421
- headers: {
422
- 'fiware-service': 'smartgondor',
423
- 'fiware-servicepath': '/gardens'
424
- }
425
- };
426
-
427
- beforeEach(function () {
428
- contextBrokerMock
429
- .matchHeader('fiware-service', 'smartgondor')
430
- .matchHeader('fiware-servicepath', '/gardens')
431
- .post(
432
- '/v2/subscriptions',
433
- utils.readExampleFile(
434
- './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json'
435
- )
436
- )
437
- .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' });
438
- });
439
-
440
- afterEach(function () {
441
- iotAgentLib.setNotificationHandler();
442
- });
443
-
444
- it('should return the transformed values', function (done) {
445
- let transformedHandler = false;
446
-
447
- function mockedHandler(device, values, callback) {
448
- let latitudeFound = false;
449
- let longitudeFound = false;
450
-
451
- for (let i = 0; i < values.length; i++) {
452
- if (values[i].name === 'latitude' && values[i].type === 'Number' && values[i].value === -9.6) {
453
- latitudeFound = true;
454
- }
455
-
456
- if (values[i].name === 'longitude' && values[i].type === 'Number' && values[i].value === 12.4) {
457
- longitudeFound = true;
458
- }
459
- }
460
-
461
- transformedHandler = values.length >= 2 && longitudeFound && latitudeFound;
462
- callback();
463
- }
464
-
465
- iotAgentLib.setNotificationHandler(mockedHandler);
466
-
467
- request(provisionGroup, function (error, response, body) {
468
- request(provisionDevice, function (error, response, body) {
469
- request(notificationOptions, function (error, response, body) {
470
- transformedHandler.should.equal(true);
471
- done();
472
- });
473
- });
474
- });
475
- });
476
- });
477
- });
478
-
479
- describe('NGSI-v2 - Bidirectional data plugin and CB is defined using environment variables', function () {
480
- const options = {
481
- url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices',
482
- method: 'POST',
483
- json: utils.readExampleFile(
484
- './test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json'
485
- ),
486
- headers: {
487
- 'fiware-service': 'smartgondor',
488
- 'fiware-servicepath': '/gardens'
489
- }
490
- };
491
-
492
- beforeEach(function (done) {
493
- logger.setLevel('FATAL');
494
- process.env.IOTA_CB_HOST = 'cbhost';
495
- iotAgentLib.activate(iotAgentConfig, function () {
496
- iotAgentLib.clearAll(function () {
497
- iotAgentLib.addDeviceProvisionMiddleware(iotAgentLib.dataPlugins.bidirectionalData.deviceProvision);
498
- iotAgentLib.addConfigurationProvisionMiddleware(
499
- iotAgentLib.dataPlugins.bidirectionalData.groupProvision
500
- );
501
- iotAgentLib.addNotificationMiddleware(iotAgentLib.dataPlugins.bidirectionalData.notification);
502
- done();
503
- });
504
- });
505
- });
506
-
507
- afterEach(function (done) {
508
- process.env.IOTA_CB_HOST = '';
509
- iotAgentLib.clearAll(function () {
510
- iotAgentLib.deactivate(done);
511
- });
512
- });
513
-
514
- describe('When a new provisioning request arrives to the IoTA with bidirectionality', function () {
515
- beforeEach(function () {
516
- contextBrokerMock = nock('http://cbhost:1026')
517
- .matchHeader('fiware-service', 'smartgondor')
518
- .matchHeader('fiware-servicepath', '/gardens')
519
- .post(
520
- '/v2/subscriptions',
521
- utils.readExampleFile(
522
- './test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json'
523
- )
524
- )
525
- .reply(201, null, { Location: '/v2/subscriptions/51c0ac9ed714fb3b37d7d5a8' });
526
- });
527
-
528
- it('should subscribe to the modification of the combined attribute with all the variables', function (done) {
529
- request(options, function (error, response, body) {
530
- should.not.exist(error);
531
- contextBrokerMock.done();
532
- done();
533
- });
534
- });
535
- });
536
- });
File without changes
File without changes