@bluedot-innovation/models 7.5.4 → 7.5.7
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/CHANGELOG.md +9 -0
- package/Models.js +0 -5
- package/__tests__/project/project.data.json +4 -0
- package/__tests__/project/project.spec.js +20 -20
- package/package.json +1 -1
- package/schemas/Integration.js +4 -4
- package/schemas/OloIntegration.js +10 -0
- package/schemas/Webhook.js +2 -2
- package/models/TestDevice.js +0 -42
- package/models/TestDeviceCluster.js +0 -32
- package/models/TestInstance.js +0 -60
- package/models/TestScenario.js +0 -40
package/CHANGELOG.md
CHANGED
package/Models.js
CHANGED
|
@@ -28,11 +28,6 @@ Models.TravelPath = require('./models/conditions/TravelPath').Model
|
|
|
28
28
|
Models.Speed = require('./models/conditions/Speed').Model
|
|
29
29
|
Models.TravelDirection = require('./models/conditions/TravelDirection').Model
|
|
30
30
|
|
|
31
|
-
// Test Management Portal
|
|
32
|
-
Models.TestDevice = require('./models/TestDevice').Model
|
|
33
|
-
Models.TestDeviceCluster = require('./models/TestDeviceCluster').Model
|
|
34
|
-
Models.TestInstance = require('./models/TestInstance').Model
|
|
35
|
-
Models.TestScenario = require('./models/TestScenario').Model
|
|
36
31
|
// Added V1 Application model to get Remote Config details for Test Management Portal.
|
|
37
32
|
// This model can be removed once we start using V2 models.
|
|
38
33
|
Models.Application = require('./models/Application').Model
|
|
@@ -50,6 +50,10 @@
|
|
|
50
50
|
"androidSecretKey": "eZqphc1Vh2dqaIQEvz4APNbErZkW_AaaRmwE8BCmYpHZFc3n_ZKajTLgJgFqLNNN",
|
|
51
51
|
"iosApiKey": "us1-a5e6eefe90fe704aba0a7d2daa00baaa",
|
|
52
52
|
"iosSecretKey": "fZqphc1Vh2dqaIQEvz4APNbErZkW_AaaRmwE8BCmYpHZFc3n_ZKajTLgJgFqLNNN"
|
|
53
|
+
},
|
|
54
|
+
"olo": {
|
|
55
|
+
"sharedSecret": "jhFGJHKJhkHIjklJ",
|
|
56
|
+
"nowReadyEnabled": true
|
|
53
57
|
}
|
|
54
58
|
},
|
|
55
59
|
"tempo": {
|
|
@@ -387,11 +387,11 @@ describe('Project', () => {
|
|
|
387
387
|
it(`should throw an error if structure is mobivity and taregt_id is not a body field`, (done) => {
|
|
388
388
|
project.webhooks[0].type = "register"
|
|
389
389
|
project.webhooks[0].structure = "mobivity"
|
|
390
|
-
project.webhooks[0].body = {"message_text": "test-value", "
|
|
390
|
+
project.webhooks[0].body = {"message_text": "test-value", "username": "test-value"}
|
|
391
391
|
let Project = new ProjectModel(project)
|
|
392
392
|
Project.validate((err, res) => {
|
|
393
393
|
assert.exists(err)
|
|
394
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id"
|
|
394
|
+
assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
|
|
395
395
|
done()
|
|
396
396
|
})
|
|
397
397
|
})
|
|
@@ -399,23 +399,11 @@ describe('Project', () => {
|
|
|
399
399
|
it(`should throw an error if structure is mobivity and message_text is not a body field`, (done) => {
|
|
400
400
|
project.webhooks[0].type = "register"
|
|
401
401
|
project.webhooks[0].structure = "mobivity"
|
|
402
|
-
project.webhooks[0].body = {"target_id": "test-value", "
|
|
402
|
+
project.webhooks[0].body = {"target_id": "test-value", "username": "test-value"}
|
|
403
403
|
let Project = new ProjectModel(project)
|
|
404
404
|
Project.validate((err, res) => {
|
|
405
405
|
assert.exists(err)
|
|
406
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id"
|
|
407
|
-
done()
|
|
408
|
-
})
|
|
409
|
-
})
|
|
410
|
-
|
|
411
|
-
it(`should throw an error if structure is mobivity and url is not a body field`, (done) => {
|
|
412
|
-
project.webhooks[0].type = "register"
|
|
413
|
-
project.webhooks[0].structure = "mobivity"
|
|
414
|
-
project.webhooks[0].body = {"target_id": "test-value", "message_text": "test-value", "username": "test-value"}
|
|
415
|
-
let Project = new ProjectModel(project)
|
|
416
|
-
Project.validate((err, res) => {
|
|
417
|
-
assert.exists(err)
|
|
418
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id", "url" and "message_text" body fields to be present/)
|
|
406
|
+
assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
|
|
419
407
|
done()
|
|
420
408
|
})
|
|
421
409
|
})
|
|
@@ -423,11 +411,11 @@ describe('Project', () => {
|
|
|
423
411
|
it(`should throw an error if structure is mobivity and username is not a body field`, (done) => {
|
|
424
412
|
project.webhooks[0].type = "register"
|
|
425
413
|
project.webhooks[0].structure = "mobivity"
|
|
426
|
-
project.webhooks[0].body = {"target_id": "test-value", "message_text": "
|
|
414
|
+
project.webhooks[0].body = {"target_id": "test-value", "message_text": "est-value"}
|
|
427
415
|
let Project = new ProjectModel(project)
|
|
428
416
|
Project.validate((err, res) => {
|
|
429
417
|
assert.exists(err)
|
|
430
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id"
|
|
418
|
+
assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
|
|
431
419
|
done()
|
|
432
420
|
})
|
|
433
421
|
})
|
|
@@ -439,7 +427,7 @@ describe('Project', () => {
|
|
|
439
427
|
let Project = new ProjectModel(project)
|
|
440
428
|
Project.validate((err, res) => {
|
|
441
429
|
assert.exists(err)
|
|
442
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id"
|
|
430
|
+
assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
|
|
443
431
|
done()
|
|
444
432
|
})
|
|
445
433
|
})
|
|
@@ -451,7 +439,7 @@ describe('Project', () => {
|
|
|
451
439
|
let Project = new ProjectModel(project)
|
|
452
440
|
Project.validate((err, res) => {
|
|
453
441
|
assert.exists(err)
|
|
454
|
-
assert.match(err.message, /mobivity webhooks require "username", "target_id"
|
|
442
|
+
assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
|
|
455
443
|
done()
|
|
456
444
|
})
|
|
457
445
|
})
|
|
@@ -521,6 +509,18 @@ describe('Project', () => {
|
|
|
521
509
|
})
|
|
522
510
|
})
|
|
523
511
|
})
|
|
512
|
+
|
|
513
|
+
describe("olo integration validation", () => {
|
|
514
|
+
it('should throw an error when sharedSecret is missing', (done) => {
|
|
515
|
+
delete project.integrations.olo.sharedSecret
|
|
516
|
+
let Project = new ProjectModel(project)
|
|
517
|
+
Project.validate((err, res) => {
|
|
518
|
+
assert.exists(err)
|
|
519
|
+
assert.match(err.message, /`sharedSecret` is required/)
|
|
520
|
+
done()
|
|
521
|
+
})
|
|
522
|
+
})
|
|
523
|
+
})
|
|
524
524
|
})
|
|
525
525
|
|
|
526
526
|
describe('should throw an error when any of the values of the array contains a falsy value', () => {
|
package/package.json
CHANGED
package/schemas/Integration.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
let mongoose = require("mongoose");
|
|
2
|
-
|
|
2
|
+
const oloIntegrationSchema = require('./OloIntegration')
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const MParticleSchema = new mongoose.Schema({
|
|
@@ -46,9 +46,9 @@ const IntegrationSchema = new mongoose.Schema({
|
|
|
46
46
|
validator:androidPairValidator,
|
|
47
47
|
msg: 'both androidSecretKey and androidApiKey are required'
|
|
48
48
|
}
|
|
49
|
-
]
|
|
50
|
-
|
|
51
|
-
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
olo: { type: oloIntegrationSchema }
|
|
52
52
|
},{ _id : false });
|
|
53
53
|
function apiKeyValidator(value){
|
|
54
54
|
// check if the value is a non-empty string
|
package/schemas/Webhook.js
CHANGED
|
@@ -21,7 +21,7 @@ function validateMobivityRequiredFields(structure){
|
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
const bodyKeys = Object.keys(webhookBodyFields)
|
|
24
|
-
if(!bodyKeys.includes("username") || !bodyKeys.includes("target_id") || !bodyKeys.includes("message_text")
|
|
24
|
+
if(!bodyKeys.includes("username") || !bodyKeys.includes("target_id") || !bodyKeys.includes("message_text")){
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -45,7 +45,7 @@ let WebhookSchema = new mongoose.Schema({
|
|
|
45
45
|
default: 'standard',
|
|
46
46
|
validate: [
|
|
47
47
|
{validator: validateTealiumRequiredFields, msg: 'tealium webhooks require "tealium_account" and "tealium_profile" body fields to be present'},
|
|
48
|
-
{validator: validateMobivityRequiredFields, msg: 'mobivity webhooks require "username", "target_id"
|
|
48
|
+
{validator: validateMobivityRequiredFields, msg: 'mobivity webhooks require "username", "target_id" and "message_text" body fields to be present'}
|
|
49
49
|
]
|
|
50
50
|
}
|
|
51
51
|
}, {
|
package/models/TestDevice.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Andrew on 01/03/2017.
|
|
3
|
-
* Copyright : Bluedot Innovations.
|
|
4
|
-
* Owner :
|
|
5
|
-
*/
|
|
6
|
-
let mongoose = require('mongoose')
|
|
7
|
-
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
8
|
-
|
|
9
|
-
let TestDeviceSchema = new mongoose.Schema({
|
|
10
|
-
name: String,
|
|
11
|
-
identifier: String,
|
|
12
|
-
os: String,
|
|
13
|
-
osVersion: String,
|
|
14
|
-
hostToken: String,
|
|
15
|
-
batteryToken: String,
|
|
16
|
-
model: String,
|
|
17
|
-
trackingDevice: {type: Boolean, default: false},
|
|
18
|
-
creationTime: {type: Date, default: Date.now},
|
|
19
|
-
lastUpdateTime: {type: Date, default: Date.now},
|
|
20
|
-
serialNumber: String,
|
|
21
|
-
mobileNumber: String,
|
|
22
|
-
deviceType: String,
|
|
23
|
-
state: {type: String, default: StateEnum.ACTIVE},
|
|
24
|
-
comments: String,
|
|
25
|
-
imei: String,
|
|
26
|
-
udid: String
|
|
27
|
-
},
|
|
28
|
-
{ collection: 'testDevice'})
|
|
29
|
-
|
|
30
|
-
// optional mongoose
|
|
31
|
-
let model = (mongooseInstance) => {
|
|
32
|
-
let TestDevice
|
|
33
|
-
if (mongooseInstance) {
|
|
34
|
-
TestDevice = mongooseInstance.model('TestDevice', TestDeviceSchema)
|
|
35
|
-
} else {
|
|
36
|
-
TestDevice = mongoose.model('TestDevice', TestDeviceSchema)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return TestDevice
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = { Model: model, Schema: TestDeviceSchema }
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Andrew on 02/03/2017.
|
|
3
|
-
* Copyright : Bluedot Innovation.
|
|
4
|
-
*/
|
|
5
|
-
let mongoose = require('mongoose')
|
|
6
|
-
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
7
|
-
|
|
8
|
-
let TestDeviceClusterSchema = new mongoose.Schema(
|
|
9
|
-
{
|
|
10
|
-
name: String,
|
|
11
|
-
devices: [],
|
|
12
|
-
creationTime: {type: Date, default: Date.now},
|
|
13
|
-
lastUpdateTime: {type: Date, default: Date.now},
|
|
14
|
-
comments: String,
|
|
15
|
-
state: {type: String, default: StateEnum.ACTIVE}
|
|
16
|
-
},
|
|
17
|
-
{ collection: 'testDeviceCluster' }
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
// optional mongoose
|
|
21
|
-
let model = (mongooseInstance) => {
|
|
22
|
-
let TestDeviceCluster
|
|
23
|
-
if (mongooseInstance) {
|
|
24
|
-
TestDeviceCluster = mongooseInstance.model('TestDeviceCluster', TestDeviceClusterSchema)
|
|
25
|
-
} else {
|
|
26
|
-
TestDeviceCluster = mongoose.model('TestDeviceCluster', TestDeviceClusterSchema)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return TestDeviceCluster
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = { Model: model, Schema: TestDeviceClusterSchema }
|
package/models/TestInstance.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Andrew on 02/03/2017.
|
|
3
|
-
* Copyright : Bluedot Innovation.
|
|
4
|
-
*/
|
|
5
|
-
let mongoose = require('mongoose')
|
|
6
|
-
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
7
|
-
let TestStatusEnum = require('@bluedot-innovation/enums').TestStatusEnum
|
|
8
|
-
|
|
9
|
-
const Schema = mongoose.Schema
|
|
10
|
-
let Scenario = require('./TestScenario').Schema
|
|
11
|
-
|
|
12
|
-
let TestInstanceSchema = new mongoose.Schema(
|
|
13
|
-
{
|
|
14
|
-
name: String,
|
|
15
|
-
scenarioId: String,
|
|
16
|
-
devices: {},
|
|
17
|
-
clusters: {type: Array, default: []},
|
|
18
|
-
mode: String,
|
|
19
|
-
startTime: Date,
|
|
20
|
-
endTime: Date,
|
|
21
|
-
duration: Number,
|
|
22
|
-
endPoint: String,
|
|
23
|
-
trackedLocations: {type: Array, default: []},
|
|
24
|
-
creationTime: {type: Date, default: Date.now},
|
|
25
|
-
lastUpdateTime: {type: Date, default: Date.now},
|
|
26
|
-
state: {type: String, default: StateEnum.ACTIVE},
|
|
27
|
-
status: {type: String, default: TestStatusEnum.PLANNED},
|
|
28
|
-
isValid: {type: Boolean, default: true},
|
|
29
|
-
comments: String,
|
|
30
|
-
isProduction: Boolean,
|
|
31
|
-
enableBackgroundLocationIndicator: {type: Boolean, default: false},
|
|
32
|
-
enableForegroundService: {type: Boolean, default: true},
|
|
33
|
-
sdkVersion: String,
|
|
34
|
-
sdkBuildNumber: String,
|
|
35
|
-
platform: String,
|
|
36
|
-
appVersion: String,
|
|
37
|
-
buildType: String,
|
|
38
|
-
locationPermission: String,
|
|
39
|
-
roundNumber: Number,
|
|
40
|
-
useCaseType: String,
|
|
41
|
-
groupOfDevices: String,
|
|
42
|
-
configurationParameters:{type: Schema.Types.Mixed, default: null},
|
|
43
|
-
scenario: Scenario
|
|
44
|
-
},
|
|
45
|
-
{ collection: 'testInstance' }
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
// optional mongoose
|
|
49
|
-
let model = (mongooseInstance) => {
|
|
50
|
-
let TestInstance
|
|
51
|
-
if (mongooseInstance) {
|
|
52
|
-
TestInstance = mongooseInstance.model('TestInstance', TestInstanceSchema)
|
|
53
|
-
} else {
|
|
54
|
-
TestInstance = mongoose.model('TestInstance', TestInstanceSchema)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return TestInstance
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
module.exports = { Model: model, Schema: TestInstanceSchema }
|
package/models/TestScenario.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Andrew on 02/03/2017.
|
|
3
|
-
* Copyright : Bluedot Innovations.
|
|
4
|
-
* Owner :
|
|
5
|
-
*/
|
|
6
|
-
let mongoose = require('mongoose')
|
|
7
|
-
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
8
|
-
|
|
9
|
-
let TestScenarioSchema = new mongoose.Schema(
|
|
10
|
-
{
|
|
11
|
-
name: String,
|
|
12
|
-
apiKey: String,
|
|
13
|
-
customerApiKey: String,
|
|
14
|
-
email: String,
|
|
15
|
-
creationTime: {type: Date, default: Date.now},
|
|
16
|
-
lastUpdateTime: {type: Date, default: Date.now},
|
|
17
|
-
state: {type: String, default: StateEnum.ACTIVE},
|
|
18
|
-
numberZones: String,
|
|
19
|
-
comments: String,
|
|
20
|
-
environment: String,
|
|
21
|
-
accountId: String,
|
|
22
|
-
projectId: String,
|
|
23
|
-
zones: []
|
|
24
|
-
},
|
|
25
|
-
{ collection: 'testScenario' }
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
// optional mongoose
|
|
29
|
-
let model = (mongooseInstance) => {
|
|
30
|
-
let TestScenario
|
|
31
|
-
if (mongooseInstance) {
|
|
32
|
-
TestScenario = mongooseInstance.model('TestScenario', TestScenarioSchema)
|
|
33
|
-
} else {
|
|
34
|
-
TestScenario = mongoose.model('TestScenario', TestScenarioSchema)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return TestScenario
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = { Model: model, Schema: TestScenarioSchema }
|