iotagent-node-lib 3.4.4 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/doc/admin.md +1 -13
- package/doc/api.md +116 -18
- package/doc/devel/architecture.md +0 -12
- package/doc/index.md +1 -1
- package/doc/roadmap.md +22 -10
- package/lib/commonConfig.js +0 -11
- package/lib/errors.js +2 -2
- package/lib/model/Device.js +2 -1
- package/lib/model/Group.js +2 -1
- package/lib/model/dbConn.js +22 -11
- package/lib/plugins/expressionPlugin.js +0 -5
- package/lib/plugins/jexlParser.js +15 -31
- package/lib/services/common/genericMiddleware.js +14 -2
- package/lib/services/common/iotManagerService.js +2 -1
- package/lib/services/devices/deviceRegistryMongoDB.js +3 -1
- package/lib/services/devices/deviceService.js +16 -21
- package/lib/services/devices/devices-NGSI-LD.js +5 -98
- package/lib/services/devices/devices-NGSI-mixed.js +0 -14
- package/lib/services/devices/devices-NGSI-v2.js +3 -0
- package/lib/services/groups/groupRegistryMemory.js +0 -25
- package/lib/services/groups/groupRegistryMongoDB.js +20 -19
- package/lib/services/groups/groupService.js +3 -14
- package/lib/services/ngsi/entities-NGSI-LD.js +82 -7
- package/lib/services/ngsi/entities-NGSI-v2.js +297 -696
- package/lib/services/ngsi/ngsiUtils.js +0 -30
- package/lib/services/northBound/deviceProvisioningServer.js +6 -3
- package/lib/templates/createDevice.json +4 -0
- package/lib/templates/createDeviceLax.json +4 -0
- package/lib/templates/deviceGroup.json +4 -0
- package/lib/templates/updateDevice.json +4 -0
- package/lib/templates/updateDeviceLax.json +4 -0
- package/package.json +6 -2
- package/test/functional/README.md +378 -0
- package/test/functional/config-test.js +70 -0
- package/test/functional/functional-tests-runner.js +126 -0
- package/test/functional/functional-tests.js +241 -0
- package/test/functional/testCases.js +2944 -0
- package/test/functional/testUtils.js +251 -0
- package/test/tools/utils.js +25 -0
- package/test/unit/mongodb/mongodb-connectionoptions-test.js +35 -22
- package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json +3 -34
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin6.json +8 -1
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin7.json +1 -4
- package/test/unit/ngsi-ld/examples/contextRequests/updateContextAliasPlugin8.json +1 -6
- package/test/unit/ngsi-ld/general/contextBrokerOAuthSecurityAccess-test.js +67 -87
- package/test/unit/ngsi-ld/lazyAndCommands/command-test.js +7 -13
- package/test/unit/ngsi-ld/lazyAndCommands/merge-patch-test.js +43 -43
- package/test/unit/ngsi-ld/lazyAndCommands/polling-commands-test.js +19 -29
- package/test/unit/ngsi-ld/ngsiService/languageProperties-test.js +0 -1
- package/test/unit/ngsi-ld/ngsiService/subscriptions-test.js +35 -46
- package/test/unit/ngsi-ld/plugins/alias-plugin_test.js +8 -9
- package/test/unit/ngsi-ld/provisioning/device-provisioning-api_test.js +96 -221
- package/test/unit/ngsi-ld/provisioning/device-registration_test.js +18 -27
- package/test/unit/ngsi-ld/provisioning/device-update-registration_test.js +8 -16
- package/test/unit/ngsi-ld/provisioning/updateProvisionedDevices-test.js +0 -13
- package/test/unit/ngsiv2/examples/contextRequests/updateContextAliasPlugin8.json +4 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin29b.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin30.json +1 -1
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin32.json +0 -6
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin34b.json +14 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin35.json +1 -11
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin36b.json +13 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin37.json +8 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextExpressionPlugin41.json +1 -11
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin10b.json +37 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin11.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin15.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin16.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin25.json +4 -0
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin4.json +0 -3
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin5.json +10 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin6.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin7.json +1 -5
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityPlugin8.json +8 -12
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin2.json +0 -4
- package/test/unit/ngsiv2/examples/contextRequests/updateContextMultientityTimestampPlugin3.json +0 -8
- package/test/unit/ngsiv2/examples/contextRequests/updateContextStaticAttributesMetadata.json +7 -1
- package/test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js +898 -28
- package/test/unit/ngsiv2/ngsiService/active-devices-test.js +0 -4
- package/test/unit/ngsiv2/ngsiService/staticAttributes-test.js +267 -0
- package/test/unit/ngsiv2/plugins/alias-plugin_test.js +19 -21
- package/test/unit/ngsiv2/plugins/multientity-plugin_test.js +21 -24
- package/test/unit/ngsiv2/provisioning/device-group-utils-test.js +1 -21
- package/test/unit/ngsiv2/provisioning/device-provisioning-api_test.js +4 -6
- package/CHANGES_NEXT_RELEASE +0 -0
- package/test/unit/ngsi-ld/ngsiService/autocast-test.js +0 -438
- package/test/unit/ngsi-ld/ngsiService/geoproperties-test.js +0 -381
- package/test/unit/ngsi-ld/provisioning/singleConfigurationMode-test.js +0 -311
- package/test/unit/ngsiv2/ngsiService/autocast-test.js +0 -325
- package/test/unit/ngsiv2/ngsiService/geoproperties-test.js +0 -427
- package/test/unit/ngsiv2/plugins/compress-timestamp-plugin_test.js +0 -217
- package/test/unit/ngsiv2/plugins/timestamp-processing-plugin_test.js +0 -119
- package/test/unit/ngsiv2/provisioning/singleConfigurationMode-test.js +0 -309
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Telefonica Investigación y Desarrollo, S.A.U
|
|
3
|
+
*
|
|
4
|
+
* This file is part of iotagent-json
|
|
5
|
+
*
|
|
6
|
+
* iotagent-json 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
|
+
* iotagent-json 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 iotagent-json.
|
|
18
|
+
* If not, seehttp://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
|
+
* Modified by: Miguel Angel Pedraza
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/* eslint-disable no-unused-vars*/
|
|
27
|
+
/* eslint-disable no-unused-expressions*/
|
|
28
|
+
|
|
29
|
+
const nock = require('nock');
|
|
30
|
+
const utils = require('../tools/utils');
|
|
31
|
+
const request = utils.request;
|
|
32
|
+
const async = require('async');
|
|
33
|
+
const chai = require('chai');
|
|
34
|
+
const MQTT = require('async-mqtt');
|
|
35
|
+
const iotAgentLib = require('../../lib/fiware-iotagent-lib');
|
|
36
|
+
|
|
37
|
+
var chaiMatchPattern = require('chai-match-pattern');
|
|
38
|
+
chai.use(chaiMatchPattern);
|
|
39
|
+
var _ = chaiMatchPattern.getLodashModule();
|
|
40
|
+
var expect = chai.expect;
|
|
41
|
+
chai.config.truncateThreshold = 0;
|
|
42
|
+
|
|
43
|
+
// Error messages
|
|
44
|
+
const ERR_CB_EXPECTATION_DIFFER = 'Assertion Error - Context Broker received payload differs from expectation';
|
|
45
|
+
const ERR_MEAS_BODY = 'Assertion Error - Measure response is not empty';
|
|
46
|
+
const ERR_MEAS_CODE = 'Assertion Error - Measure response status code differs from 200';
|
|
47
|
+
const ERR_MQTT = 'Error with MQTT: ';
|
|
48
|
+
const ERR_CB_NOT_EMPTY = 'Assertion Error - unexpected Context Broker request received (no request expected)';
|
|
49
|
+
const DEF_TYPE = 'TestType';
|
|
50
|
+
/**
|
|
51
|
+
* @brief Sends a measure to the IoT Agent and returns a promise with the response
|
|
52
|
+
*
|
|
53
|
+
* @param {Object} measure Measure to be sent to the IoT Agent
|
|
54
|
+
*/
|
|
55
|
+
function sendMeasureHttp(measure) {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
request(measure, function (error, result, body) {
|
|
58
|
+
error ? reject(error) : resolve(result);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @brief Sends a measure to the IoT Agent and returns a promise with the response
|
|
65
|
+
*
|
|
66
|
+
* @param {Object} measure Measure to be sent to the IoT Agent
|
|
67
|
+
*/
|
|
68
|
+
function sendMeasureIotaLib(measure, provision) {
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
/**
|
|
71
|
+
* WARNING: This is kind of a hack, only required for the tests using Lib, since the method iotAgentLib.update
|
|
72
|
+
* requires a type and does not check the type of the group. For this purpose, this function uses the
|
|
73
|
+
* provision type, setting the measure type to the same type as the provision.
|
|
74
|
+
* This is not a problem for the tests using other transports than Lib, in that case, the type will be retrieved
|
|
75
|
+
* from the real provision.
|
|
76
|
+
*/
|
|
77
|
+
let type;
|
|
78
|
+
if (Array.isArray(provision.json.services) && provision.json.services.length > 0) {
|
|
79
|
+
type = provision.json.services[0].entity_type;
|
|
80
|
+
} else {
|
|
81
|
+
type = DEF_TYPE;
|
|
82
|
+
}
|
|
83
|
+
iotAgentLib.update(
|
|
84
|
+
type + ':' + measure.qs.i,
|
|
85
|
+
type,
|
|
86
|
+
'',
|
|
87
|
+
jsonToIotaMeasures(measure.json),
|
|
88
|
+
function (error, result, body) {
|
|
89
|
+
error ? reject(error) : resolve(result);
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @brief Converts a IOTA JSON object to an array of measures as expected by the IOTA Lib
|
|
97
|
+
*
|
|
98
|
+
* @param {Object} json
|
|
99
|
+
* @returns {Array} measures
|
|
100
|
+
*/
|
|
101
|
+
function jsonToIotaMeasures(json) {
|
|
102
|
+
let measures = [];
|
|
103
|
+
for (let key in json) {
|
|
104
|
+
/* eslint-disable-next-line no-prototype-builtins */
|
|
105
|
+
if (json.hasOwnProperty(key)) {
|
|
106
|
+
let measure = {
|
|
107
|
+
name: key,
|
|
108
|
+
value: json[key]
|
|
109
|
+
};
|
|
110
|
+
// A bit of Magic. If the key is TimeInstant, we set the type to DateTime.
|
|
111
|
+
// When sending the data through iot
|
|
112
|
+
if (key === 'TimeInstant') {
|
|
113
|
+
measure.type = 'DateTime';
|
|
114
|
+
} else {
|
|
115
|
+
measure.type = 'string';
|
|
116
|
+
}
|
|
117
|
+
measures.push(measure);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return measures;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @brief Delays the execution of the code for the specified time in ms
|
|
125
|
+
*
|
|
126
|
+
* @param {Number} time in ms
|
|
127
|
+
* @returns
|
|
128
|
+
*/
|
|
129
|
+
const delay = (time) => new Promise((res) => setTimeout(res, time));
|
|
130
|
+
|
|
131
|
+
function groupToIoTAConfigType(group, service, subservice) {
|
|
132
|
+
let type = {};
|
|
133
|
+
for (var key in group) {
|
|
134
|
+
/* eslint-disable-next-line no-prototype-builtins */
|
|
135
|
+
if (group.hasOwnProperty(key)) {
|
|
136
|
+
if (key === 'attributes') {
|
|
137
|
+
type.active = group.attributes;
|
|
138
|
+
} else if (key === 'entity_type') {
|
|
139
|
+
type.type = group.entity_type;
|
|
140
|
+
} else if (key === 'static_attributes') {
|
|
141
|
+
type.staticAttributes = group.static_attributes;
|
|
142
|
+
} else if (key !== 'resource') {
|
|
143
|
+
type[key] = group[key];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
type.service = service;
|
|
148
|
+
type.subservice = subservice;
|
|
149
|
+
return { name: group.entity_type, type: type };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Test Case function
|
|
154
|
+
* @brief Sends a measure to the IoT Agent and validates the response
|
|
155
|
+
* and validates the Context Broker expectation
|
|
156
|
+
*
|
|
157
|
+
* @param {Object} measure Measure to be sent to the IoT Agent
|
|
158
|
+
* @param {Object} expectation Expectation for the Context Broker
|
|
159
|
+
* @param {Object} env Environment variables
|
|
160
|
+
* @param {Object} config IoTA Configuration object
|
|
161
|
+
* @param {String} type Type of test (multientity or multimeasure)
|
|
162
|
+
* @param {String} transport Transport to be used (Lib, HTTP or MQTT). If not specified, Lib is used.
|
|
163
|
+
* @param {Boolean} regex If true, the expectation is treated as a regex
|
|
164
|
+
*/
|
|
165
|
+
async function testCase(measure, expectation, provision, env, config, type, transport, regex) {
|
|
166
|
+
let receivedContext = [];
|
|
167
|
+
let cbMockRoute = '';
|
|
168
|
+
// Set the correct route depending if the test is multientity or not
|
|
169
|
+
if (type === 'multientity') {
|
|
170
|
+
cbMockRoute = '/v2/op/update';
|
|
171
|
+
} else {
|
|
172
|
+
cbMockRoute = '/v2/entities?options=upsert';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Set the correct mock times depending if the test is multimeasure or not
|
|
176
|
+
// based on the length of the expectation array
|
|
177
|
+
let mockTimes = 1;
|
|
178
|
+
if (expectation.length > 1) {
|
|
179
|
+
mockTimes = expectation.length;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
let contextBrokerMock = nock('http://192.168.1.1:1026')
|
|
183
|
+
.matchHeader('fiware-service', env.service)
|
|
184
|
+
.matchHeader('fiware-servicepath', env.servicePath)
|
|
185
|
+
.post(cbMockRoute, function (body) {
|
|
186
|
+
mockTimes === 1 ? (receivedContext = body) : receivedContext.push(body); // Save the received body for later comparison
|
|
187
|
+
return true;
|
|
188
|
+
})
|
|
189
|
+
.times(mockTimes)
|
|
190
|
+
.reply(204);
|
|
191
|
+
|
|
192
|
+
// Send a measure to the IoT Agent and wait for the response
|
|
193
|
+
if (transport === 'MQTT') {
|
|
194
|
+
try {
|
|
195
|
+
let client = await MQTT.connectAsync('mqtt://' + config.mqtt.host);
|
|
196
|
+
await client.publish('/' + measure.qs.k + '/' + measure.qs.i + '/attrs', JSON.stringify(measure.json));
|
|
197
|
+
await client.end();
|
|
198
|
+
} catch (error) {
|
|
199
|
+
expect.fail(ERR_MQTT + error);
|
|
200
|
+
}
|
|
201
|
+
} else if (transport === 'HTTP') {
|
|
202
|
+
// HTTP
|
|
203
|
+
const response = await sendMeasureHttp(measure);
|
|
204
|
+
// Validate the response status code and the response body
|
|
205
|
+
expect(response.statusCode, ERR_MEAS_CODE).to.equal(200);
|
|
206
|
+
expect(response.body, ERR_MEAS_BODY).to.be.empty;
|
|
207
|
+
} else {
|
|
208
|
+
const response = await sendMeasureIotaLib(measure, provision);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Validate Context Broker Expectation
|
|
212
|
+
if ((Array.isArray(expectation) && expectation.length > 0) || !Array.isArray(expectation)) {
|
|
213
|
+
// Filter empty expectations
|
|
214
|
+
regex && regex === true
|
|
215
|
+
? expect(receivedContext, ERR_CB_EXPECTATION_DIFFER).to.matchPattern(expectation)
|
|
216
|
+
: expect(receivedContext, ERR_CB_EXPECTATION_DIFFER).to.deep.equal(expectation);
|
|
217
|
+
contextBrokerMock.done(); // Ensure the request was made, no matter the body content
|
|
218
|
+
} else {
|
|
219
|
+
// If empty expectation, ensure no request was made
|
|
220
|
+
expect(contextBrokerMock.isDone(), ERR_CB_NOT_EMPTY).to.be.false;
|
|
221
|
+
expect(receivedContext, ERR_CB_NOT_EMPTY).to.be.empty;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
*
|
|
227
|
+
* @param {*} skip skip string from test case. I.E: "lib, !json"
|
|
228
|
+
* @param {*} matchPattern skip pattern to check. I.E: "lib"
|
|
229
|
+
* @returns true if the test should be skipped. False otherwise
|
|
230
|
+
*/
|
|
231
|
+
function checkSkip(skip, matchPattern) {
|
|
232
|
+
var isMatch = false;
|
|
233
|
+
// Separate tokens by comma or space, and remove empty tokens
|
|
234
|
+
var tokens = skip.split(/[ , ]+/).filter(function (value, index, arr) {
|
|
235
|
+
return value !== '' && !value.match(/[* ]+/);
|
|
236
|
+
});
|
|
237
|
+
// Check if the skip pattern is in the tokens array, or there is a token starting with ! without the pattern (negative match -!b)
|
|
238
|
+
tokens.forEach((element) => {
|
|
239
|
+
if (element === matchPattern || (element[0] === '!' && element.substr(1) !== matchPattern)) {
|
|
240
|
+
isMatch = true;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return isMatch;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
exports.checkSkip = checkSkip;
|
|
247
|
+
exports.sendMeasureHttp = sendMeasureHttp;
|
|
248
|
+
exports.sendMeasureIotaLib = sendMeasureIotaLib;
|
|
249
|
+
exports.delayMs = delay;
|
|
250
|
+
exports.testCase = testCase;
|
|
251
|
+
exports.groupToIoTAConfigType = groupToIoTAConfigType;
|
package/test/tools/utils.js
CHANGED
|
@@ -35,6 +35,31 @@ function readExampleFile(name, raw) {
|
|
|
35
35
|
|
|
36
36
|
return raw ? text : JSON.parse(text);
|
|
37
37
|
}
|
|
38
|
+
function deepEqual(objA, objB) {
|
|
39
|
+
if (objA === objB) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (typeof objA !== 'object' || typeof objB !== 'object' || objA === null || objB === null) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const keysA = Object.keys(objA);
|
|
48
|
+
const keysB = Object.keys(objB);
|
|
49
|
+
|
|
50
|
+
if (keysA.length !== keysB.length) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const key of keysA) {
|
|
55
|
+
if (!keysB.includes(key) || !deepEqual(objA[key], objB[key])) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
38
62
|
|
|
39
63
|
exports.readExampleFile = readExampleFile;
|
|
64
|
+
exports.deepEqual = deepEqual;
|
|
40
65
|
exports.request = request;
|
|
@@ -76,7 +76,8 @@ describe('dbConn.configureDb', function () {
|
|
|
76
76
|
expected: {
|
|
77
77
|
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
78
78
|
options: {
|
|
79
|
-
useNewUrlParser: true
|
|
79
|
+
useNewUrlParser: true,
|
|
80
|
+
useUnifiedTopology: true
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
},
|
|
@@ -88,7 +89,8 @@ describe('dbConn.configureDb', function () {
|
|
|
88
89
|
expected: {
|
|
89
90
|
url: 'mongodb://example.com:98765/' + dbConn.DEFAULT_DB_NAME,
|
|
90
91
|
options: {
|
|
91
|
-
useNewUrlParser: true
|
|
92
|
+
useNewUrlParser: true,
|
|
93
|
+
useUnifiedTopology: true
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
},
|
|
@@ -100,7 +102,8 @@ describe('dbConn.configureDb', function () {
|
|
|
100
102
|
expected: {
|
|
101
103
|
url: 'mongodb://example.com:27017/examples',
|
|
102
104
|
options: {
|
|
103
|
-
useNewUrlParser: true
|
|
105
|
+
useNewUrlParser: true,
|
|
106
|
+
useUnifiedTopology: true
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
},
|
|
@@ -113,7 +116,8 @@ describe('dbConn.configureDb', function () {
|
|
|
113
116
|
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
114
117
|
options: {
|
|
115
118
|
replicaSet: 'rs0',
|
|
116
|
-
useNewUrlParser: true
|
|
119
|
+
useNewUrlParser: true,
|
|
120
|
+
useUnifiedTopology: true
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
123
|
},
|
|
@@ -125,7 +129,8 @@ describe('dbConn.configureDb', function () {
|
|
|
125
129
|
expected: {
|
|
126
130
|
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
127
131
|
options: {
|
|
128
|
-
useNewUrlParser: true
|
|
132
|
+
useNewUrlParser: true,
|
|
133
|
+
useUnifiedTopology: true
|
|
129
134
|
}
|
|
130
135
|
}
|
|
131
136
|
},
|
|
@@ -137,7 +142,8 @@ describe('dbConn.configureDb', function () {
|
|
|
137
142
|
expected: {
|
|
138
143
|
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
139
144
|
options: {
|
|
140
|
-
useNewUrlParser: true
|
|
145
|
+
useNewUrlParser: true,
|
|
146
|
+
useUnifiedTopology: true
|
|
141
147
|
}
|
|
142
148
|
}
|
|
143
149
|
},
|
|
@@ -148,13 +154,14 @@ describe('dbConn.configureDb', function () {
|
|
|
148
154
|
password: 'pass01'
|
|
149
155
|
},
|
|
150
156
|
expected: {
|
|
151
|
-
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
157
|
+
url: 'mongodb://user01:pass01@example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
152
158
|
options: {
|
|
153
159
|
auth: {
|
|
154
160
|
user: 'user01',
|
|
155
161
|
password: 'pass01'
|
|
156
162
|
},
|
|
157
|
-
useNewUrlParser: true
|
|
163
|
+
useNewUrlParser: true,
|
|
164
|
+
useUnifiedTopology: true
|
|
158
165
|
}
|
|
159
166
|
}
|
|
160
167
|
},
|
|
@@ -166,8 +173,8 @@ describe('dbConn.configureDb', function () {
|
|
|
166
173
|
expected: {
|
|
167
174
|
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
168
175
|
options: {
|
|
169
|
-
|
|
170
|
-
|
|
176
|
+
useNewUrlParser: true,
|
|
177
|
+
useUnifiedTopology: true
|
|
171
178
|
}
|
|
172
179
|
}
|
|
173
180
|
},
|
|
@@ -182,15 +189,15 @@ describe('dbConn.configureDb', function () {
|
|
|
182
189
|
authSource: 'admin'
|
|
183
190
|
},
|
|
184
191
|
expected: {
|
|
185
|
-
url: 'mongodb://example.com:98765/examples',
|
|
192
|
+
url: 'mongodb://user01:pass01@example.com:98765/examples?authSource=admin',
|
|
186
193
|
options: {
|
|
187
194
|
replicaSet: 'rs0',
|
|
188
195
|
auth: {
|
|
189
196
|
user: 'user01',
|
|
190
197
|
password: 'pass01'
|
|
191
198
|
},
|
|
192
|
-
|
|
193
|
-
|
|
199
|
+
useNewUrlParser: true,
|
|
200
|
+
useUnifiedTopology: true
|
|
194
201
|
}
|
|
195
202
|
}
|
|
196
203
|
},
|
|
@@ -203,7 +210,8 @@ describe('dbConn.configureDb', function () {
|
|
|
203
210
|
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
204
211
|
options: {
|
|
205
212
|
ssl: true,
|
|
206
|
-
useNewUrlParser: true
|
|
213
|
+
useNewUrlParser: true,
|
|
214
|
+
useUnifiedTopology: true
|
|
207
215
|
}
|
|
208
216
|
}
|
|
209
217
|
},
|
|
@@ -217,7 +225,8 @@ describe('dbConn.configureDb', function () {
|
|
|
217
225
|
expected: {
|
|
218
226
|
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME + '?retryWrites=true',
|
|
219
227
|
options: {
|
|
220
|
-
useNewUrlParser: true
|
|
228
|
+
useNewUrlParser: true,
|
|
229
|
+
useUnifiedTopology: true
|
|
221
230
|
}
|
|
222
231
|
}
|
|
223
232
|
},
|
|
@@ -235,7 +244,8 @@ describe('dbConn.configureDb', function () {
|
|
|
235
244
|
dbConn.DEFAULT_DB_NAME +
|
|
236
245
|
'?retryWrites=true&readPreference=nearest',
|
|
237
246
|
options: {
|
|
238
|
-
useNewUrlParser: true
|
|
247
|
+
useNewUrlParser: true,
|
|
248
|
+
useUnifiedTopology: true
|
|
239
249
|
}
|
|
240
250
|
}
|
|
241
251
|
},
|
|
@@ -247,7 +257,8 @@ describe('dbConn.configureDb', function () {
|
|
|
247
257
|
expected: {
|
|
248
258
|
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
249
259
|
options: {
|
|
250
|
-
useNewUrlParser: true
|
|
260
|
+
useNewUrlParser: true,
|
|
261
|
+
useUnifiedTopology: true
|
|
251
262
|
}
|
|
252
263
|
}
|
|
253
264
|
},
|
|
@@ -259,7 +270,8 @@ describe('dbConn.configureDb', function () {
|
|
|
259
270
|
expected: {
|
|
260
271
|
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
261
272
|
options: {
|
|
262
|
-
useNewUrlParser: true
|
|
273
|
+
useNewUrlParser: true,
|
|
274
|
+
useUnifiedTopology: true
|
|
263
275
|
}
|
|
264
276
|
}
|
|
265
277
|
},
|
|
@@ -271,7 +283,8 @@ describe('dbConn.configureDb', function () {
|
|
|
271
283
|
expected: {
|
|
272
284
|
url: 'mongodb://example.com:27017/' + dbConn.DEFAULT_DB_NAME,
|
|
273
285
|
options: {
|
|
274
|
-
useNewUrlParser: true
|
|
286
|
+
useNewUrlParser: true,
|
|
287
|
+
useUnifiedTopology: true
|
|
275
288
|
}
|
|
276
289
|
}
|
|
277
290
|
},
|
|
@@ -293,16 +306,16 @@ describe('dbConn.configureDb', function () {
|
|
|
293
306
|
unknownparam: 'unknown'
|
|
294
307
|
},
|
|
295
308
|
expected: {
|
|
296
|
-
url: 'mongodb://example.com:98765/examples?retryWrites=true&readPreference=nearest&w=majority',
|
|
309
|
+
url: 'mongodb://user01:pass01@example.com:98765/examples?retryWrites=true&readPreference=nearest&w=majority&authSource=admin',
|
|
297
310
|
options: {
|
|
298
311
|
replicaSet: 'rs0',
|
|
299
312
|
auth: {
|
|
300
313
|
user: 'user01',
|
|
301
314
|
password: 'pass01'
|
|
302
315
|
},
|
|
303
|
-
authSource: 'admin',
|
|
304
316
|
ssl: true,
|
|
305
|
-
useNewUrlParser: true
|
|
317
|
+
useNewUrlParser: true,
|
|
318
|
+
useUnifiedTopology: true
|
|
306
319
|
}
|
|
307
320
|
}
|
|
308
321
|
}
|
package/test/unit/ngsi-ld/examples/contextRequests/createProvisionedDeviceWithGroupAndStatic2.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"@context": "http://context.json-ld",
|
|
4
|
-
"id": "urn:ngsi-ld:SensorMachine:
|
|
4
|
+
"id": "urn:ngsi-ld:SensorMachine:Light1",
|
|
5
5
|
"type": "SensorMachine",
|
|
6
|
-
"
|
|
6
|
+
"status": {
|
|
7
7
|
"type": "Property",
|
|
8
|
-
"value":
|
|
9
|
-
"@type": "hardcodedType",
|
|
10
|
-
"@value": "hardcodedValue"
|
|
11
|
-
}
|
|
8
|
+
"value": "STARTING"
|
|
12
9
|
},
|
|
13
10
|
"bootstrapServer": {
|
|
14
11
|
"type": "Property",
|
|
@@ -16,34 +13,6 @@
|
|
|
16
13
|
"@type": "Address",
|
|
17
14
|
"@value": "127.0.0.1"
|
|
18
15
|
}
|
|
19
|
-
},
|
|
20
|
-
"commandAttr_status": {
|
|
21
|
-
"type": "Property",
|
|
22
|
-
"value": {
|
|
23
|
-
"@type": "commandStatus",
|
|
24
|
-
"@value": "UNKNOWN"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"commandAttr_info": {
|
|
28
|
-
"type": "Property",
|
|
29
|
-
"value": {
|
|
30
|
-
"@type": "commandResult",
|
|
31
|
-
"@value": " "
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"wheel1_status": {
|
|
35
|
-
"type": "Property",
|
|
36
|
-
"value": {
|
|
37
|
-
"@type": "commandStatus",
|
|
38
|
-
"@value": "UNKNOWN"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"wheel1_info": {
|
|
42
|
-
"type": "Property",
|
|
43
|
-
"value": {
|
|
44
|
-
"@type": "commandResult",
|
|
45
|
-
"@value": " "
|
|
46
|
-
}
|
|
47
16
|
}
|
|
48
17
|
}
|
|
49
18
|
]
|
|
@@ -5,12 +5,7 @@
|
|
|
5
5
|
"type": "Property",
|
|
6
6
|
"value": {
|
|
7
7
|
"@type": "Object",
|
|
8
|
-
"@value": {
|
|
9
|
-
"firmware": {
|
|
10
|
-
"hash": "cf23df2207d99a74fbe169e3eba035e633b65d94",
|
|
11
|
-
"version": "1.1.0"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
8
|
+
"@value": "{\"firmware\": {\"version\": \"1.1.0\",\"hash\": \"cf23df2207d99a74fbe169e3eba035e633b65d94\"}}"
|
|
14
9
|
}
|
|
15
10
|
},
|
|
16
11
|
"id": "urn:ngsi-ld:Light:light1",
|