iotagent-node-lib 3.4.3 → 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 (94) hide show
  1. package/CHANGES_NEXT_RELEASE +0 -1
  2. package/README.md +4 -0
  3. package/doc/admin.md +1 -13
  4. package/doc/api.md +118 -14
  5. package/doc/devel/architecture.md +0 -12
  6. package/doc/index.md +1 -1
  7. package/doc/roadmap.md +22 -10
  8. package/lib/commonConfig.js +0 -11
  9. package/lib/model/Device.js +2 -1
  10. package/lib/model/Group.js +2 -1
  11. package/lib/model/dbConn.js +22 -11
  12. package/lib/plugins/expressionPlugin.js +0 -5
  13. package/lib/plugins/jexlParser.js +15 -31
  14. package/lib/services/common/genericMiddleware.js +14 -2
  15. package/lib/services/common/iotManagerService.js +2 -1
  16. package/lib/services/devices/deviceRegistryMongoDB.js +3 -1
  17. package/lib/services/devices/deviceService.js +16 -21
  18. package/lib/services/devices/devices-NGSI-LD.js +5 -98
  19. package/lib/services/devices/devices-NGSI-mixed.js +0 -14
  20. package/lib/services/devices/devices-NGSI-v2.js +3 -0
  21. package/lib/services/groups/groupRegistryMemory.js +0 -25
  22. package/lib/services/groups/groupRegistryMongoDB.js +20 -19
  23. package/lib/services/groups/groupService.js +3 -14
  24. package/lib/services/ngsi/entities-NGSI-LD.js +81 -6
  25. package/lib/services/ngsi/entities-NGSI-v2.js +304 -687
  26. package/lib/services/ngsi/ngsiUtils.js +0 -30
  27. package/lib/services/northBound/deviceProvisioningServer.js +6 -3
  28. package/lib/templates/createDevice.json +4 -0
  29. package/lib/templates/createDeviceLax.json +4 -0
  30. package/lib/templates/deviceGroup.json +4 -0
  31. package/lib/templates/updateDevice.json +4 -0
  32. package/lib/templates/updateDeviceLax.json +4 -0
  33. package/package.json +6 -2
  34. package/test/functional/README.md +378 -0
  35. package/test/functional/config-test.js +70 -0
  36. package/test/functional/functional-tests-runner.js +126 -0
  37. package/test/functional/functional-tests.js +241 -0
  38. package/test/functional/testCases.js +2944 -0
  39. package/test/functional/testUtils.js +251 -0
  40. package/test/tools/utils.js +25 -0
  41. package/test/unit/mongodb/mongodb-connectionoptions-test.js +35 -22
  42. package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +3 -34
  43. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +8 -1
  44. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
  45. package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +1 -6
  46. package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +67 -87
  47. package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +7 -13
  48. package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +43 -43
  49. package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +19 -29
  50. package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -1
  51. package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +35 -46
  52. package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +8 -9
  53. package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +96 -221
  54. package/test/unit/ngsi-ld/provisioning/device-registration_test.js +18 -27
  55. package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +8 -16
  56. package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +0 -13
  57. package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +4 -4
  58. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29b.json +8 -0
  59. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +1 -1
  60. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +0 -6
  61. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +8 -0
  62. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json +14 -0
  63. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +1 -11
  64. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36b.json +13 -0
  65. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin37.json +8 -0
  66. package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -11
  67. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json +37 -0
  68. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +0 -4
  69. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +0 -4
  70. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +0 -4
  71. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +4 -0
  72. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +0 -3
  73. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +10 -12
  74. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -4
  75. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -5
  76. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -12
  77. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +0 -4
  78. package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +0 -8
  79. package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +7 -1
  80. package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +898 -28
  81. package/test/unit/ngsiv2/ngsiService/active-devices-test.js +188 -1
  82. package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +267 -0
  83. package/test/unit/ngsiv2/plugins/alias-plugin_test.js +19 -21
  84. package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +21 -24
  85. package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -21
  86. package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +4 -6
  87. package/test/unit/ngsi-ld/ngsiService/autocast-test.js +0 -438
  88. package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +0 -381
  89. package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +0 -311
  90. package/test/unit/ngsiv2/ngsiService/autocast-test.js +0 -325
  91. package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +0 -427
  92. package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +0 -217
  93. package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +0 -119
  94. package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -309
