iotagent-node-lib 4.5.0 → 4.7.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/.github/workflows/ci.yml +0 -1
- package/Changelog +12 -0
- package/README.md +67 -272
- package/config.js +3 -1
- package/doc/README.md +1 -1
- package/doc/admin.md +40 -18
- package/doc/api.md +532 -136
- package/doc/deprecated.md +4 -0
- package/doc/devel/architecture.md +5 -135
- package/doc/devel/development.md +224 -12
- package/doc/getting-started.md +114 -53
- package/doc/requirements.txt +1 -1
- package/doc/roadmap.md +5 -5
- package/docker/Mosquitto/Dockerfile +2 -2
- package/docker/Mosquitto/README.md +14 -11
- package/lib/commonConfig.js +21 -2
- package/lib/constants.js +3 -0
- package/lib/fiware-iotagent-lib.js +12 -15
- package/lib/jexlTranformsMap.js +3 -1
- package/lib/model/Command.js +2 -2
- package/lib/model/Device.js +7 -3
- package/lib/model/Group.js +5 -3
- package/lib/model/dbConn.js +53 -115
- package/lib/services/commands/commandRegistryMongoDB.js +115 -75
- package/lib/services/common/alarmManagement.js +3 -0
- package/lib/services/common/iotManagerService.js +3 -1
- package/lib/services/devices/deviceRegistryMemory.js +36 -0
- package/lib/services/devices/deviceRegistryMongoDB.js +160 -87
- package/lib/services/devices/deviceService.js +33 -3
- package/lib/services/devices/devices-NGSI-v2.js +6 -1
- package/lib/services/groups/groupRegistryMongoDB.js +120 -83
- package/lib/services/groups/groupService.js +1 -1
- package/lib/services/ngsi/entities-NGSI-LD.js +320 -570
- package/lib/services/ngsi/entities-NGSI-v2.js +51 -3
- package/lib/services/ngsi/ngsiService.js +34 -1
- package/lib/services/northBound/deviceGroupAdministrationServer.js +42 -6
- package/lib/services/northBound/deviceProvisioningServer.js +12 -4
- package/lib/services/northBound/northboundServer.js +2 -0
- package/lib/services/stats/statsRegistry.js +128 -101
- package/lib/templates/createDevice.json +0 -24
- package/lib/templates/createDeviceLax.json +0 -23
- package/lib/templates/deviceGroup.json +1 -25
- package/lib/templates/updateDevice.json +12 -24
- package/lib/templates/updateDeviceLax.json +12 -23
- package/package.json +5 -5
- package/scripts/legacy_expression_tool/README.md +0 -1
- package/test/functional/README.md +22 -17
- package/test/functional/config-test.js +3 -2
- package/test/functional/functional-tests-runner.js +9 -4
- package/test/functional/functional-tests.js +4 -4
- package/test/functional/testCases.js +245 -4
- package/test/functional/testUtils.js +2 -2
- package/test/unit/examples/deviceProvisioningRequests/provisionFullDevice.json +1 -13
- package/test/unit/examples/groupProvisioningRequests/multipleConfigGroupsCreation.json +44 -0
- package/test/unit/examples/groupProvisioningRequests/provisionDuplicateConfigGroup.json +35 -0
- package/test/unit/examples/groupProvisioningRequests/provisionFullConfigGroup.json +36 -0
- package/test/unit/examples/groupProvisioningRequests/provisionFullConfigGroupAlternate.json +36 -0
- package/test/unit/examples/groupProvisioningRequests/provisionFullGroup.json +1 -0
- package/test/unit/general/config-multi-core-test.js +1 -2
- package/test/unit/general/contextBrokerKeystoneSecurityAccess-test.js +5 -4
- package/test/unit/general/deviceService-test.js +106 -3
- package/test/unit/general/statistics-service_test.js +1 -74
- package/test/unit/memoryRegistry/deviceRegistryMemory_test.js +6 -5
- package/test/unit/mongodb/mongodb-configGroup-registry-test.js +452 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +9 -42
- package/test/unit/mongodb/mongodb-group-registry-test.js +34 -33
- package/test/unit/mongodb/mongodb-service-registry-test.js +477 -0
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin1a.json +4 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin2.json +22 -22
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin29.json +4 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextExpressionPlugin32.json +14 -15
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin1.json +23 -23
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin15.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin4.json +11 -16
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin5.json +23 -28
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin6.json +8 -13
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin7.json +0 -5
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityPlugin8.json +24 -29
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +12 -17
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextStaticLinkedAttributes.json +12 -10
- package/test/unit/ngsi-ld/expressions/jexlBasedTransformations-test.js +1 -104
- package/test/unit/ngsi-ld/general/config-jsonld-contexts-test.js +1 -2
- package/test/unit/ngsi-ld/plugins/multientity-plugin_test.js +4 -5
- package/test/unit/ngsi-ld/provisioning/listProvisionedDevices-test.js +0 -4
- package/test/unit/ngsi-mixed/provisioning/ngsi-versioning-test.js +8 -5
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +42 -41
- package/test/unit/ngsiv2/general/contextBrokerOAuthSecurityAccess-test.js +11 -10
- package/test/unit/ngsiv2/general/deviceService-test.js +98 -4
- package/test/unit/ngsiv2/general/https-support-test.js +1 -1
- package/test/unit/ngsiv2/general/iotam-autoregistration-test.js +195 -0
- package/test/unit/ngsiv2/lazyAndCommands/active-devices-attribute-update-test.js +4 -3
- package/test/unit/ngsiv2/lazyAndCommands/command-test.js +6 -5
- package/test/unit/ngsiv2/lazyAndCommands/lazy-devices-test.js +17 -16
- package/test/unit/ngsiv2/lazyAndCommands/polling-commands-test.js +10 -18
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +21 -20
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +8 -7
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +12 -11
- package/test/unit/ngsiv2/plugins/custom-plugin_test.js +3 -2
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +28 -27
- package/test/unit/ngsiv2/provisioning/device-group-api-test.js +265 -4
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +12 -11
- package/test/unit/ngsiv2/provisioning/device-provisioning-configGroup-api_test.js +1190 -0
- package/test/unit/ngsiv2/provisioning/device-registration_test.js +5 -4
- package/test/unit/ngsiv2/provisioning/listProvisionedDevices-test.js +6 -9
- package/test/unit/ngsiv2/provisioning/provisionDeviceMultientity-test.js +1 -1
- package/test/unit/ngsiv2/provisioning/removeProvisionedDevice-test.js +5 -4
- package/test/unit/ngsiv2/provisioning/updateProvisionedDevices-test.js +8 -7
- package/test/unit/statsRegistry/openmetrics-test.js +167 -0
- package/lib/templates/queryContext.json +0 -25
- package/test/unit/examples/deviceProvisioningRequests/provisionBidirectionalDevice.json +0 -35
- package/test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json +0 -17
- package/test/unit/examples/groupProvisioningRequests/bidirectionalGroup.json +0 -31
- package/test/unit/general/statistics-persistence_test.js +0 -121
- package/test/unit/ngsi-ld/examples/contextRequests/createBidirectionalDevice.json +0 -17
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextProcessTimestamp.json +0 -12
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotification.json +0 -13
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotificationWithDatasetId.json +0 -21
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json +0 -17
- package/test/unit/ngsi-ld/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -23
- package/test/unit/ngsi-ld/plugins/timestamp-processing-plugin_test.js +0 -132
- package/test/unit/ngsiv2/examples/contextRequests/createBidirectionalDevice.json +0 -8
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotification.json +0 -13
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalNotificationWithMetadata.json +0 -19
- package/test/unit/ngsiv2/examples/subscriptionRequests/bidirectionalSubscriptionRequest.json +0 -24
|
@@ -76,7 +76,8 @@ const iotAgentConfig = {
|
|
|
76
76
|
},
|
|
77
77
|
service: 'smartgondor',
|
|
78
78
|
subservice: 'gardens',
|
|
79
|
-
providerUrl: 'http://smartgondor.com'
|
|
79
|
+
providerUrl: 'http://smartgondor.com',
|
|
80
|
+
useCBflowControl: true
|
|
80
81
|
};
|
|
81
82
|
const device1 = {
|
|
82
83
|
id: 'light1',
|
|
@@ -215,7 +216,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
215
216
|
contextBrokerMock
|
|
216
217
|
.matchHeader('fiware-service', 'smartgondor')
|
|
217
218
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
218
|
-
.post('/v2/entities?options=upsert')
|
|
219
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
219
220
|
.reply(204);
|
|
220
221
|
|
|
221
222
|
iotAgentLib.activate(iotAgentConfig, function (error) {
|
|
@@ -321,7 +322,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
321
322
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
322
323
|
// device provisioning functionality. Appropriate verification is done in tests under
|
|
323
324
|
// provisioning folder
|
|
324
|
-
contextBrokerMock.post('/v2/entities?options=upsert').reply(204);
|
|
325
|
+
contextBrokerMock.post('/v2/entities?options=upsert,flowControl').reply(204);
|
|
325
326
|
|
|
326
327
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
327
328
|
.post('/v2/registrations')
|
|
@@ -330,7 +331,7 @@ describe('NGSI-v2 - IoT Agent Device Registration', function () {
|
|
|
330
331
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
331
332
|
// device provisioning functionality. Appropriate verification is done in tests under
|
|
332
333
|
// provisioning folder
|
|
333
|
-
contextBrokerMock.post('/v2/entities?options=upsert').reply(204);
|
|
334
|
+
contextBrokerMock.post('/v2/entities?options=upsert,flowControl').reply(204);
|
|
334
335
|
|
|
335
336
|
contextBrokerMock.delete('/v2/registrations/6319a7f5254b05844116584d', '').reply(500);
|
|
336
337
|
|
|
@@ -48,7 +48,8 @@ const iotAgentConfig = {
|
|
|
48
48
|
types: {},
|
|
49
49
|
service: 'smartgondor',
|
|
50
50
|
subservice: 'gardens',
|
|
51
|
-
providerUrl: 'http://smartgondor.com'
|
|
51
|
+
providerUrl: 'http://smartgondor.com',
|
|
52
|
+
useCBflowControl: true
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
describe('NGSI-v2 - Device provisioning API: List provisioned devices', function () {
|
|
@@ -96,7 +97,7 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function
|
|
|
96
97
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
97
98
|
// device provisioning functionality. Appropriate verification is done in tests under
|
|
98
99
|
// provisioning folder
|
|
99
|
-
contextBrokerMock.post('/v2/entities?options=upsert').reply(204);
|
|
100
|
+
contextBrokerMock.post('/v2/entities?options=upsert,flowControl').reply(204);
|
|
100
101
|
|
|
101
102
|
contextBrokerMock
|
|
102
103
|
.post('/v2/registrations')
|
|
@@ -105,7 +106,7 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function
|
|
|
105
106
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
106
107
|
// device provisioning functionality. Appropriate verification is done in tests under
|
|
107
108
|
// provisioning folder
|
|
108
|
-
contextBrokerMock.post('/v2/entities?options=upsert').reply(204);
|
|
109
|
+
contextBrokerMock.post('/v2/entities?options=upsert,flowControl').reply(204);
|
|
109
110
|
|
|
110
111
|
contextBrokerMock
|
|
111
112
|
.post('/v2/registrations')
|
|
@@ -114,7 +115,7 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function
|
|
|
114
115
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
115
116
|
// device provisioning functionality. Appropriate verification is done in tests under
|
|
116
117
|
// provisioning folder
|
|
117
|
-
contextBrokerMock.post('/v2/entities?options=upsert').reply(204);
|
|
118
|
+
contextBrokerMock.post('/v2/entities?options=upsert,flowControl').reply(204);
|
|
118
119
|
|
|
119
120
|
async.series(
|
|
120
121
|
[
|
|
@@ -183,11 +184,9 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function
|
|
|
183
184
|
should.exist(body.devices[2].attributes[0].entity_name);
|
|
184
185
|
should.exist(body.devices[2].attributes[0].entity_type);
|
|
185
186
|
should.exist(body.devices[2].attributes[1].expression);
|
|
186
|
-
should.exist(body.devices[2].attributes[2].reverse);
|
|
187
187
|
body.devices[2].attributes[0].entity_name.should.equal('Higro2000');
|
|
188
188
|
body.devices[2].attributes[0].entity_type.should.equal('Higrometer');
|
|
189
189
|
body.devices[2].attributes[1].expression.should.equal('${@humidity * 20}');
|
|
190
|
-
body.devices[2].attributes[2].reverse.length.should.equal(2);
|
|
191
190
|
done();
|
|
192
191
|
});
|
|
193
192
|
});
|
|
@@ -242,11 +241,9 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function
|
|
|
242
241
|
should.exist(body.attributes[0].entity_name);
|
|
243
242
|
should.exist(body.attributes[0].entity_type);
|
|
244
243
|
should.exist(body.attributes[1].expression);
|
|
245
|
-
should.exist(body.attributes[2].reverse);
|
|
246
244
|
body.attributes[0].entity_name.should.equal('Higro2000');
|
|
247
245
|
body.attributes[0].entity_type.should.equal('Higrometer');
|
|
248
246
|
body.attributes[1].expression.should.equal('${@humidity * 20}');
|
|
249
|
-
body.attributes[2].reverse.length.should.equal(2);
|
|
250
247
|
done();
|
|
251
248
|
});
|
|
252
249
|
});
|
|
@@ -312,7 +309,7 @@ describe('NGSI-v2 - Device provisioning API: List provisioned devices', function
|
|
|
312
309
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
313
310
|
// device provisioning functionality. Appropriate verification is done in tests under
|
|
314
311
|
// provisioning folder
|
|
315
|
-
contextBrokerMock.post('/v2/entities?options=upsert').times(10).reply(204);
|
|
312
|
+
contextBrokerMock.post('/v2/entities?options=upsert,flowControl').times(10).reply(204);
|
|
316
313
|
|
|
317
314
|
iotAgentLib.clearAll(function () {
|
|
318
315
|
async.times(10, createDeviceRequest, function (error, results) {
|
|
@@ -84,7 +84,7 @@ describe('NGSI-v2 - Device provisioning API: Provision devices', function () {
|
|
|
84
84
|
.matchHeader('fiware-service', 'smartgondor')
|
|
85
85
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
86
86
|
.post(
|
|
87
|
-
'/v2/entities?options=upsert',
|
|
87
|
+
'/v2/entities?options=upsert,flowControl',
|
|
88
88
|
utils.readExampleFile(
|
|
89
89
|
'./test/unit/ngsiv2/examples/contextRequests/createProvisionedDeviceMultientity.json'
|
|
90
90
|
)
|
|
@@ -48,7 +48,8 @@ const iotAgentConfig = {
|
|
|
48
48
|
types: {},
|
|
49
49
|
service: 'smartgondor',
|
|
50
50
|
subservice: 'gardens',
|
|
51
|
-
providerUrl: 'http://smartgondor.com'
|
|
51
|
+
providerUrl: 'http://smartgondor.com',
|
|
52
|
+
useCBflowControl: true
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', function () {
|
|
@@ -97,7 +98,7 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi
|
|
|
97
98
|
contextBrokerMock
|
|
98
99
|
.matchHeader('fiware-service', 'smartgondor')
|
|
99
100
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
100
|
-
.post('/v2/entities?options=upsert')
|
|
101
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
101
102
|
.reply(204);
|
|
102
103
|
|
|
103
104
|
const nockBody2 = utils.readExampleFile(
|
|
@@ -115,7 +116,7 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi
|
|
|
115
116
|
contextBrokerMock
|
|
116
117
|
.matchHeader('fiware-service', 'smartgondor')
|
|
117
118
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
118
|
-
.post('/v2/entities?options=upsert')
|
|
119
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
119
120
|
.reply(204);
|
|
120
121
|
|
|
121
122
|
contextBrokerMock
|
|
@@ -130,7 +131,7 @@ describe('NGSI-v2 - Device provisioning API: Remove provisioned devices', functi
|
|
|
130
131
|
contextBrokerMock
|
|
131
132
|
.matchHeader('fiware-service', 'smartgondor')
|
|
132
133
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
133
|
-
.post('/v2/entities?options=upsert')
|
|
134
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
134
135
|
.reply(204);
|
|
135
136
|
|
|
136
137
|
async.series(
|
|
@@ -48,7 +48,8 @@ const iotAgentConfig = {
|
|
|
48
48
|
types: {},
|
|
49
49
|
service: 'smartgondor',
|
|
50
50
|
subservice: 'gardens',
|
|
51
|
-
providerUrl: 'http://smartgondor.com'
|
|
51
|
+
providerUrl: 'http://smartgondor.com',
|
|
52
|
+
useCBflowControl: true
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
describe('NGSI-v2 - Device provisioning API: Update provisioned devices', function () {
|
|
@@ -107,7 +108,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi
|
|
|
107
108
|
contextBrokerMock
|
|
108
109
|
.matchHeader('fiware-service', 'smartgondor')
|
|
109
110
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
110
|
-
.post('/v2/entities?options=upsert')
|
|
111
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
111
112
|
.reply(204);
|
|
112
113
|
|
|
113
114
|
const nockBody2 = utils.readExampleFile(
|
|
@@ -126,7 +127,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi
|
|
|
126
127
|
contextBrokerMock
|
|
127
128
|
.matchHeader('fiware-service', 'smartgondor')
|
|
128
129
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
129
|
-
.post('/v2/entities?options=upsert')
|
|
130
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
130
131
|
.reply(204);
|
|
131
132
|
|
|
132
133
|
// FIXME: When https://github.com/telefonicaid/fiware-orion/issues/3007 is merged into master branch,
|
|
@@ -181,7 +182,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi
|
|
|
181
182
|
.matchHeader('fiware-service', 'smartgondor')
|
|
182
183
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
183
184
|
.post(
|
|
184
|
-
'/v2/entities?options=upsert',
|
|
185
|
+
'/v2/entities?options=upsert,flowControl',
|
|
185
186
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateProvisionDevice.json')
|
|
186
187
|
)
|
|
187
188
|
.reply(204);
|
|
@@ -374,7 +375,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi
|
|
|
374
375
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
375
376
|
.matchHeader('fiware-service', 'smartgondor')
|
|
376
377
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
377
|
-
.post('/v2/entities?options=upsert')
|
|
378
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
378
379
|
.reply(204);
|
|
379
380
|
|
|
380
381
|
contextBrokerMock
|
|
@@ -442,7 +443,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi
|
|
|
442
443
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
443
444
|
.matchHeader('fiware-service', 'smartgondor')
|
|
444
445
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
445
|
-
.post('/v2/entities?options=upsert')
|
|
446
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
446
447
|
.reply(204);
|
|
447
448
|
|
|
448
449
|
contextBrokerMock
|
|
@@ -504,7 +505,7 @@ describe('NGSI-v2 - Device provisioning API: Update provisioned devices', functi
|
|
|
504
505
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
505
506
|
.matchHeader('fiware-service', 'smartgondor')
|
|
506
507
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
507
|
-
.post('/v2/entities?options=upsert')
|
|
508
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
508
509
|
.reply(204);
|
|
509
510
|
|
|
510
511
|
async.series([iotAgentLib.clearAll, async.apply(request, provisioning4Options)], done);
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
|
|
24
|
+
/* eslint-disable no-unused-vars */
|
|
25
|
+
|
|
26
|
+
const statsRegistry = require('../../../lib/services/stats/statsRegistry');
|
|
27
|
+
const should = require('should');
|
|
28
|
+
|
|
29
|
+
describe('statsRegistry - openmetrics endpoint', function () {
|
|
30
|
+
|
|
31
|
+
const testCases = [
|
|
32
|
+
{
|
|
33
|
+
description: 'Should accept standard openmetrics 0.0.1 header',
|
|
34
|
+
accept: 'application/openmetrics-text; version=0.0.1; charset=utf-8',
|
|
35
|
+
contentType: {
|
|
36
|
+
mediaType: 'application/openmetrics-text',
|
|
37
|
+
version: '0.0.1',
|
|
38
|
+
charset: 'utf-8'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
description: 'Should accept standard openmetrics 1.0.0 header',
|
|
43
|
+
accept: 'application/openmetrics-text; version=1.0.0; charset=utf-8',
|
|
44
|
+
contentType: {
|
|
45
|
+
mediaType: 'application/openmetrics-text',
|
|
46
|
+
version: '1.0.0',
|
|
47
|
+
charset: 'utf-8'
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
description: 'Should accept openmetrics with no version',
|
|
52
|
+
accept: 'application/openmetrics-text',
|
|
53
|
+
contentType: {
|
|
54
|
+
mediaType: 'application/openmetrics-text',
|
|
55
|
+
version: '1.0.0',
|
|
56
|
+
charset: 'utf-8'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
description: 'Should accept text/plain header with version',
|
|
61
|
+
accept: 'text/plain; version=0.0.4',
|
|
62
|
+
contentType: {
|
|
63
|
+
mediaType: 'text/plain',
|
|
64
|
+
version: '0.0.4',
|
|
65
|
+
charset: 'utf-8'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
description: 'Should accept wildcard header',
|
|
70
|
+
accept: '*/*',
|
|
71
|
+
contentType: {
|
|
72
|
+
mediaType: 'text/plain',
|
|
73
|
+
version: '0.0.4',
|
|
74
|
+
charset: 'utf-8'
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
description: 'Should accept both openmetrics and text/plain, prefer openmetrics',
|
|
79
|
+
accept: 'application/openmetrics-text; version=0.0.1; charset=utf-8,text/plain;version=0.0.4',
|
|
80
|
+
contentType: {
|
|
81
|
+
mediaType: 'application/openmetrics-text',
|
|
82
|
+
version: '0.0.1',
|
|
83
|
+
charset: 'utf-8'
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
description: 'Should accept both text/plain and openmetrics, prefer openmetrics',
|
|
88
|
+
accept: 'text/plain,application/openmetrics-text; version=0.0.1; charset=utf-8',
|
|
89
|
+
contentType: {
|
|
90
|
+
mediaType: 'application/openmetrics-text',
|
|
91
|
+
version: '0.0.1',
|
|
92
|
+
charset: 'utf-8'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
description: 'Should accept both openmetrics and text/plain, prefer text if preference set',
|
|
97
|
+
accept: 'application/openmetrics-text; version=0.0.1; charset=utf-8;q=0.5,text/plain;q=0.7',
|
|
98
|
+
contentType: {
|
|
99
|
+
mediaType: 'text/plain',
|
|
100
|
+
version: '0.0.4',
|
|
101
|
+
charset: 'utf-8'
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
description: 'Should match version to content-type',
|
|
106
|
+
accept: 'application/openmetrics-text; version=0.0.1; charset=utf-8, text/plain;version=1.0.0',
|
|
107
|
+
contentType: {
|
|
108
|
+
mediaType: 'application/openmetrics-text',
|
|
109
|
+
version: '0.0.1',
|
|
110
|
+
charset: 'utf-8'
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
description: 'Should set default q to 1.0',
|
|
115
|
+
accept: 'application/openmetrics-text; version=0.0.1; q=0.5,text/plain;version=0.0.4',
|
|
116
|
+
contentType: {
|
|
117
|
+
mediaType: 'text/plain',
|
|
118
|
+
version: '0.0.4',
|
|
119
|
+
charset: 'utf-8'
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
description: 'Should accept mixture of content-types and q',
|
|
124
|
+
accept: 'application/openmetrics-text; version=0.0.1,text/plain;version=0.0.4;q=0.5,*/*;q=0.1',
|
|
125
|
+
contentType: {
|
|
126
|
+
mediaType: 'application/openmetrics-text',
|
|
127
|
+
version: '0.0.1',
|
|
128
|
+
charset: 'utf-8'
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
description: 'Should reject Invalid charset',
|
|
133
|
+
accept: '*/*; charset=utf-16',
|
|
134
|
+
contentType: null
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
description: 'Should reject Invalid openmetrics version',
|
|
138
|
+
accept: 'application/openmetrics-text; version=0.0.5',
|
|
139
|
+
contentType: null
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
description: 'Should reject Invalid text/plain',
|
|
143
|
+
accept: 'text/plain; version=0.0.2',
|
|
144
|
+
contentType: null
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
for (const testCase of testCases) {
|
|
149
|
+
describe(testCase.description, function () {
|
|
150
|
+
const result = statsRegistry.matchContentType(testCase.accept);
|
|
151
|
+
if (testCase.contentType) {
|
|
152
|
+
it('should match', function (done) {
|
|
153
|
+
should.exist(result);
|
|
154
|
+
result.mediaType.should.equal(testCase.contentType.mediaType);
|
|
155
|
+
result.version.should.equal(testCase.contentType.version);
|
|
156
|
+
result.charset.should.equal(testCase.contentType.charset);
|
|
157
|
+
done();
|
|
158
|
+
});
|
|
159
|
+
} else {
|
|
160
|
+
it('should not match', function (done) {
|
|
161
|
+
should.not.exist(result);
|
|
162
|
+
done();
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"properties": {
|
|
3
|
-
"entities": {
|
|
4
|
-
"description": "The objects the request is applied to.",
|
|
5
|
-
"type": "array",
|
|
6
|
-
"items": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"type": {
|
|
10
|
-
"type": "string",
|
|
11
|
-
"required": true
|
|
12
|
-
},
|
|
13
|
-
"isPattern": {
|
|
14
|
-
"type": "string"
|
|
15
|
-
},
|
|
16
|
-
"id": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"required": true
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"required": true
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"devices": [
|
|
3
|
-
{
|
|
4
|
-
"device_id": "Light1",
|
|
5
|
-
"protocol": "GENERIC_PROTO",
|
|
6
|
-
"entity_name": "TheFirstLight",
|
|
7
|
-
"entity_type": "TheLightType",
|
|
8
|
-
"timezone": "America/Santiago",
|
|
9
|
-
"endpoint": "http://fakedEndpoint:1234",
|
|
10
|
-
"transport": "MQTT",
|
|
11
|
-
"attributes": [
|
|
12
|
-
{
|
|
13
|
-
"name":"location",
|
|
14
|
-
"type":"geo:point",
|
|
15
|
-
"expression": "latitude,longitude",
|
|
16
|
-
"reverse": [
|
|
17
|
-
{
|
|
18
|
-
"object_id":"latitude",
|
|
19
|
-
"type": "Number",
|
|
20
|
-
"expression": "location | split(', ')[1] | parsefloat()"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"object_id":"longitude",
|
|
24
|
-
"type": "Number",
|
|
25
|
-
"expression": "location | split(', ')[0] | parsefloat()"
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
"lazy": [],
|
|
31
|
-
"static_attributes": [],
|
|
32
|
-
"commands": []
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
}
|
package/test/unit/examples/deviceProvisioningRequests/provisionDeviceBidirectionalGroup.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"devices": [
|
|
3
|
-
{
|
|
4
|
-
"device_id": "Light1",
|
|
5
|
-
"protocol": "GENERIC_PROTO",
|
|
6
|
-
"entity_name": "TheFirstLight",
|
|
7
|
-
"entity_type": "TheLightType",
|
|
8
|
-
"timezone": "America/Santiago",
|
|
9
|
-
"endpoint": "http://fakedEndpoint:1234",
|
|
10
|
-
"transport": "MQTT",
|
|
11
|
-
"attributes": [],
|
|
12
|
-
"lazy": [],
|
|
13
|
-
"static_attributes": [],
|
|
14
|
-
"commands": []
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"services": [
|
|
3
|
-
{
|
|
4
|
-
"resource": "/deviceTest",
|
|
5
|
-
"apikey": "801230BJKL23Y9090DSFL123HJK09H324HV8732",
|
|
6
|
-
"entity_type": "TheLightType",
|
|
7
|
-
"commands": [],
|
|
8
|
-
"lazy": [],
|
|
9
|
-
"attributes": [
|
|
10
|
-
{
|
|
11
|
-
"name":"location",
|
|
12
|
-
"type":"geo:point",
|
|
13
|
-
"expression": "${latitude}, ${longitude}",
|
|
14
|
-
"reverse": [
|
|
15
|
-
{
|
|
16
|
-
"object_id":"latitude",
|
|
17
|
-
"type": "Number",
|
|
18
|
-
"expression": "location | split(', ')[1] | parsefloat()"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"object_id":"longitude",
|
|
22
|
-
"type": "Number",
|
|
23
|
-
"expression": "location | split(', ')[0] | parsefloat()"
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
"static_attributes": []
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2014 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::[contacto@tid.es]
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/* eslint-disable no-unused-vars */
|
|
25
|
-
|
|
26
|
-
const statsService = require('../../../lib/services/stats/statsRegistry');
|
|
27
|
-
const commonConfig = require('../../../lib/commonConfig');
|
|
28
|
-
const iotAgentLib = require('../../../lib/fiware-iotagent-lib');
|
|
29
|
-
const should = require('should');
|
|
30
|
-
const async = require('async');
|
|
31
|
-
const mongoUtils = require('../mongodb/mongoDBUtils');
|
|
32
|
-
const iotAgentConfig = {
|
|
33
|
-
logLevel: 'FATAL',
|
|
34
|
-
contextBroker: {
|
|
35
|
-
host: '192.168.1.1',
|
|
36
|
-
port: '1026'
|
|
37
|
-
},
|
|
38
|
-
server: {
|
|
39
|
-
port: 4041,
|
|
40
|
-
host: 'localhost',
|
|
41
|
-
baseRoot: '/'
|
|
42
|
-
},
|
|
43
|
-
stats: {
|
|
44
|
-
interval: 50,
|
|
45
|
-
persistence: true
|
|
46
|
-
},
|
|
47
|
-
mongodb: {
|
|
48
|
-
host: 'localhost',
|
|
49
|
-
port: '27017',
|
|
50
|
-
db: 'iotagent'
|
|
51
|
-
},
|
|
52
|
-
types: {},
|
|
53
|
-
service: 'smartgondor',
|
|
54
|
-
subservice: 'gardens',
|
|
55
|
-
providerUrl: 'http://smartgondor.com',
|
|
56
|
-
deviceRegistrationDuration: 'P1M'
|
|
57
|
-
};
|
|
58
|
-
let iotAgentDb;
|
|
59
|
-
let oldConfig;
|
|
60
|
-
|
|
61
|
-
describe('Statistics persistence service', function () {
|
|
62
|
-
function insertDummy(n, callback) {
|
|
63
|
-
iotAgentDb.collection('tests').insertOne({ test: 'test' }, function () {
|
|
64
|
-
callback();
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
beforeEach(function (done) {
|
|
69
|
-
oldConfig = commonConfig.getConfig();
|
|
70
|
-
|
|
71
|
-
iotAgentLib.activate(iotAgentConfig, function (error) {
|
|
72
|
-
statsService.globalLoad({}, function () {
|
|
73
|
-
iotAgentDb = require('../../../lib/model/dbConn').db;
|
|
74
|
-
|
|
75
|
-
async.times(10, insertDummy, function () {
|
|
76
|
-
done();
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
afterEach(function (done) {
|
|
83
|
-
iotAgentLib.deactivate(function (error) {
|
|
84
|
-
commonConfig.setConfig(oldConfig);
|
|
85
|
-
statsService.globalLoad({}, function () {
|
|
86
|
-
mongoUtils.cleanDbs(done);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe('When a periodic persitence action is set', function () {
|
|
92
|
-
beforeEach(function (done) {
|
|
93
|
-
statsService.globalLoad(
|
|
94
|
-
{
|
|
95
|
-
stat1: 10
|
|
96
|
-
},
|
|
97
|
-
function () {
|
|
98
|
-
statsService.add('stat1', 5, done);
|
|
99
|
-
}
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('should store all the records in the database', function (done) {
|
|
104
|
-
statsService.addTimerAction(statsService.mongodbPersistence, function () {
|
|
105
|
-
setTimeout(function () {
|
|
106
|
-
statsService.clearTimers(function () {
|
|
107
|
-
iotAgentDb
|
|
108
|
-
.collection('kpis')
|
|
109
|
-
.find({})
|
|
110
|
-
.toArray(function (err, docs) {
|
|
111
|
-
should.not.exist(err);
|
|
112
|
-
should.exist(docs);
|
|
113
|
-
docs.length.should.be.above(2);
|
|
114
|
-
done();
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
}, 200);
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"@context": "http://context.json-ld",
|
|
4
|
-
"id": "urn:ngsi-ld:TheLightType:TheFirstLight",
|
|
5
|
-
"location": {
|
|
6
|
-
"type": "GeoProperty",
|
|
7
|
-
"value": {
|
|
8
|
-
"coordinates": [
|
|
9
|
-
0,
|
|
10
|
-
0
|
|
11
|
-
],
|
|
12
|
-
"type": "Point"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"type": "TheLightType"
|
|
16
|
-
}
|
|
17
|
-
]
|