ac-sanitizer 3.9.18 → 3.10.2

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,38 @@
1
+ <a name="3.10.2"></a>
2
+
3
+ ## [3.10.2](https://github.com/mmpro/ac-sanitizer/compare/v3.10.1..v3.10.2) (2022-04-28 11:21:08)
4
+
5
+
6
+ ### Bug Fix
7
+
8
+ * **App:** Detect int and float | MP | [1320003ec27cb1b85824aa0ad719b2d23b4ef5e5](https://github.com/mmpro/ac-sanitizer/commit/1320003ec27cb1b85824aa0ad719b2d23b4ef5e5)
9
+ Detect int and float
10
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
11
+ <a name="3.10.1"></a>
12
+
13
+ ## [3.10.1](https://github.com/mmpro/ac-sanitizer/compare/v3.10.0..v3.10.1) (2022-04-24 19:38:16)
14
+
15
+
16
+ ### Bug Fix
17
+
18
+ * **App:** Fix for checking float | MP | [bd68b7c8bd76d15d22d9d2dea8ce78e07be7d3c9](https://github.com/mmpro/ac-sanitizer/commit/bd68b7c8bd76d15d22d9d2dea8ce78e07be7d3c9)
19
+ Check if type float is really a float
20
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
21
+ ### Tests
22
+
23
+ * **App:** Fixed tests | MP | [96e8d6067c219a241840e253ac9e11c36b258df0](https://github.com/mmpro/ac-sanitizer/commit/96e8d6067c219a241840e253ac9e11c36b258df0)
24
+ Make sure to check for errors from function
25
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
26
+ <a name="3.10.0"></a>
27
+
28
+ # [3.10.0](https://github.com/mmpro/ac-sanitizer/compare/v3.9.18..v3.10.0) (2022-04-24 18:45:04)
29
+
30
+
31
+ ### Feature
32
+
33
+ * **App:** Add type any | MP | [ff0858e978b7f7195f68ad5c9c346723107075fb](https://github.com/mmpro/ac-sanitizer/commit/ff0858e978b7f7195f68ad5c9c346723107075fb)
34
+ Type any will try to determine the actual type but gives you flexibility while sanitizing.
35
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
1
36
  <a name="3.9.18"></a>
2
37
 
3
38
  ## [3.9.18](https://github.com/mmpro/ac-sanitizer/compare/v3.9.17..v3.9.18) (2022-04-24 18:09:53)
package/README.md CHANGED
@@ -69,6 +69,7 @@ countrylist | list of country names | e.g. Laos, Brazil, Norway...
69
69
 
70
70
  Type | Options | Remarks
71
71
  --- | --- | --- |
72
+ any | | Any can be string, integer, boolean, object or array - it will be automatically detected.
72
73
  base64 | | Checks if a string is base64 encoded, optional with field option "convert" (to string)
73
74
  boolean | |
74
75
  cidr | | Check CIDR, see example
package/index.js CHANGED
@@ -116,6 +116,31 @@ const sanitizer = function() {
116
116
 
117
117
  if (!error && _.has(paramsToCheck, fieldName)) {
118
118
  /// SPECIAL FIELDS
119
+ // field type any, can be any field
120
+ if (field.type === 'any') {
121
+ if (_.isString(value)) {
122
+ field.type = 'string'
123
+ }
124
+ else if (_.isPlainObject(value)) {
125
+ field.type = 'object'
126
+ }
127
+ else if (_.isArray(value)) {
128
+ field.type = 'array'
129
+ }
130
+ else if (_.isBoolean(value)) {
131
+ field.type = 'boolean'
132
+ }
133
+ else if (_.isInteger(value)) {
134
+ field.type = 'integer'
135
+ }
136
+ else if (_.isFinite(value)) {
137
+ field.type = 'float'
138
+ }
139
+ else {
140
+ error = { message: fieldName + '_couldNotResolveType' }
141
+ }
142
+ }
143
+
119
144
  // special field - can be string or integer -> determine type and then use type settings
120
145
  if (field.type === 'integer | string') {
121
146
  if (!_.isString(value) && !_.isFinite(parseInt(value))) {
@@ -170,27 +195,36 @@ const sanitizer = function() {
170
195
  }
171
196
  else if (_.indexOf(['number', 'integer', 'long', 'short', 'float'], field.type) > -1) {
172
197
  if (typeof value != 'number' || isNaN(value)) error = { message: fieldName + '_' + getTypeMapping('integer', 'errorMessage') }
198
+ else {
199
+ // Number types - usually we allow only non-negative values (unsigned). If you want negative values, set type.subtype 'signed'
200
+ if (field.type === 'number') console.error('SANITIZER - number should not be used, be more precise')
201
+ if (field.type === 'number') field.type = 'integer'
173
202
 
174
- // Number types - usually we allow only non-negative values (unsigned). If you want negative values, set type.subtype 'signed'
175
- if (field.type === 'number') console.error('SANITIZER - number should not be used, be more precise')
176
- if (field.type === 'number') field.type = 'integer'
177
-
178
- const subtype = _.get(field, 'subtype')
179
- let ranges = {
180
- integer: [(subtype === 'signed' ? -Math.pow(2, 31) : 0), Math.pow(2, 31)],
181
- long: [(subtype === 'signed' ? -(Math.pow(2,53) - 1) : 0), Math.pow(2, 53)-1],
182
- short: [(subtype === 'signed' ? -Math.pow(2, 15) : 0), Math.pow(2, 15)],
183
- float: [(subtype === 'signed' ? -Math.pow(2, 31) : 0), Math.pow(2, 31)]
184
- }
185
- let range = _.get(field, 'range', _.get(ranges, field.type, ranges.integer))
203
+ if (field.type === 'float' && value !== parseFloat(value)) {
204
+ error = { message: fieldName + '_not_' + field.type, additionalInfo: { value } }
205
+ }
206
+ else if (field.type !== 'float' && value !== parseInt(value)) {
207
+ error = { message: fieldName + '_typeIncorrect', additionalInfo: { value, int: parseInt(value) } }
208
+ }
209
+ else {
210
+ const subtype = _.get(field, 'subtype')
211
+ let ranges = {
212
+ integer: [(subtype === 'signed' ? -Math.pow(2, 31) : 0), Math.pow(2, 31)],
213
+ long: [(subtype === 'signed' ? -(Math.pow(2,53) - 1) : 0), Math.pow(2, 53)-1],
214
+ short: [(subtype === 'signed' ? -Math.pow(2, 15) : 0), Math.pow(2, 15)],
215
+ float: [(subtype === 'signed' ? -Math.pow(2, 31) : 0), Math.pow(2, 31)]
216
+ }
217
+ let range = _.get(field, 'range', _.get(ranges, field.type, ranges.integer))
186
218
 
187
- if (field.type === 'float') value = parseFloat(value)
188
- else value = parseInt(value)
219
+ if (field.type === 'float') value = parseFloat(value)
220
+ else value = parseInt(value)
189
221
 
190
- let lowest = _.first(range)
191
- let highest = _.size(range) === 2 && _.last(range)
192
- if (value < lowest || (highest && value > highest)) {
193
- error = { message: fieldName + '_outOfRange', additionalInfo: { range, value } }
222
+ let lowest = _.first(range)
223
+ let highest = _.size(range) === 2 && _.last(range)
224
+ if (value < lowest || (highest && value > highest)) {
225
+ error = { message: fieldName + '_outOfRange', additionalInfo: { range, value } }
226
+ }
227
+ }
194
228
  }
195
229
  }
196
230
  else if (field.type === 'string') {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Mark Poepping (https://www.admiralcloud.com)",
5
5
  "license": "MIT",
6
6
  "repository": "admiralcloud/ac-sanitizer",
7
- "version": "3.9.18",
7
+ "version": "3.10.2",
8
8
  "homepage": "https://www.admiralcloud.com",
9
9
  "dependencies": {
10
10
  "ac-countrylist": "^1.0.6",
@@ -12,6 +12,11 @@ module.exports = {
12
12
  tests.error.test()
13
13
  })
14
14
 
15
+ describe('ANY', function() {
16
+ this.timeout(timeOut)
17
+ tests.any.test()
18
+ })
19
+
15
20
  describe('STRING', function() {
16
21
  this.timeout(timeOut)
17
22
  tests.string.test()
@@ -0,0 +1,49 @@
1
+ const _ = require('lodash')
2
+ const expect = require('expect')
3
+ const sanitizer = require('../../index')
4
+
5
+ module.exports = {
6
+
7
+ test: () => {
8
+
9
+ const baseTests = [
10
+ { name: 'Any - with string', type: 'any', value: 'admiralcloud', expected: 'admiralcloud' },
11
+ { name: 'Any - with integer', type: 'any', value: 123, expected: 123 },
12
+ { name: 'Any - with boolean', type: 'any', value: true, expected: true },
13
+ { name: 'Any - with boolean - false', type: 'any', value: false, expected: false },
14
+ { name: 'Any - with object', type: 'any', value: { a: 123 }, expected: { a: 123 } },
15
+ { name: 'Any - with array', type: 'any', value: [1,2,3], expected: [1,2,3] },
16
+ { name: 'Any - with array of objects', type: 'any', value: [{ a: 123 }], expected: [{ a: 123 }] },
17
+ { name: 'Any - with float', type: 'any', value: 123.235, expected: 123.235 },
18
+ { name: 'Any - with Infinity - should fail', type: 'any', value: Infinity, error: 'any_couldNotResolveType' },
19
+ ]
20
+
21
+ _.forEach(baseTests, (test) => {
22
+ it(test.name, (done) => {
23
+ let fieldsToCheck = {
24
+ params: {
25
+ any: _.get(test, 'value')
26
+ },
27
+ fields: [
28
+ { field: 'any', type: _.get(test, 'type') }
29
+ ]
30
+ }
31
+ let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
32
+ if (_.get(r, 'error')) {
33
+ expect(_.get(r, 'error.message')).toEqual(test.error)
34
+ if (_.get(test, 'additionalInfo')) {
35
+ expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
36
+ }
37
+ }
38
+ else {
39
+ expect(_.get(r, 'params.any')).toEqual(_.get(test, 'expected'))
40
+ }
41
+ return done()
42
+ })
43
+
44
+ })
45
+
46
+
47
+
48
+ }
49
+ }
@@ -50,7 +50,7 @@ module.exports = {
50
50
  }
51
51
 
52
52
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
53
- if (_.get(test, 'error')) {
53
+ if (_.get(r, 'error')) {
54
54
  expect(_.get(r, 'error.message')).toEqual(test.error)
55
55
  if (_.get(test, 'additionalInfo')) {
56
56
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -28,7 +28,7 @@ module.exports = {
28
28
  }
29
29
 
30
30
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
31
- if (_.get(test, 'error')) {
31
+ if (_.get(r, 'error')) {
32
32
  expect(_.get(r, 'error.message')).toEqual(test.error)
33
33
  if (_.get(test, 'additionalInfo')) {
34
34
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -28,7 +28,7 @@ module.exports = {
28
28
  }
29
29
 
30
30
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
31
- if (_.get(test, 'error')) {
31
+ if (_.get(r, 'error')) {
32
32
  expect(_.get(r, 'error.message')).toEqual(test.error)
33
33
  if (_.get(test, 'additionalInfo')) {
34
34
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -24,7 +24,7 @@ module.exports = {
24
24
  }
25
25
 
26
26
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
27
- if (_.get(test, 'error')) {
27
+ if (_.get(r, 'error')) {
28
28
  expect(_.get(r, 'error.message')).toEqual(test.error)
29
29
  if (_.get(test, 'additionalInfo')) {
30
30
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -29,7 +29,7 @@ module.exports = {
29
29
  }
30
30
 
31
31
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
32
- if (_.get(test, 'error')) {
32
+ if (_.get(r, 'error')) {
33
33
  expect(_.get(r, 'error.message')).toEqual(test.error)
34
34
  if (_.get(test, 'additionalInfo')) {
35
35
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -25,7 +25,7 @@ module.exports = {
25
25
  }
26
26
 
27
27
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
28
- if (_.get(test, 'error')) {
28
+ if (_.get(r, 'error')) {
29
29
  expect(_.get(r, 'error.message')).toEqual(test.error)
30
30
  if (_.get(test, 'additionalInfo')) {
31
31
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -31,7 +31,7 @@ module.exports = {
31
31
  }
32
32
 
33
33
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
34
- if (_.get(test, 'error')) {
34
+ if (_.get(r, 'error')) {
35
35
  expect(_.get(r, 'error.message')).toEqual(test.error)
36
36
  if (_.get(test, 'additionalInfo')) {
37
37
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -26,7 +26,7 @@ module.exports = {
26
26
  }
27
27
 
28
28
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
29
- if (_.get(test, 'error')) {
29
+ if (_.get(r, 'error')) {
30
30
  expect(_.get(r, 'error.message')).toEqual(test.error)
31
31
  if (_.get(test, 'additionalInfo')) {
32
32
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -17,16 +17,17 @@ module.exports = {
17
17
  it(test.name, (done) => {
18
18
  let fieldsToCheck = {
19
19
  adminLevel: 4,
20
+ omitFields: _.get(test, 'omitFields'),
20
21
  params: {
21
22
  errorField: _.get(test, 'value'),
22
23
  },
23
24
  fields: [
24
- { field: 'errorField', type: _.get(test, 'type'), required: _.get(test, 'required'), adminLevel: _.get(test, 'adminLevel'), omitFields: _.get(test, 'omitFields') }
25
+ { field: 'errorField', type: _.get(test, 'type'), required: _.get(test, 'required'), adminLevel: _.get(test, 'adminLevel') }
25
26
  ]
26
27
  }
27
28
 
28
29
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
29
- if (_.get(test, 'error')) {
30
+ if (_.get(r, 'error')) {
30
31
  expect(_.get(r, 'error.message')).toEqual(test.error)
31
32
  if (_.get(test, 'additionalInfo')) {
32
33
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -25,7 +25,7 @@ module.exports = {
25
25
  }
26
26
 
27
27
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
28
- if (_.get(test, 'error')) {
28
+ if (_.get(r, 'error')) {
29
29
  expect(_.get(r, 'error.message')).toEqual(test.error)
30
30
  if (_.get(test, 'additionalInfo')) {
31
31
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -23,7 +23,7 @@ module.exports = {
23
23
  ]
24
24
  }
25
25
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
26
- if (_.get(test, 'error')) {
26
+ if (_.get(r, 'error')) {
27
27
  expect(_.get(r, 'error.message')).toEqual(test.error)
28
28
  if (_.get(test, 'additionalInfo')) {
29
29
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
package/test/tests/gps.js CHANGED
@@ -28,7 +28,7 @@ module.exports = {
28
28
  }
29
29
 
30
30
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
31
- if (_.get(test, 'error')) {
31
+ if (_.get(r, 'error')) {
32
32
  expect(_.get(r, 'error.message')).toEqual(test.error)
33
33
  if (_.get(test, 'additionalInfo')) {
34
34
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -28,7 +28,7 @@ module.exports = {
28
28
  }
29
29
 
30
30
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
31
- if (_.get(test, 'error')) {
31
+ if (_.get(r, 'error')) {
32
32
  expect(_.get(r, 'error.message')).toEqual(test.error)
33
33
  if (_.get(test, 'additionalInfo')) {
34
34
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -25,7 +25,7 @@ module.exports = {
25
25
  }
26
26
 
27
27
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
28
- if (_.get(test, 'error')) {
28
+ if (_.get(r, 'error')) {
29
29
  expect(_.get(r, 'error.message')).toEqual(test.error)
30
30
  if (_.get(test, 'additionalInfo')) {
31
31
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -1,4 +1,5 @@
1
1
  module.exports = {
2
+ any: require('./any'),
2
3
  array: require('./array'),
3
4
  base64: require('./base64'),
4
5
  bool: require('./bool'),
package/test/tests/ip.js CHANGED
@@ -26,7 +26,7 @@ module.exports = {
26
26
  }
27
27
 
28
28
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
29
- if (_.get(test, 'error')) {
29
+ if (_.get(r, 'error')) {
30
30
  expect(_.get(r, 'error.message')).toEqual(test.error)
31
31
  if (_.get(test, 'additionalInfo')) {
32
32
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -101,6 +101,7 @@ module.exports = {
101
101
  { name: 'Unsigned float -1 - should fail and display additionalInfo', type: 'float', value: -1, error: 'number_outOfRange', additionalInfo: { range: [0,2147483648], value: -1 } },
102
102
  { name: 'Array of numbers with one entry', type: 'integer', value: [123], error: 'number_notAFiniteNumber' },
103
103
  { name: 'Array of numbers with multiple entries', type: 'integer', value: [123, 456], error: 'number_notAFiniteNumber' },
104
+ { name: 'Check float', type: 'float', range: [-90, 90], value: 53.15, expected: 53.15 }
104
105
  ]
105
106
 
106
107
  _.forEach(tests, (test) => {
@@ -115,7 +116,7 @@ module.exports = {
115
116
  }
116
117
 
117
118
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
118
- if (_.get(test, 'error')) {
119
+ if (_.get(r, 'error')) {
119
120
  expect(_.get(r, 'error.message')).toEqual(test.error)
120
121
  if (_.get(test, 'additionalInfo')) {
121
122
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -181,7 +181,7 @@ module.exports = {
181
181
  ],
182
182
  };
183
183
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck);
184
- if (_.get(test, 'error')) {
184
+ if (_.get(r, 'error')) {
185
185
  expect(_.get(r, 'error.message')).toEqual(test.error)
186
186
  if (_.get(test, 'additionalInfo')) {
187
187
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -26,7 +26,7 @@ module.exports = {
26
26
  }
27
27
 
28
28
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
29
- if (_.get(test, 'error')) {
29
+ if (_.get(r, 'error')) {
30
30
  expect(_.get(r, 'error.message')).toEqual(test.error)
31
31
  if (_.get(test, 'additionalInfo')) {
32
32
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
package/test/tests/rgb.js CHANGED
@@ -28,7 +28,7 @@ module.exports = {
28
28
  }
29
29
 
30
30
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
31
- if (_.get(test, 'error')) {
31
+ if (_.get(r, 'error')) {
32
32
  expect(_.get(r, 'error.message')).toEqual(test.error)
33
33
  if (_.get(test, 'additionalInfo')) {
34
34
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -32,7 +32,7 @@ module.exports = {
32
32
  }
33
33
 
34
34
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
35
- if (_.get(test, 'error')) {
35
+ if (_.get(r, 'error')) {
36
36
  expect(_.get(r, 'error.message')).toEqual(test.error)
37
37
  if (_.get(test, 'additionalInfo')) {
38
38
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -20,13 +20,13 @@ module.exports = {
20
20
  let fieldsToCheck = {
21
21
  params: {},
22
22
  fields: [
23
- { field: 'stringOrInteger', type: _.get(test, 'type'), required: _.get(test, 'required') }
23
+ { field: 'stringOrInteger', type: _.get(test, 'type'), required: _.get(test, 'required'), minLength: _.get(test, 'minLength') }
24
24
  ]
25
25
  }
26
26
  if (_.has(test, 'value')) fieldsToCheck.params.stringOrInteger = test.value
27
27
 
28
28
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
29
- if (_.get(test, 'error')) {
29
+ if (_.get(r, 'error')) {
30
30
  expect(_.get(r, 'error.message')).toEqual(test.error)
31
31
  if (_.get(test, 'additionalInfo')) {
32
32
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
package/test/tests/url.js CHANGED
@@ -24,7 +24,7 @@ module.exports = {
24
24
  }
25
25
 
26
26
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
27
- if (_.get(test, 'error')) {
27
+ if (_.get(r, 'error')) {
28
28
  expect(_.get(r, 'error.message')).toEqual(test.error)
29
29
  if (_.get(test, 'additionalInfo')) {
30
30
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))
@@ -25,7 +25,7 @@ module.exports = {
25
25
  }
26
26
 
27
27
  let r = sanitizer.checkAndSanitizeValues(fieldsToCheck)
28
- if (_.get(test, 'error')) {
28
+ if (_.get(r, 'error')) {
29
29
  expect(_.get(r, 'error.message')).toEqual(test.error)
30
30
  if (_.get(test, 'additionalInfo')) {
31
31
  expect(_.get(r, 'error.additionalInfo')).toEqual(_.get(test, 'additionalInfo'))