@@ -289,16 +289,6 @@ describe('NGSI-LD - Secured access to the Context Broker with OAuth2 provider',
289
289
  )
290
290
  .reply(201, null, { Location: '/ngsi-ld/v1/csourceRegistrations//6319a7f5254b05844116584d' });
291
291
 
292
- contextBrokerMock
293
- .post(
294
- '/ngsi-ld/v1/entityOperations/upsert/',
295
- utils.readExampleFile(
296
- './test/unit/ngsi-ld/examples/' +
297
- 'contextRequests/createProvisionedDeviceWithGroupAndStatic3.json'
298
- )
299
- )
300
- .reply(204);
301
-
302
292
  contextBrokerMock
303
293
  .post(
304
294
  '/ngsi-ld/v1/subscriptions/',
@@ -316,38 +306,38 @@ describe('NGSI-LD - Secured access to the Context Broker with OAuth2 provider',
316
306
  });
317
307
  });
318
308
  });
319
- // FIXME: disabled test by #1421
320
- // it('subscribe requests use auth header', function (done) {
321
- // iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
322
- // iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
323
- // should.not.exist(error);
324
-
325
- // contextBrokerMock.done();
326
-
327
- // done();
328
- // });
329
- // });
330
- // });
331
- // FIXME: disabled test by #1421
332
- // it('unsubscribe requests use auth header', function (done) {
333
- // oauth2Mock
334
- // .post(
335
- // '/auth/realms/default/protocol/openid-connect/token',
336
- // utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)
337
- // )
338
- // .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {});
339
-
340
- // contextBrokerMock.delete('/ngsi-ld/v1/subscriptions/51c0ac9ed714fb3b37d7d5a8', '').reply(204);
341
-
342
- // iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
343
- // iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
344
- // iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
345
- // contextBrokerMock.done();
346
- // done();
347
- // });
348
- // });
349
- // });
350
- // });
309
+
310
+ it('subscribe requests use auth header', function (done) {
311
+ iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
312
+ iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
313
+ should.not.exist(error);
314
+
315
+ contextBrokerMock.done();
316
+
317
+ done();
318
+ });
319
+ });
320
+ });
321
+
322
+ it('unsubscribe requests use auth header', function (done) {
323
+ oauth2Mock
324
+ .post(
325
+ '/auth/realms/default/protocol/openid-connect/token',
326
+ utils.readExampleFile('./test/unit/examples/oauthRequests/getTokenFromTrust.json', true)
327
+ )
328
+ .reply(201, utils.readExampleFile('./test/unit/examples/oauthResponses/tokenFromTrust.json'), {});
329
+
330
+ contextBrokerMock.delete('/ngsi-ld/v1/subscriptions/51c0ac9ed714fb3b37d7d5a8', '').reply(204);
331
+
332
+ iotAgentLib.getDevice('Light1', null, 'smartgondor', 'electricity', function (error, device) {
333
+ iotAgentLib.subscribe(device, ['dimming'], null, function (error) {
334
+ iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
335
+ contextBrokerMock.done();
336
+ done();
337
+ });
338
+ });
339
+ });
340
+ });
351
341
  });
352
342
  });
353
343
 
