node_modules: update

This commit is contained in:
Dawid Dziurla 2020-11-12 16:37:43 +01:00
parent 4a21c51f2f
commit b91baffed3
No known key found for this signature in database
GPG key ID: 7B6D8368172E9B0B
107 changed files with 3886 additions and 2943 deletions

View file

@ -5,6 +5,7 @@ const fastRedact = require('..')
const censor = '[REDACTED]'
const censorFct = value => !value ? value : 'xxx' + value.substr(-2)
const censorWithPath = (v, p) => p.join('.') + ' ' + censorFct(v)
test('returns no-op when passed no paths [serialize: false]', ({ end, doesNotThrow }) => {
const redact = fastRedact({ paths: [], serialize: false })
@ -88,23 +89,27 @@ test('returns original value when passed non-object using [strict: false, serial
end()
})
test('throws if a path is not a string', ({ end, is, throws }) => {
test('throws if a path is not a string', ({ end, throws }) => {
const invalidTypeMsg = 'fast-redact - Paths must be (non-empty) strings'
throws((e) => {
fastRedact({ paths: [1] })
}, Error('fast-redact - Paths must be strings'))
}, Error(invalidTypeMsg))
throws((e) => {
fastRedact({ paths: [null] })
}, Error('fast-redact - Paths must be strings'))
}, Error(invalidTypeMsg))
throws((e) => {
fastRedact({ paths: [undefined] })
}, Error('fast-redact - Paths must be strings'))
}, Error(invalidTypeMsg))
throws((e) => {
fastRedact({ paths: [{}] })
}, Error('fast-redact - Paths must be strings'))
}, Error(invalidTypeMsg))
throws((e) => {
fastRedact({ paths: [[null]] })
}, Error(invalidTypeMsg))
end()
})
test('throws when passed illegal paths', ({ end, is, throws }) => {
test('throws when passed illegal paths', ({ end, throws }) => {
const err = (s) => Error(`fast-redact Invalid path (${s})`)
throws((e) => {
fastRedact({ paths: ['@'] })
@ -193,6 +198,12 @@ test('throws when passed illegal paths', ({ end, is, throws }) => {
throws((e) => {
fastRedact({ paths: ['a\r'] })
}, err('a\r'))
throws((e) => {
fastRedact({ paths: [''] })
}, err(''))
throws((e) => {
fastRedact({ paths: ['[""""]'] })
}, err('[""""]'))
end()
})
@ -217,6 +228,42 @@ test('throws if serialize is false and remove is true', ({ end, throws }) => {
end()
})
test('supports path segments that aren\'t identifiers if bracketed', ({ end, strictSame }) => {
const redactSerializeFalse = fastRedact({
paths: ['a[""]', 'a["x-y"]', 'a[\'"y"\']', "a['\\'x\\'']"],
serialize: false,
censor: 'X'
})
const res = redactSerializeFalse({ a: { '': 'Hi!', 'x-y': 'Hi!', '"y"': 'Hi!', "'x'": 'Hi!' } })
strictSame(res, { a: { '': 'X', 'x-y': 'X', '"y"': 'X', "'x'": 'X' } })
end()
})
test('supports consecutive bracketed path segments', ({ end, strictSame }) => {
const redactSerializeFalse = fastRedact({
paths: ['a[""]["y"]'],
serialize: false,
censor: 'X'
})
const res = redactSerializeFalse({ a: { '': { 'y': 'Hi!' } } })
strictSame(res, { a: { '': { 'y': 'X' } } })
end()
})
test('supports leading bracketed widcard', ({ end, strictSame }) => {
const redactSerializeFalse = fastRedact({
paths: ['[*]["y"]'],
serialize: false,
censor: 'X'
})
const res = redactSerializeFalse({ 'x': { 'y': 'Hi!' } })
strictSame(res, { 'x': { 'y': 'X' } })
end()
})
test('masks according to supplied censor', ({ end, is }) => {
const censor = 'test'
const redact = fastRedact({ paths: ['a'], censor, serialize: false })
@ -262,6 +309,26 @@ test('masks according to supplied censor function with nested wildcards', ({ end
end()
})
test('masks according to supplied censor-with-path function', ({ end, is }) => {
const redact = fastRedact({ paths: ['a'], censor: censorWithPath, serialize: false })
is(redact({ a: '0123456' }).a, 'a xxx56')
end()
})
test('masks according to supplied censor-with-path function with wildcards', ({ end, is }) => {
const redact = fastRedact({ paths: '*', censor: censorWithPath, serialize: false })
is(redact({ a: '0123456' }).a, 'a xxx56')
end()
})
test('masks according to supplied censor-with-path function with nested wildcards', ({ end, is }) => {
const redact = fastRedact({ paths: ['*.b'], censor: censorWithPath, serialize: false })
is(redact({ a: { b: '0123456' } }).a.b, 'a.b xxx56')
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.b, 'c.b xxx56')
is(redact({ c: { b: '0123456', d: 'pristine' } }).c.d, 'pristine')
end()
})
test('redact.restore function places original values back in place with censor function', ({ end, is }) => {
const redact = fastRedact({ paths: ['a'], censor: censorFct, serialize: false })
const o = { a: 'qwerty' }