iotagent-node-lib 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -11
- package/doc/README.md +16 -0
- package/doc/admin.md +565 -0
- package/doc/api.md +9 -5
- package/doc/deprecated.md +16 -14
- package/doc/{architecture.md → devel/architecture.md} +3 -3
- package/doc/{Contribution.md → devel/contribution-guidelines.md} +43 -35
- package/doc/devel/development.md +1879 -0
- package/doc/{northboundinteractions.md → devel/northboundinteractions.md} +18 -33
- package/doc/index.md +3 -5
- package/docker/Mosquitto/README.md +1 -0
- package/lib/commonConfig.js +0 -5
- package/lib/fiware-iotagent-lib.js +1 -1
- package/lib/jexlTranformsMap.js +2 -1
- package/lib/request-shim.js +2 -2
- package/lib/services/commands/commandService.js +1 -1
- package/lib/services/common/genericMiddleware.js +1 -1
- package/lib/services/devices/deviceRegistryMemory.js +2 -2
- package/lib/services/devices/deviceRegistryMongoDB.js +22 -9
- package/lib/services/devices/deviceService.js +36 -30
- package/lib/services/devices/devices-NGSI-LD.js +14 -2
- package/lib/services/devices/devices-NGSI-mixed.js +0 -2
- package/lib/services/devices/devices-NGSI-v2.js +22 -100
- package/lib/services/groups/groupService.js +1 -1
- package/lib/services/ngsi/entities-NGSI-v2.js +11 -25
- package/lib/services/northBound/deviceProvisioningServer.js +14 -5
- package/mkdocs.yml +6 -11
- package/package.json +3 -3
- package/scripts/legacy_expression_tool/README.md +56 -38
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +2 -2
- package/test/unit/mongodb/mongodb-registry-test.js +1 -1
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +66 -65
- package/test/unit/ngsi-ld/general/https-support-test.js +1 -1
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +8 -7
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +12 -11
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +41 -39
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +122 -122
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +28 -28
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +18 -17
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +7 -7
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +8 -7
- package/test/unit/ngsiv2/examples/contextRequests/updateContext6.json +2 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin1.json +0 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin11.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin12.json +1 -5
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin2.json +0 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29.json +0 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin3.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +0 -10
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin5.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin6.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin7.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin8.json +0 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin9.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +1 -5
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +13 -12
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +2 -2
- package/test/unit/ngsiv2/general/https-support-test.js +1 -1
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +3 -8
- package/test/unit/ngsiv2/ngsiService/subscriptions-test.js +10 -10
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +8 -103
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +8 -6
- package/test/unit/ngsiv2/provisioning/device-update-registration_test.js +2 -1
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +0 -1
- package/.nyc_output/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
- package/.nyc_output/processinfo/33364de2-1199-4ec2-b33c-cae063ef8cc4.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/doc/config-basic-example.js +0 -20
- package/doc/development.md +0 -285
- package/doc/howto.md +0 -641
- package/doc/installationguide.md +0 -365
- package/doc/operations.md +0 -127
- package/doc/usermanual.md +0 -900
- package/lib/plugins/bidirectionalData.js +0 -356
- package/test/unit/ngsi-ld/plugins/bidirectional-plugin_test.js +0 -697
- package/test/unit/ngsiv2/plugins/bidirectional-plugin_test.js +0 -536
- /package/doc/{NorthboundInteractions.postman_collection → devel/NorthboundInteractions.postman_collection} +0 -0
- /package/doc/{echo.js → devel/echo.js} +0 -0
- /package/doc/{finalResult.js → devel/finalResult.js} +0 -0
|
@@ -316,38 +316,38 @@ describe('NGSI-LD - Secured access to the Context Broker with OAuth2 provider',
|
|
|
316
316
|
});
|
|
317
317
|
});
|
|
318
318
|
});
|
|
319
|
-
|
|
320
|
-
it('subscribe requests use auth header', function (done) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
it('unsubscribe requests use auth header', function (done) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
});
|
|
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
|
+
// });
|
|
351
351
|
});
|
|
352
352
|
});
|
|
353
353
|
|
|
@@ -773,24 +773,24 @@ describe(
|
|
|
773
773
|
|
|
774
774
|
done();
|
|
775
775
|
});
|
|
776
|
-
|
|
777
|
-
it('should not raise any error', function (done) {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
});
|
|
786
|
-
|
|
787
|
-
it('should send the mixed data to the Context Broker', function (done) {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
});
|
|
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
|
+
// });
|
|
794
794
|
});
|
|
795
795
|
}
|
|
796
796
|
);
|
|
@@ -849,21 +849,22 @@ describe(
|
|
|
849
849
|
});
|
|
850
850
|
});
|
|
851
851
|
});
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
});
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
});
|
|
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
|
+
// });
|
|
867
868
|
});
|
|
868
869
|
}
|
|
869
870
|
);
|
|
@@ -213,7 +213,7 @@ describe('NGSI-LD - HTTPS support tests', function () {
|
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
it('should send the appropriate request to the Context Broker', function (done) {
|
|
216
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
216
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
217
217
|
iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
|
|
218
218
|
should.not.exist(error);
|
|
219
219
|
|
|
@@ -155,13 +155,14 @@ describe('NGSI-LD - Command functionalities', function () {
|
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
describe('When a device is preregistered with commands', function () {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
});
|
|
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
|
+
// });
|
|
165
166
|
});
|
|
166
167
|
|
|
167
168
|
describe('When multiple command updates via PATCH /attrs arrive to the IoT Agent as Context Provider', function () {
|
|
@@ -209,17 +209,18 @@ describe('NGSI-LD - Polling commands', function () {
|
|
|
209
209
|
done();
|
|
210
210
|
});
|
|
211
211
|
});
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
});
|
|
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
|
+
// });
|
|
223
224
|
xit('should store the commands in the queue', function (done) {
|
|
224
225
|
iotAgentLib.setCommandHandler(function (id, type, service, subservice, attributes, callback) {
|
|
225
226
|
callback(null);
|
|
@@ -102,21 +102,22 @@ describe('NGSI-LD - Subscription tests', function () {
|
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
describe('When a client invokes the subscribe() function for device', function () {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
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
|
+
// });
|
|
116
117
|
it('should store the subscription ID in the Device Registry', function (done) {
|
|
117
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
118
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
118
119
|
iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
|
|
119
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
120
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
120
121
|
should.not.exist(error);
|
|
121
122
|
should.exist(device);
|
|
122
123
|
should.exist(device.subscriptions);
|
|
@@ -138,23 +139,24 @@ describe('NGSI-LD - Subscription tests', function () {
|
|
|
138
139
|
|
|
139
140
|
done();
|
|
140
141
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
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
|
+
// });
|
|
153
155
|
it('should remove the id from the subscriptions array', function (done) {
|
|
154
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
156
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
155
157
|
iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
|
|
156
158
|
iotAgentLib.unsubscribe(device, '51c0ac9ed714fb3b37d7d5a8', function (error) {
|
|
157
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
159
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
158
160
|
should.not.exist(error);
|
|
159
161
|
should.exist(device);
|
|
160
162
|
should.exist(device.subscriptions);
|
|
@@ -175,21 +177,21 @@ describe('NGSI-LD - Subscription tests', function () {
|
|
|
175
177
|
|
|
176
178
|
done();
|
|
177
179
|
});
|
|
178
|
-
|
|
179
|
-
it('should delete the subscription from the CB', function (done) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
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
|
+
// });
|
|
189
191
|
});
|
|
190
192
|
describe('When a new notification comes to the IoTAgent', function () {
|
|
191
193
|
beforeEach(function (done) {
|
|
192
|
-
iotAgentLib.getDevice('MicroLight1', 'smartgondor', '/gardens', function (error, device) {
|
|
194
|
+
iotAgentLib.getDevice('MicroLight1', null, 'smartgondor', '/gardens', function (error, device) {
|
|
193
195
|
iotAgentLib.subscribe(device, ['attr_name'], null, function (error) {
|
|
194
196
|
done();
|
|
195
197
|
});
|