@bluedot-innovation/models 8.2.1 → 8.2.3

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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 8.2.3
2
+ - Move helloSsoCode from destination to project model
3
+
4
+ ## 8.2.2
5
+ - Remove domain from helloSso featture
6
+
1
7
  ## 8.2.1
2
8
  - Add Hello SSO feature to Account model and helloSsoCode to Destinnation model
3
9
 
@@ -39,8 +39,7 @@
39
39
  },
40
40
  "helloSso": {
41
41
  "enabled": true,
42
- "identityProvider": "coles-screens",
43
- "domain": "coles.com"
42
+ "identityProvider": "coles-screens"
44
43
  }
45
44
  },
46
45
  "integrations": {
@@ -14,6 +14,5 @@
14
14
  "waitTime": {
15
15
  "goal": 300,
16
16
  "alert": 240
17
- },
18
- "helloSsoCode": "HGDUS69SDJJ0"
17
+ }
19
18
  }
@@ -58,16 +58,6 @@ describe('Valid Destination ', () => {
58
58
  done()
59
59
  })
60
60
  })
61
-
62
- it('should validate a valid destination without helloSsoCode', (done) => {
63
- delete destination.helloSsoCode
64
- let Destination = new DestinationModel(destination)
65
- Destination.validate((err, res) => {
66
- assert.notExists(res)
67
- assert(err === null, 'err equals null')
68
- done()
69
- })
70
- })
71
61
  })
72
62
 
73
63
  describe('Invalid Destination ', () => {
@@ -198,52 +188,4 @@ describe('Invalid Destination ', () => {
198
188
  done()
199
189
  })
200
190
  })
201
-
202
- it("should throw an error if helloSsoCode is shorter than 12 characters", (done) => {
203
- destination.helloSsoCode = "HGDUS69SD"
204
- let Destination = new DestinationModel(destination)
205
- Destination.validate((err, res) => {
206
- assert.notExists(res)
207
- assert.exists(err)
208
- console.log(err.message)
209
- assert.match(err.message, /Hello SSO code must be a 12 character capital alphanumeric text/)
210
- done()
211
- })
212
- })
213
-
214
- it("should throw an error if helloSsoCode is longer than 12 characters", (done) => {
215
- destination.helloSsoCode = "HGDUS69SDASLDKJSFDHWUER7Y"
216
- let Destination = new DestinationModel(destination)
217
- Destination.validate((err, res) => {
218
- assert.notExists(res)
219
- assert.exists(err)
220
- console.log(err.message)
221
- assert.match(err.message, /Hello SSO code must be a 12 character capital alphanumeric text/)
222
- done()
223
- })
224
- })
225
-
226
- it("should throw an error if helloSsoCode include lowercase characters", (done) => {
227
- destination.helloSsoCode = "3HgDUs69SD95"
228
- let Destination = new DestinationModel(destination)
229
- Destination.validate((err, res) => {
230
- assert.notExists(res)
231
- assert.exists(err)
232
- console.log(err.message)
233
- assert.match(err.message, /Hello SSO code must be a 12 character capital alphanumeric text/)
234
- done()
235
- })
236
- })
237
-
238
- it("should throw an error if helloSsoCode is empty", (done) => {
239
- destination.helloSsoCode = ""
240
- let Destination = new DestinationModel(destination)
241
- Destination.validate((err, res) => {
242
- assert.notExists(res)
243
- assert.exists(err)
244
- console.log(err.message)
245
- assert.match(err.message, /Hello SSO code must be a 12 character capital alphanumeric text/)
246
- done()
247
- })
248
- })
249
191
  })
@@ -87,6 +87,7 @@
87
87
  "isochroneBracketInterval": [60, 120, 300]
88
88
  },
89
89
  "hello": {
90
- "registrationTtl": 86400
90
+ "registrationTtl": 86400,
91
+ "ssoLinkingCode": "HGDUS69SDJJ0"
91
92
  }
92
93
  }
@@ -113,6 +113,16 @@ describe('Project', () => {
113
113
  done()
114
114
  })
115
115
  })
116
+
117
+ it('should validate a valid project without ssoLinkingCode', (done) => {
118
+ delete project.hello.ssoLinkingCode
119
+ let Project = new ProjectModel(project)
120
+ Project.validate((err, res) => {
121
+ assert.notExists(res)
122
+ assert(err === null, 'err equals null')
123
+ done()
124
+ })
125
+ })
116
126
  })