@@ -745,7 +735,7 @@ describe(
745
735
  .matchHeader('fiware-service', 'testservice')
746
736
  .matchHeader('authorization', 'Bearer bea752e377680acd1349a3ed59db855a1db07zxc')
747
737
  .post(
748
- '/ngsi-ld/v1/entityOperations/upsert/',
738
+ '/ngsi-ld/v1/entityOperations/upsert/?options=update',
749
739
  utils.readExampleFile(
750
740
  './test/unit/ngsi-ld/examples/' +
751
741
  'contextRequests/createProvisionedDeviceWithGroupAndStatic2.json'
@@ -753,15 +743,6 @@ describe(
753
743
  )
754
744
  .reply(204);
755
745
 
756
- contextBrokerMock3 = nock('http://unexistentHost:1026')
757
- .matchHeader('fiware-service', 'testservice')
758
- .matchHeader('authorization', 'Bearer zzz752e377680acd1349a3ed59db855a1db07bbb')
759
- .post(
760
- '/ngsi-ld/v1/entityOperations/upsert/?options=update',
761
- utils.readExampleFile('./test/unit/ngsi-ld/examples/contextRequests/updateContext5.json')
762
- )
763
- .reply(204);
764
-
765
746
  iotAgentConfig.authentication.tokenPath = '/oauth2/token';
766
747
  iotAgentLib.activate(iotAgentConfig, function () {
767
748
  done();
@@ -773,24 +754,23 @@ describe(
773
754
 
774
755
  done();
775
756
  });
776
- // FIXME: disabled test by #1421
777
- // it('should not raise any error', function (done) {
778
- // request(deviceCreation, function (error, response, body) {
779
- // should.not.exist(error);
780
- // response.statusCode.should.equal(201);
781
- // contextBrokerMock.done();
782
- // contextBrokerMock2.done();
783
- // done();
784
- // });
785
- // });
786
- // FIXME: disabled test by #1421
787
- // it('should send the mixed data to the Context Broker', function (done) {
788
- // iotAgentLib.update('Light1', 'SensorMachine', '', values, function (error) {
789
- // should.not.exist(error);
790
- // contextBrokerMock3.done();
791
- // done();
792
- // });
793
- // });
757
+
758
+ it('should not raise any error', function (done) {
759
+ request(deviceCreation, function (error, response, body) {
760
+ should.not.exist(error);
761
+ response.statusCode.should.equal(201);
762
+ contextBrokerMock.done();
763
+ done();
764
+ });
765
+ });
766
+
767
+ it('should send the mixed data to the Context Broker', function (done) {
768
+ iotAgentLib.update('Light1', 'SensorMachine', '', values, function (error) {
769
+ should.not.exist(error);
770
+ contextBrokerMock2.done();
771
+ done();
772
+ });
773
+ });
794
774
  });
795
775
  }
796
776
  );
@@ -833,7 +813,7 @@ describe(
833
813
 
834
814
  contextBrokerMock = nock('http://unexistentHost:1026')
835
815
  .matchHeader('fiware-service', 'testservice')
836
- .matchHeader('Authorization', 'Bearer 999210dacf913772606c95dd0b895d5506cbc988')
816
+ .matchHeader('Authorization', 'Bearer 000210dacf913772606c95dd0b895d5506cbc700')
837
817
  .post(
838
818
  '/ngsi-ld/v1/entityOperations/upsert/?options=update',
839
819
  utils.readExampleFile(
@@ -849,22 +829,22 @@ describe(
849
829
  });
850
830
  });
851
831
  });
