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
|
@@ -126,7 +126,8 @@ const iotAgentConfig = {
|
|
|
126
126
|
},
|
|
127
127
|
service: 'smartgondor',
|
|
128
128
|
subservice: 'gardens',
|
|
129
|
-
providerUrl: 'http://smartgondor.com'
|
|
129
|
+
providerUrl: 'http://smartgondor.com',
|
|
130
|
+
useCBflowControl: true
|
|
130
131
|
};
|
|
131
132
|
const groupCreation = {
|
|
132
133
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/services',
|
|
@@ -156,6 +157,34 @@ const groupCreation = {
|
|
|
156
157
|
'fiware-servicepath': '/testingPath'
|
|
157
158
|
}
|
|
158
159
|
};
|
|
160
|
+
const configGroupCreation = {
|
|
161
|
+
url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/groups',
|
|
162
|
+
method: 'POST',
|
|
163
|
+
json: {
|
|
164
|
+
groups: [
|
|
165
|
+
{
|
|
166
|
+
resource: '',
|
|
167
|
+
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732',
|
|
168
|
+
entity_type: 'TheLightType',
|
|
169
|
+
trust: '8970A9078A803H3BL98PINEQRW8342HBAMS',
|
|
170
|
+
cbHost: 'http://192.168.1.1:1026',
|
|
171
|
+
commands: [],
|
|
172
|
+
lazy: [],
|
|
173
|
+
attributes: [
|
|
174
|
+
{
|
|
175
|
+
name: 'status',
|
|
176
|
+
type: 'Boolean'
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
static_attributes: []
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
headers: {
|
|
184
|
+
'fiware-service': 'testservice',
|
|
185
|
+
'fiware-servicepath': '/testingPath'
|
|
186
|
+
}
|
|
187
|
+
};
|
|
159
188
|
const deviceCreation = {
|
|
160
189
|
url: 'http://localhost:' + iotAgentConfig.server.port + '/iot/devices',
|
|
161
190
|
method: 'POST',
|
|
@@ -182,7 +211,7 @@ describe('NGSI-v2 - Device Service: utils', function () {
|
|
|
182
211
|
nock.cleanAll();
|
|
183
212
|
async.series([iotAgentLib.clearAll, iotAgentLib.deactivate], done);
|
|
184
213
|
});
|
|
185
|
-
|
|
214
|
+
// #FIXME1649: this test will be removed if at the end /iot/services API (now Deprecated) is removed
|
|
186
215
|
describe('When an existing device tries to be retrieved with retrieveOrCreate()', function () {
|
|
187
216
|
beforeEach(function (done) {
|
|
188
217
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
@@ -191,7 +220,7 @@ describe('NGSI-v2 - Device Service: utils', function () {
|
|
|
191
220
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
192
221
|
.matchHeader('fiware-service', 'testservice')
|
|
193
222
|
.matchHeader('fiware-servicepath', '/testingPath')
|
|
194
|
-
.post('/v2/entities?options=upsert')
|
|
223
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
195
224
|
.reply(204);
|
|
196
225
|
|
|
197
226
|
async.series(
|
|
@@ -212,7 +241,39 @@ describe('NGSI-v2 - Device Service: utils', function () {
|
|
|
212
241
|
});
|
|
213
242
|
});
|
|
214
243
|
});
|
|
244
|
+
describe('When an existing device tries to be retrieved with retrieveOrCreate()', function () {
|
|
245
|
+
beforeEach(function (done) {
|
|
246
|
+
// This mock does not check the payload since the aim of the test is not to verify
|
|
247
|
+
// device provisioning functionality. Appropriate verification is done in tests under
|
|
248
|
+
// provisioning folder
|
|
249
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
250
|
+
.matchHeader('fiware-service', 'testservice')
|
|
251
|
+
.matchHeader('fiware-servicepath', '/testingPath')
|
|
252
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
253
|
+
.reply(204);
|
|
254
|
+
|
|
255
|
+
async.series(
|
|
256
|
+
[
|
|
257
|
+
utils.request.bind(utils.request, configGroupCreation),
|
|
258
|
+
utils.request.bind(utils.request, deviceCreation)
|
|
259
|
+
],
|
|
260
|
+
function (error, results) {
|
|
261
|
+
done();
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('should return the existing device', function (done) {
|
|
267
|
+
iotAgentLib.retrieveDevice('Light1', '801230BJKL23Y9090DSFL123HJK09H324HV8732', function (error, device) {
|
|
268
|
+
should.not.exist(error);
|
|
269
|
+
should.exist(device);
|
|
215
270
|
|
|
271
|
+
device.id.should.equal('Light1');
|
|
272
|
+
done();
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
// #FIXME1649: this test will be removed if at the end /iot/services API (now Deprecated) is removed
|
|
216
277
|
describe('When an unexisting device tries to be retrieved for an existing APIKey', function () {
|
|
217
278
|
beforeEach(function (done) {
|
|
218
279
|
// This mock does not check the payload since the aim of the test is not to verify
|
|
@@ -221,7 +282,7 @@ describe('NGSI-v2 - Device Service: utils', function () {
|
|
|
221
282
|
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
222
283
|
.matchHeader('fiware-service', 'testservice')
|
|
223
284
|
.matchHeader('fiware-servicepath', '/testingPath')
|
|
224
|
-
.post('/v2/entities?options=upsert')
|
|
285
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
225
286
|
.reply(204);
|
|
226
287
|
|
|
227
288
|
async.series([utils.request.bind(utils.request, groupCreation)], function (error, results) {
|
|
@@ -246,6 +307,39 @@ describe('NGSI-v2 - Device Service: utils', function () {
|
|
|
246
307
|
});
|
|
247
308
|
});
|
|
248
309
|
|
|
310
|
+
describe('When an unexisting device tries to be retrieved for an existing APIKey', function () {
|
|
311
|
+
beforeEach(function (done) {
|
|
312
|
+
// This mock does not check the payload since the aim of the test is not to verify
|
|
313
|
+
// device provisioning functionality. Appropriate verification is done in tests under
|
|
314
|
+
// provisioning folder
|
|
315
|
+
contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
316
|
+
.matchHeader('fiware-service', 'testservice')
|
|
317
|
+
.matchHeader('fiware-servicepath', '/testingPath')
|
|
318
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
319
|
+
.reply(204);
|
|
320
|
+
|
|
321
|
+
async.series([utils.request.bind(utils.request, configGroupCreation)], function (error, results) {
|
|
322
|
+
done();
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it('should register the device and return it', function (done) {
|
|
327
|
+
iotAgentLib.retrieveDevice(
|
|
328
|
+
'UNEXISTENT_DEV',
|
|
329
|
+
'801230BJKL23Y9090DSFL123HJK09H324HV8732',
|
|
330
|
+
function (error, device) {
|
|
331
|
+
should.not.exist(error);
|
|
332
|
+
should.exist(device);
|
|
333
|
+
|
|
334
|
+
device.id.should.equal('UNEXISTENT_DEV');
|
|
335
|
+
should.exist(device.protocol);
|
|
336
|
+
device.protocol.should.equal('MQTT_UL');
|
|
337
|
+
done();
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
|
|
249
343
|
describe('When an unexisting device tries to be retrieved for an unexisting APIKey', function () {
|
|
250
344
|
it('should raise an error', function (done) {
|
|
251
345
|
iotAgentLib.retrieveDevice(
|
|
@@ -175,7 +175,7 @@ describe('NGSI-v2 - HTTPS support tests', function () {
|
|
|
175
175
|
.matchHeader('fiware-service', 'smartgondor')
|
|
176
176
|
.matchHeader('fiware-servicepath', '/gardens')
|
|
177
177
|
.post(
|
|
178
|
-
'/v2/entities?options=upsert',
|
|
178
|
+
'/v2/entities?options=upsert,flowControl',
|
|
179
179
|
utils.readExampleFile(
|
|
180
180
|
'./test/unit/ngsiv2/examples/contextRequests/createMinimumProvisionedDevice.json'
|
|
181
181
|
)
|
|
@@ -134,6 +134,43 @@ const optionsCreation = {
|
|
|
134
134
|
'fiware-servicepath': 'theSubService'
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
+
const configGroupCreation = {
|
|
138
|
+
url: 'http://localhost:4041/iot/groups',
|
|
139
|
+
method: 'POST',
|
|
140
|
+
json: {
|
|
141
|
+
groups: [
|
|
142
|
+
{
|
|
143
|
+
resource: '/deviceTest',
|
|
144
|
+
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732',
|
|
145
|
+
entity_type: 'SensorMachine',
|
|
146
|
+
trust: '8970A9078A803H3BL98PINEQRW8342HBAMS',
|
|
147
|
+
cbHost: 'http://unexistentHost:1026',
|
|
148
|
+
commands: [
|
|
149
|
+
{
|
|
150
|
+
name: 'wheel1',
|
|
151
|
+
type: 'Wheel'
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
lazy: [
|
|
155
|
+
{
|
|
156
|
+
name: 'luminescence',
|
|
157
|
+
type: 'Lumens'
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
attributes: [
|
|
161
|
+
{
|
|
162
|
+
name: 'status',
|
|
163
|
+
type: 'Boolean'
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
headers: {
|
|
170
|
+
'fiware-service': 'theservice',
|
|
171
|
+
'fiware-servicepath': 'theSubService'
|
|
172
|
+
}
|
|
173
|
+
};
|
|
137
174
|
const optionsCreationStatic = {
|
|
138
175
|
url: 'http://localhost:4041/iot/services',
|
|
139
176
|
method: 'POST',
|
|
@@ -172,6 +209,44 @@ const optionsCreationStatic = {
|
|
|
172
209
|
'fiware-servicepath': 'theSubService'
|
|
173
210
|
}
|
|
174
211
|
};
|
|
212
|
+
const configGroupCreationStatic = {
|
|
213
|
+
url: 'http://localhost:4041/iot/groups',
|
|
214
|
+
method: 'POST',
|
|
215
|
+
json: {
|
|
216
|
+
groups: [
|
|
217
|
+
{
|
|
218
|
+
resource: '/deviceTest',
|
|
219
|
+
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732',
|
|
220
|
+
entity_type: 'SensorMachine',
|
|
221
|
+
trust: '8970A9078A803H3BL98PINEQRW8342HBAMS',
|
|
222
|
+
cbHost: 'http://unexistentHost:1026',
|
|
223
|
+
commands: [
|
|
224
|
+
{
|
|
225
|
+
name: 'wheel1',
|
|
226
|
+
type: 'Wheel'
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
static_attributes: [
|
|
230
|
+
{
|
|
231
|
+
name: 'position',
|
|
232
|
+
type: 'location',
|
|
233
|
+
values: '123,12'
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
attributes: [
|
|
237
|
+
{
|
|
238
|
+
name: 'status',
|
|
239
|
+
type: 'Boolean'
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
},
|
|
245
|
+
headers: {
|
|
246
|
+
'fiware-service': 'theservice',
|
|
247
|
+
'fiware-servicepath': 'theSubService'
|
|
248
|
+
}
|
|
249
|
+
};
|
|
175
250
|
const optionsDelete = {
|
|
176
251
|
url: 'http://localhost:4041/iot/services',
|
|
177
252
|
method: 'DELETE',
|
|
@@ -185,6 +260,19 @@ const optionsDelete = {
|
|
|
185
260
|
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732'
|
|
186
261
|
}
|
|
187
262
|
};
|
|
263
|
+
const configGroupDelete = {
|
|
264
|
+
url: 'http://localhost:4041/iot/groups',
|
|
265
|
+
method: 'DELETE',
|
|
266
|
+
json: {},
|
|
267
|
+
headers: {
|
|
268
|
+
'fiware-service': 'theservice',
|
|
269
|
+
'fiware-servicepath': 'theSubService'
|
|
270
|
+
},
|
|
271
|
+
qs: {
|
|
272
|
+
resource: '/deviceTest',
|
|
273
|
+
apikey: '801230BJKL23Y9090DSFL123HJK09H324HV8732'
|
|
274
|
+
}
|
|
275
|
+
};
|
|
188
276
|
let iotamMock;
|
|
189
277
|
|
|
190
278
|
describe('NGSI-v2 - IoT Manager autoregistration', function () {
|
|
@@ -263,6 +351,7 @@ describe('NGSI-v2 - IoT Manager autoregistration', function () {
|
|
|
263
351
|
});
|
|
264
352
|
});
|
|
265
353
|
|
|
354
|
+
// #FIXME1649: this test will be removed if at the end /iot/services API (now Deprecated) is removed
|
|
266
355
|
describe('When a new service is created in the IoT Agent', function () {
|
|
267
356
|
beforeEach(function (done) {
|
|
268
357
|
nock.cleanAll();
|
|
@@ -298,6 +387,42 @@ describe('NGSI-v2 - IoT Manager autoregistration', function () {
|
|
|
298
387
|
});
|
|
299
388
|
});
|
|
300
389
|
|
|
390
|
+
describe('When a new configGroup is created in the IoT Agent', function () {
|
|
391
|
+
beforeEach(function (done) {
|
|
392
|
+
nock.cleanAll();
|
|
393
|
+
|
|
394
|
+
iotamMock = nock('http://mockediotam.com:9876')
|
|
395
|
+
.post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json'))
|
|
396
|
+
.reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json'));
|
|
397
|
+
|
|
398
|
+
iotamMock
|
|
399
|
+
.post(
|
|
400
|
+
'/protocols',
|
|
401
|
+
utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json')
|
|
402
|
+
)
|
|
403
|
+
.reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json'));
|
|
404
|
+
|
|
405
|
+
iotAgentLib.activate(iotAgentConfig, function (error) {
|
|
406
|
+
done();
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
afterEach(function (done) {
|
|
411
|
+
groupRegistryMemory.clear(function () {
|
|
412
|
+
iotAgentLib.deactivate(done);
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it('should update the registration in the IoT Manager', function (done) {
|
|
417
|
+
request(configGroupCreation, function (error, result, body) {
|
|
418
|
+
should.not.exist(error);
|
|
419
|
+
iotamMock.done();
|
|
420
|
+
done();
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// #FIXME1649: this test will be removed if at the end /iot/services API (now Deprecated) is removed
|
|
301
426
|
describe('When a service is removed from the IoT Agent', function () {
|
|
302
427
|
beforeEach(function (done) {
|
|
303
428
|
nock.cleanAll();
|
|
@@ -333,6 +458,42 @@ describe('NGSI-v2 - IoT Manager autoregistration', function () {
|
|
|
333
458
|
});
|
|
334
459
|
});
|
|
335
460
|
|
|
461
|
+
describe('When a configGroup is removed from the IoT Agent', function () {
|
|
462
|
+
beforeEach(function (done) {
|
|
463
|
+
nock.cleanAll();
|
|
464
|
+
|
|
465
|
+
iotamMock = nock('http://mockediotam.com:9876')
|
|
466
|
+
.post(
|
|
467
|
+
'/protocols',
|
|
468
|
+
utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithGroups.json')
|
|
469
|
+
)
|
|
470
|
+
.reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json'));
|
|
471
|
+
|
|
472
|
+
iotamMock
|
|
473
|
+
.post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json'))
|
|
474
|
+
.reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json'));
|
|
475
|
+
|
|
476
|
+
groupRegistryMemory.create(groupCreation, function () {
|
|
477
|
+
iotAgentLib.activate(iotAgentConfig, done);
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
afterEach(function (done) {
|
|
482
|
+
groupRegistryMemory.clear(function () {
|
|
483
|
+
iotAgentLib.deactivate(done);
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
it('should update the registration in the IoT Manager', function (done) {
|
|
488
|
+
request(configGroupDelete, function (error, result, body) {
|
|
489
|
+
should.not.exist(error);
|
|
490
|
+
iotamMock.done();
|
|
491
|
+
done();
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
// #FIXME1649: this test will be removed if at the end /iot/services API (now Deprecated) is removed
|
|
336
497
|
describe('When a new service with static attributes is created in the IoT Agent', function () {
|
|
337
498
|
beforeEach(function (done) {
|
|
338
499
|
nock.cleanAll();
|
|
@@ -367,4 +528,38 @@ describe('NGSI-v2 - IoT Manager autoregistration', function () {
|
|
|
367
528
|
});
|
|
368
529
|
});
|
|
369
530
|
});
|
|
531
|
+
describe('When a new configGroup with static attributes is created in the IoT Agent', function () {
|
|
532
|
+
beforeEach(function (done) {
|
|
533
|
+
nock.cleanAll();
|
|
534
|
+
|
|
535
|
+
iotamMock = nock('http://mockediotam.com:9876')
|
|
536
|
+
.post('/protocols', utils.readExampleFile('./test/unit/examples/iotamRequests/registrationEmpty.json'))
|
|
537
|
+
.reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json'));
|
|
538
|
+
|
|
539
|
+
iotamMock
|
|
540
|
+
.post(
|
|
541
|
+
'/protocols',
|
|
542
|
+
utils.readExampleFile('./test/unit/examples/iotamRequests/registrationWithStaticGroups.json')
|
|
543
|
+
)
|
|
544
|
+
.reply(200, utils.readExampleFile('./test/unit/examples/iotamResponses/registrationSuccess.json'));
|
|
545
|
+
|
|
546
|
+
iotAgentLib.activate(iotAgentConfig, function (error) {
|
|
547
|
+
done();
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
afterEach(function (done) {
|
|
552
|
+
groupRegistryMemory.clear(function () {
|
|
553
|
+
iotAgentLib.deactivate(done);
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
it('should update the registration in the IoT Manager', function (done) {
|
|
558
|
+
request(configGroupCreationStatic, function (error, result, body) {
|
|
559
|
+
should.not.exist(error);
|
|
560
|
+
iotamMock.done();
|
|
561
|
+
done();
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
});
|
|
370
565
|
});
|
|
@@ -58,7 +58,8 @@ const iotAgentConfig = {
|
|
|
58
58
|
},
|
|
59
59
|
service: 'smartgondor',
|
|
60
60
|
subservice: 'gardens',
|
|
61
|
-
providerUrl: 'http://smartgondor.com'
|
|
61
|
+
providerUrl: 'http://smartgondor.com',
|
|
62
|
+
useCBflowControl: true
|
|
62
63
|
};
|
|
63
64
|
const device = {
|
|
64
65
|
id: 'somelight',
|
|
@@ -82,7 +83,7 @@ describe('NGSI-v2 - Update attribute functionalities', function () {
|
|
|
82
83
|
contextBrokerMock
|
|
83
84
|
.matchHeader('fiware-service', 'smartgondor')
|
|
84
85
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
85
|
-
.post('/v2/entities?options=upsert')
|
|
86
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
86
87
|
.reply(204);
|
|
87
88
|
|
|
88
89
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -103,7 +104,7 @@ describe('NGSI-v2 - Update attribute functionalities', function () {
|
|
|
103
104
|
|
|
104
105
|
describe('When a attribute update arrives to the IoT Agent as Context Provider', function () {
|
|
105
106
|
const options = {
|
|
106
|
-
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update',
|
|
107
|
+
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl',
|
|
107
108
|
method: 'POST',
|
|
108
109
|
json: {
|
|
109
110
|
actionType: 'update',
|
|
@@ -103,7 +103,8 @@ const iotAgentConfig = {
|
|
|
103
103
|
},
|
|
104
104
|
service: 'smartgondor',
|
|
105
105
|
subservice: 'gardens',
|
|
106
|
-
providerUrl: 'http://smartgondor.com'
|
|
106
|
+
providerUrl: 'http://smartgondor.com',
|
|
107
|
+
useCBflowControl: true
|
|
107
108
|
};
|
|
108
109
|
const device3 = {
|
|
109
110
|
id: 'r2d2',
|
|
@@ -159,7 +160,7 @@ describe('NGSI-v2 - Command functionalities', function () {
|
|
|
159
160
|
});
|
|
160
161
|
describe('When a command update arrives to the IoT Agent as Context Provider', function () {
|
|
161
162
|
const options = {
|
|
162
|
-
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update',
|
|
163
|
+
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl',
|
|
163
164
|
method: 'POST',
|
|
164
165
|
json: {
|
|
165
166
|
actionType: 'update',
|
|
@@ -264,7 +265,7 @@ describe('NGSI-v2 - Command functionalities', function () {
|
|
|
264
265
|
.matchHeader('fiware-service', 'smartgondor')
|
|
265
266
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
266
267
|
.post(
|
|
267
|
-
'/v2/entities?options=upsert',
|
|
268
|
+
'/v2/entities?options=upsert,flowControl',
|
|
268
269
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandFinish.json')
|
|
269
270
|
)
|
|
270
271
|
.reply(204);
|
|
@@ -288,7 +289,7 @@ describe('NGSI-v2 - Command functionalities', function () {
|
|
|
288
289
|
.matchHeader('fiware-service', 'smartgondor')
|
|
289
290
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
290
291
|
.post(
|
|
291
|
-
'/v2/entities?options=upsert',
|
|
292
|
+
'/v2/entities?options=upsert,flowControl',
|
|
292
293
|
utils.readExampleFile('./test/unit/ngsiv2/examples/contextRequests/updateContextCommandError.json')
|
|
293
294
|
)
|
|
294
295
|
.reply(204);
|
|
@@ -309,7 +310,7 @@ describe('NGSI-v2 - Command functionalities', function () {
|
|
|
309
310
|
|
|
310
311
|
describe('When a command update with metadata arrives to the IoT Agent as Context Provider', function () {
|
|
311
312
|
const options = {
|
|
312
|
-
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update',
|
|
313
|
+
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl',
|
|
313
314
|
method: 'POST',
|
|
314
315
|
json: {
|
|
315
316
|
actionType: 'update',
|
|
@@ -114,7 +114,8 @@ const iotAgentConfig = {
|
|
|
114
114
|
},
|
|
115
115
|
service: 'smartgondor',
|
|
116
116
|
subservice: 'gardens',
|
|
117
|
-
providerUrl: 'http://smartgondor.com'
|
|
117
|
+
providerUrl: 'http://smartgondor.com',
|
|
118
|
+
useCBflowControl: true
|
|
118
119
|
};
|
|
119
120
|
const device1 = {
|
|
120
121
|
id: 'light1',
|
|
@@ -170,7 +171,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
170
171
|
|
|
171
172
|
describe('When the IoT Agent receives an update on the device data in JSON format', function () {
|
|
172
173
|
const options = {
|
|
173
|
-
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update',
|
|
174
|
+
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl',
|
|
174
175
|
method: 'POST',
|
|
175
176
|
json: {
|
|
176
177
|
actionType: 'update',
|
|
@@ -208,7 +209,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
208
209
|
contextBrokerMock
|
|
209
210
|
.matchHeader('fiware-service', 'smartgondor')
|
|
210
211
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
211
|
-
.post('/v2/entities?options=upsert')
|
|
212
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
212
213
|
.reply(204);
|
|
213
214
|
|
|
214
215
|
async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done);
|
|
@@ -279,7 +280,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
279
280
|
contextBrokerMock
|
|
280
281
|
.matchHeader('fiware-service', 'smartgondor')
|
|
281
282
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
282
|
-
.post('/v2/entities?options=upsert')
|
|
283
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
283
284
|
.reply(204);
|
|
284
285
|
|
|
285
286
|
async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done);
|
|
@@ -341,7 +342,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
341
342
|
contextBrokerMock
|
|
342
343
|
.matchHeader('fiware-service', 'smartgondor')
|
|
343
344
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
344
|
-
.post('/v2/entities?options=upsert')
|
|
345
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
345
346
|
.reply(204);
|
|
346
347
|
|
|
347
348
|
async.series(
|
|
@@ -414,7 +415,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
414
415
|
contextBrokerMock
|
|
415
416
|
.matchHeader('fiware-service', 'smartgondor')
|
|
416
417
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
417
|
-
.post('/v2/entities?options=upsert')
|
|
418
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
418
419
|
.reply(204);
|
|
419
420
|
|
|
420
421
|
async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done);
|
|
@@ -485,7 +486,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
485
486
|
contextBrokerMock
|
|
486
487
|
.matchHeader('fiware-service', 'smartgondor')
|
|
487
488
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
488
|
-
.post('/v2/entities?options=upsert')
|
|
489
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
489
490
|
.reply(204);
|
|
490
491
|
|
|
491
492
|
async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device2)], done);
|
|
@@ -517,7 +518,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
517
518
|
'internalAttributes',
|
|
518
519
|
function () {
|
|
519
520
|
const options = {
|
|
520
|
-
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update',
|
|
521
|
+
url: 'http://localhost:' + iotAgentConfig.server.port + '/v2/op/update?options=flowControl',
|
|
521
522
|
method: 'POST',
|
|
522
523
|
json: {
|
|
523
524
|
actionType: 'update',
|
|
@@ -555,7 +556,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
555
556
|
contextBrokerMock
|
|
556
557
|
.matchHeader('fiware-service', 'smartgondor')
|
|
557
558
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
558
|
-
.post('/v2/entities?options=upsert')
|
|
559
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
559
560
|
.reply(204);
|
|
560
561
|
|
|
561
562
|
async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device3)], done);
|
|
@@ -634,7 +635,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
634
635
|
contextBrokerMock
|
|
635
636
|
.matchHeader('fiware-service', 'smartgondor')
|
|
636
637
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
637
|
-
.post('/v2/entities?options=upsert')
|
|
638
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
638
639
|
.times(3)
|
|
639
640
|
.reply(204);
|
|
640
641
|
|
|
@@ -717,7 +718,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
717
718
|
contextBrokerMock
|
|
718
719
|
.matchHeader('fiware-service', 'smartgondor')
|
|
719
720
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
720
|
-
.post('/v2/entities?options=upsert')
|
|
721
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
721
722
|
.times(3)
|
|
722
723
|
.reply(204);
|
|
723
724
|
|
|
@@ -789,7 +790,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
789
790
|
contextBrokerMock
|
|
790
791
|
.matchHeader('fiware-service', 'smartgondor')
|
|
791
792
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
792
|
-
.post('/v2/entities?options=upsert')
|
|
793
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
793
794
|
.reply(204);
|
|
794
795
|
|
|
795
796
|
async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done);
|
|
@@ -852,7 +853,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
852
853
|
contextBrokerMock
|
|
853
854
|
.matchHeader('fiware-service', 'smartgondor')
|
|
854
855
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
855
|
-
.post('/v2/entities?options=upsert')
|
|
856
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
856
857
|
.reply(204);
|
|
857
858
|
|
|
858
859
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -917,7 +918,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
917
918
|
contextBrokerMock
|
|
918
919
|
.matchHeader('fiware-service', 'smartgondor')
|
|
919
920
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
920
|
-
.post('/v2/entities?options=upsert')
|
|
921
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
921
922
|
.reply(204);
|
|
922
923
|
|
|
923
924
|
iotAgentLib.activate(iotAgentConfig, done);
|
|
@@ -984,7 +985,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
984
985
|
contextBrokerMock
|
|
985
986
|
.matchHeader('fiware-service', 'smartgondor')
|
|
986
987
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
987
|
-
.post('/v2/entities?options=upsert')
|
|
988
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
988
989
|
.reply(204);
|
|
989
990
|
|
|
990
991
|
async.series([apply(iotAgentLib.activate, iotAgentConfig), apply(iotAgentLib.register, device1)], done);
|
|
@@ -1052,7 +1053,7 @@ describe('NGSI-v2 - IoT Agent Lazy Devices', function () {
|
|
|
1052
1053
|
contextBrokerMock
|
|
1053
1054
|
.matchHeader('fiware-service', 'smartgondor')
|
|
1054
1055
|
.matchHeader('fiware-servicepath', 'gardens')
|
|
1055
|
-
.post('/v2/entities?options=upsert')
|
|
1056
|
+
.post('/v2/entities?options=upsert,flowControl')
|
|
1056
1057
|
.reply(204);
|
|
1057
1058
|
|
|
1058
1059
|
iotAgentLib.activate(iotAgentConfig, done);
|