117
127
  testCase('Valid Project ', () => {
118
128
  assertions('should validate a valid project ', (done) => {
@@ -643,6 +653,52 @@ describe('Project', () => {
643
653
  })
644
654
  })
645
655
 
656
+ describe("SSO linking code validation", () => {
657
+ it("should throw an error if ssoLinkingCode is shorter than 12 characters", (done) => {
658
+ project.hello.ssoLinkingCode = "HGDUS69SD"
659
+ let Project = new ProjectModel(project)
660
+ Project.validate((err, res) => {
661
+ assert.notExists(res)
662
+ assert.exists(err)
663
+ assert.match(err.message, /SSO linking code must be a 12 character capital alphanumeric text/)
664
+ done()
665
+ })
666
+ })
667
+
668
+ it("should throw an error if ssoLinkingCode is longer than 12 characters", (done) => {
669
+ project.hello.ssoLinkingCode = "HGDUS69SDASLDKJSFDHWUER7Y"
670
+ let Project = new ProjectModel(project)
671
+ Project.validate((err, res) => {
672
+ assert.notExists(res)
673
+ assert.exists(err)
674
+ assert.match(err.message, /SSO linking code must be a 12 character capital alphanumeric text/)
675
+ done()
676
+ })
677
+ })
678
+
679
+ it("should throw an error if ssoLinkingCode include lowercase characters", (done) => {
680
+ project.hello.ssoLinkingCode = "3HgDUs69SD95"
681
+ let Project = new ProjectModel(project)
682
+ Project.validate((err, res) => {
683
+ assert.notExists(res)
684
+ assert.exists(err)
685
+ assert.match(err.message, /SSO linking code must be a 12 character capital alphanumeric text/)
686
+ done()
687
+ })
688
+ })
689
+
690
+ it("should throw an error if ssoLinkingCode is empty", (done) => {
691
+ project.hello.ssoLinkingCode = ""
692
+ let Project = new ProjectModel(project)
693
+ Project.validate((err, res) => {
694
+ assert.notExists(res)
695
+ assert.exists(err)
696
+ assert.match(err.message, /SSO linking code must be a 12 character capital alphanumeric text/)
697
+ done()
698
+ })
699
+ })
700
+ })
701
+
646
702
  })
647
703
 
648
704
  describe('should throw an error when any of the values of the array contains a falsy value', () => {
package/helpers.js CHANGED
@@ -247,7 +247,7 @@ helpers.validateLongitude = function(longitude){
247
247
  return longitude >= -180 && longitude <= 180
248
248
  }
249
249
 
250
- helpers.validateHelloSsoCode = function(code){
250
+ helpers.validateSsoLinkingCode = function(code){
251
251
  const expression = '^[A-Z0-9]{12}$'
252
252
  const regex = new RegExp(expression)
253
253
  return regex.test(code)
@@ -17,8 +17,7 @@ const DestinationSchema = new mongoose.Schema({
17
17
  projectId: {type: String, required: true, validate: {validator: helpers.validateUUIDv4, msg: 'Invalid projectId'}},
18
18
  creationTime: {type: Date, default: Date.now},
19
19
  lastUpdateTime: {type: Date, default: Date.now},
20
- waitTime: { type: WaitTime },
21
- helloSsoCode: {type: String, validate: {validator: helpers.validateHelloSsoCode, msg: 'Hello SSO code must be a 12 character capital alphanumeric text'}}
20
+ waitTime: { type: WaitTime }
22
21
  }, {collection: 'destination'})
23
22
 
24
23
  DestinationSchema.plugin(patcher)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "8.2.1",
3
+ "version": "8.2.3",
4
4
  "main": "Models.js",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",
@@ -2,8 +2,7 @@ let mongoose = require('mongoose')
2
2
 
3
3
  let HelloSsoSchema = new mongoose.Schema({
4
4
  enabled: {type: Boolean, default: true},
5
- identityProvider: {type: String, required: true},
6
- domain: {type: String, required: true}
5
+ identityProvider: {type: String, required: true}
7
6
  }, {
8
7
  _id: false
9
8
  })
@@ -1,7 +1,9 @@
1
1
  let mongoose = require('mongoose')
2
+ const helpers = require('../helpers')
2
3
 
3
4
  let ProjectHelloSchema = new mongoose.Schema({
4
5
  registrationTtl: {type: Number, validate: { validator: Number.isInteger, msg: 'hello.registrationTtl should be an integer number' }},
6
+ ssoLinkingCode: {type: String, validate: {validator: helpers.validateSsoLinkingCode, msg: 'SSO linking code must be a 12 character capital alphanumeric text'}}
5
7
  }, {
6
8
  _id: false
7
9
  })
@@ -53,16 +53,18 @@ const indexes = {
53
53
  options: {
54
54
  name: "geometry_index"
55
55
  }
56
- },
56
+ }
57
+ ],
58
+ project: [
57
59
  {
58
60
  fields: {
59
- helloSsoCode: 1
61
+ ssoLinkingCode: 1
60
62
  },
61
63
  options: {
62
- name: "helloSsoCode_index",
64
+ name: "ssoLinkingCode_index",
63
65
  unique: true,
64
66
  partialFilterExpression: {
65
- helloSsoCode: { $type: "string" }
67
+ ssoLinkingCode: { $type: "string" }
66
68
  }
67
69
  }
68
70
  }