852
- // FIXME: disabled test by #1421
853
- // it('should send the permanent token in the auth header', function (done) {
854
- // iotAgentLib.update('machine1', 'SensorMachine', '', values, function (error) {
855
- // should.not.exist(error);
856
- // contextBrokerMock.done();
857
- // done();
858
- // });
859
- // });
860
- // FIXME: disabled test by #1421
861
- // it('should use the permanent trust token in the following requests', function (done) {
862
- // iotAgentLib.update('machine1', 'SensorMachine', '', values, function (error) {
863
- // should.not.exist(error);
864
- // contextBrokerMock.done();
865
- // done();
866
- // });
867
- // });
832
+
833
+ it('should send the permanent token in the auth header', function (done) {
834
+ iotAgentLib.update('machine1', 'SensorMachine', '', values, function (error) {
835
+ should.not.exist(error);
836
+ contextBrokerMock.done();
837
+ done();
838
+ });
839
+ });
840
+
841
+ it('should use the permanent trust token in the following requests', function (done) {
842
+ iotAgentLib.update('machine1', 'SensorMachine', '', values, function (error) {
843
+ should.not.exist(error);
844
+ contextBrokerMock.done();
845
+ done();
846
+ });
847
+ });
868
848
  });
869
849
  }
870
850
  );
@@ -131,11 +131,6 @@ describe('NGSI-LD - Command functionalities', function () {
131
131
  )
132
132
  .reply(201, null, { Location: '/ngsi-ld/v1/csourceRegistrations/6319a7f5254b05844116584d' });
133
133
 
134
- contextBrokerMock
135
- .matchHeader('fiware-service', 'smartgondor')
136
- .post('/ngsi-ld/v1/entityOperations/upsert/')
137
- .reply(204);
138
-
139
134
  iotAgentLib.activate(iotAgentConfig, done);
140
135
  });
141
136
 
@@ -155,14 +150,13 @@ describe('NGSI-LD - Command functionalities', function () {
155
150
  });
156
151
 
157
152
  describe('When a device is preregistered with commands', function () {
158
- // FIXME: disabled test by #1421
159
- // it('should register as Context Provider of the commands', function (done) {
160
- // iotAgentLib.register(device3, function (error) {
161
- // should.not.exist(error);
162
- // contextBrokerMock.done();
163
- // done();
164
- // });
165
- // });
153
+ it('should register as Context Provider of the commands', function (done) {
154
+ iotAgentLib.register(device3, function (error) {
155
+ should.not.exist(error);
156
+ contextBrokerMock.done();
157
+ done();
158
+ });
159
+ });
166
160
  });
167
161
 
168
162
  describe('When multiple command updates via PATCH /attrs arrive to the IoT Agent as Context Provider', function () {
@@ -55,17 +55,7 @@ const iotAgentConfig = {
55
55
  types: {
56
56
  Robot: {
57
57
  internalAttributes: [],
58
- commands: [
59
- {
60
- name: 'position',
61
- object_id: 'pos',
62
- type: 'Object'
63
- },
64
- {
65
- name: 'orientation',
66
- type: 'Object'
67
- }
68
- ],
58
+ commands: [],
69
59
  lazy: [
70
60
  {
71
61
  name: 'batteryLevel',
@@ -82,7 +72,18 @@ const iotAgentConfig = {
82
72
  const device3 = {
83
73
  id: 'r2d2',
84
74
  type: 'Robot',
85
- service: 'smartgondor'
75
+ service: 'smartgondor',
76
+ commands: [
77
+ {
78
+ name: 'position',
79
+ object_id: 'pos',
80
+ type: 'Object'
81
+ },
82
+ {
83
+ name: 'orientation',
84
+ type: 'Object'
85
+ }
86
+ ]
86
87
  };
87
88
 
88
89
  describe('NGSI-LD - Merge-Patch functionalities', function () {
@@ -154,37 +155,36 @@ describe('NGSI-LD - Merge-Patch functionalities', function () {
154
155
  });
155
156
  });
156
157
 
157
- // FIXME: after (PR#1396)
158
- // it('should call the client handler once', function (done) {
159
- // let handlerCalled = 0;
160
-
161
- // iotAgentLib.setMergePatchHandler(function (id, type, service, subservice, attributes, callback) {
162
- // id.should.equal('urn:ngsi-ld:' + device3.type + ':' + device3.id);
163
- // type.should.equal(device3.type);
164
- // attributes[0].name.should.equal('position');
165
- // attributes[1].name.should.equal('orientation');
166
- // should.equal(attributes[1].value, null);
167
- // handlerCalled++;
168
- // callback(null, {
169
- // id,
170
- // type,
171
- // attributes: [
172
- // {
173
- // name: 'position',
174
- // type: 'Array',
175
- // value: '[28, -104, 23]'
176
- // }
177
- // ]
178
- // });
179
- // });
180
-
181
- // request(options, function (error, response, body) {
182
- // should.not.exist(error);
183
- // response.statusCode.should.equal(200);
184
- // handlerCalled.should.equal(1);
185
- // done();
186
- // });
187
- // });
158
+ it('should call the client handler once', function (done) {
159
+ let handlerCalled = 0;
160
+
161
+ iotAgentLib.setMergePatchHandler(function (id, type, service, subservice, attributes, callback) {
162
+ id.should.equal('urn:ngsi-ld:' + device3.type + ':' + device3.id);
163
+ type.should.equal(device3.type);
164
+ attributes[0].name.should.equal('position');
165
+ attributes[1].name.should.equal('orientation');
166
+ should.equal(attributes[1].value, null);
167
+ handlerCalled++;
168
+ callback(null, {
169
+ id,
170
+ type,
171
+ attributes: [
172
+ {
173
+ name: 'position',
174
+ type: 'Array',
175
+ value: '[28, -104, 23]'
176
+ }
177
+ ]
178
+ });
179
+ });
180
+
181
+ request(options, function (error, response, body) {
182
+ should.not.exist(error);
183
+ response.statusCode.should.equal(200);
184
+ handlerCalled.should.equal(1);
185
+ done();
186
+ });
187
+ });
188
188
  });
189
189
 
190
190
  xdescribe('When a partial update PATCH with an NGSI-LD Null arrives to the IoT Agent as Context Provider', function () {
@@ -90,12 +90,7 @@ const iotAgentConfig = {
90
90
  active: []
91
91
  },
92
92
  Robot: {
93
- commands: [
94
- {
95
- name: 'position',
96
- type: 'Array'
97
- }
98
- ],
93
+ commands: [],
99
94
  lazy: [],
100
95
  staticAttributes: [],
101
96
  active: []
@@ -121,7 +116,13 @@ const device3 = {
121
116
  type: 'Robot',
122
117
  service: 'smartgondor',
123
118
  subservice: 'gardens',
124
- polling: true
119
+ polling: true,
120
+ commands: [
121
+ {
122
+ name: 'position',
123
+ type: 'Array'
124
+ }
125
+ ]
125
126
  };
126
127
 
127
128
  describe('NGSI-LD - Polling commands', function () {
@@ -170,16 +171,6 @@ describe('NGSI-LD - Polling commands', function () {
170
171
  };
171
172
 
172
173
  beforeEach(function (done) {
173
- statusAttributeMock = nock('http://192.168.1.1:1026')
174
- .matchHeader('fiware-service', 'smartgondor')
175
- .post(
176
- '/ngsi-ld/v1/entityOperations/upsert/',
177
- utils.readExampleFile(
178
- './test/unit/ngsi-ld/examples/contextRequests/updateContextCommandStatus1.json'
179
- )
180
- )
181
- .reply(204);
182
-
183
174
  iotAgentLib.register(device3, function (error) {
184
175
  done();
185
176
  });
@@ -209,18 +200,17 @@ describe('NGSI-LD - Polling commands', function () {
209
200
  done();
210
201
  });
211
202
  });
212
- // FIXME: disabled test by #1421
213
- // it('should create the attribute with the "_status" prefix in the Context Broker', function (done) {
214
- // iotAgentLib.setCommandHandler(function (id, type, service, subservice, attributes, callback) {
215
- // callback(null);
216
- // });
217
-
218
- // request(options, function (error, response, body) {
219
- // should.not.exist(error);
220
- // statusAttributeMock.done();
221
- // done();
222
- // });
223
- // });
203
+
204
+ it('should create the attribute with the "_status" prefix in the Context Broker', function (done) {
205
+ iotAgentLib.setCommandHandler(function (id, type, service, subservice, attributes, callback) {
206
+ callback(null);
207
+ });
208
+
209
+ request(options, function (error, response, body) {
210
+ should.not.exist(error);
211
+ done();
212
+ });
213
+ });
224
214
  xit('should store the commands in the queue', function (done) {
225
215
  iotAgentLib.setCommandHandler(function (id, type, service, subservice, attributes, callback) {
226
216
  callback(null);
@@ -33,7 +33,6 @@ const logger = require('logops');
33
33
  const nock = require('nock');
34
34
  let contextBrokerMock;
35
35
  const iotAgentConfig = {
36
- autocast: true,
37
36
  contextBroker: {
38
37
  host: '192.168.1.1',
39
38
  port: '1026',
@@ -66,16 +66,6 @@ describe('NGSI-LD - Subscription tests', function () {
66
66
 
67
67
  iotAgentLib.activate(iotAgentConfig, function () {
68
68
  contextBrokerMock = nock('http://192.168.1.1:1026')
69
- .matchHeader('fiware-service', 'smartgondor')
70
- .post(
71
- '/ngsi-ld/v1/entityOperations/upsert/',
72
- utils.readExampleFile(
73
- './test/unit/ngsi-ld/examples/contextRequests/createMinimumProvisionedDevice.json'
74
- )
75
- )
76
- .reply(204);
77
-
78
- contextBrokerMock
79
69
  .matchHeader('fiware-service', 'smartgondor')
80
70
  .post(
81
71
  '/ngsi-ld/v1/subscriptions/',
@@ -102,18 +92,17 @@ describe('NGSI-LD - Subscription tests', function () {
102
92
  });
103
93
 
104
94
  describe('When a client invokes the subscribe() function for device', function () {
105
- // FIXME: disabled test by #1421
106
- // it('should send the appropriate request to the Context Broker', function (done) {
107
- // iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
108
- // iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
109
- // should.not.exist(error);
110
-
111
- // contextBrokerMock.done();
112
-
113
- // done();
114
- // });
115
- // });
116
- // });
95
+ it('should send the appropriate request to the Context Broker', function (done) {
96
+ iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
97
+ iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
98
+ should.not.exist(error);
99
+
100
+ contextBrokerMock.done();
101
+
102
+ done();
103
+ });
104
+ });
105
+ });
117
106
  it('should store the subscription ID in the Device Registry', function (done) {
118
107
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
119
108
  iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
@@ -139,19 +128,19 @@ describe('NGSI-LD - Subscription tests', function () {
139
128
 
140
129
  done();
141
130
  });
142
- // FIXME: disabled test by #1421
143
- // it('should delete the subscription from the CB', function (done) {
144
- // iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
145
- // iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
146
- // iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
147
- // iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
148
- // contextBrokerMock.done();
149
- // done();
150
- // });
151
- // });
152
- // });
153
- // });
154
- // });
131
+
132
+ it('should delete the subscription from the CB', function (done) {
133
+ iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
134
+ iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
135
+ iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
136
+ iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
137
+ contextBrokerMock.done();
138
+ done();
139
+ });
140
+ });
141
+ });
142
+ });
143
+ });
155
144
  it('should remove the id from the subscriptions array', function (done) {
156
145
  iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
157
146
  iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
@@ -177,17 +166,17 @@ describe('NGSI-LD - Subscription tests', function () {
177
166
 
178
167
  done();
179
168
  });
180
- // FIXME: disabled test by #1421
181
- // it('should delete the subscription from the CB', function (done) {
182
- // iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
183
- // iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
184
- // iotAgentLib.unregister(device.id, null, 'smartgondor', '/gardens', function (error) {
185
- // contextBrokerMock.done();
186
- // done();
187
- // });
188
- // });
189
- // });
190
- // });
169
+
170
+ it('should delete the subscription from the CB', function (done) {
171
+ iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
172
+ iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
173
+ iotAgentLib.unregister(device.id, null, 'smartgondor', '/gardens', function (error) {
174
+ contextBrokerMock.done();
175
+ done();
176
+ });
177
+ });
178
+ });
179
+ });
191
180
  });
192
181
  describe('When a new notification comes to the IoTAgent', function () {
193
182
  beforeEach(function (done) {
@@ -33,7 +33,6 @@ const logger = require('logops');
33
33
  const nock = require('nock');
34
34
  let contextBrokerMock;
35
35
  const iotAgentConfig = {
36
- autocast: true,
37
36
  contextBroker: {
38
37
  host: '192.168.1.1',
39
38
  port: '1026',
@@ -154,7 +153,7 @@ describe('NGSI-LD - Attribute alias plugin', function () {
154
153
  .reply(204);
155
154
  });
156
155
 
157
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
156
+ it('should rename the attributes as expected by the alias mappings', function (done) {
158
157
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
159
158
  should.not.exist(error);
160
159
  contextBrokerMock.done();
@@ -183,7 +182,7 @@ describe('NGSI-LD - Attribute alias plugin', function () {
183
182
  .reply(204);
184
183
  });
185
184
 
186
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
185
+ it('should rename the attributes as expected by the alias mappings', function (done) {
187
186
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
188
187
  should.not.exist(error);
189
188
  contextBrokerMock.done();
@@ -242,7 +241,7 @@ describe('NGSI-LD - Attribute alias plugin', function () {
242
241
  .reply(204);
243
242
  });
244
243
 
245
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
244
+ it('should rename the attributes as expected by the alias mappings', function (done) {
246
245
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
247
246
  should.not.exist(error);
248
247
  contextBrokerMock.done();
@@ -272,7 +271,7 @@ describe('NGSI-LD - Attribute alias plugin', function () {
272
271
  .reply(204);
273
272
  });
274
273
 
275
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
274
+ it('should rename the attributes as expected by the alias mappings', function (done) {
276
275
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
277
276
  should.not.exist(error);
278
277
  contextBrokerMock.done();
@@ -302,7 +301,7 @@ describe('NGSI-LD - Attribute alias plugin', function () {
302
301
  .reply(204);
303
302
  });
304
303
 
305
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
304
+ it('should rename the attributes as expected by the alias mappings', function (done) {
306
305
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
307
306
  should.not.exist(error);
308
307
  contextBrokerMock.done();
@@ -332,7 +331,7 @@ describe('NGSI-LD - Attribute alias plugin', function () {
332
331
  .reply(204);
333
332
  });
334
333
 
335
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
334
+ it('should rename the attributes as expected by the alias mappings', function (done) {
336
335
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
337
336
  should.not.exist(error);
338
337
  contextBrokerMock.done();
@@ -362,7 +361,7 @@ describe('NGSI-LD - Attribute alias plugin', function () {
362
361
  .reply(204);
363
362
  });
364
363
 
365
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
364
+ it('should rename the attributes as expected by the alias mappings', function (done) {
366
365
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
367
366
  should.not.exist(error);
368
367
  contextBrokerMock.done();
@@ -392,7 +391,7 @@ describe('NGSI-LD - Attribute alias plugin', function () {
392
391
  .reply(204);
393
392
  });
394
393
 
395
- it('should rename the attributes as expected by the alias mappings and cast values to JSON native types', function (done) {
394
+ it('should rename the attributes as expected by the alias mappings', function (done) {
396
395
  iotAgentLib.update('light1', 'Light', '', values, function (error) {
397
396
  should.not.exist(error);
398
397
  contextBrokerMock.done();