-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82a90ee
commit 780727b
Showing
9 changed files
with
1,203 additions
and
1,386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,3 @@ | ||
import { Scrubber } from './scrubber' | ||
import { ScrubberConfig } from './scrubber.model' | ||
import { undefinedScrubber, UndefinedScrubberFn } from './scrubbers' | ||
import { preserveOriginalScrubber, PreserveOriginalScrubberFn } from './scrubbers' | ||
import { staticScrubber, StaticScrubberFn, StaticScrubberParams } from './scrubbers' | ||
import { | ||
isoDateStringScrubber, | ||
ISODateStringScrubberFn, | ||
ISODateStringScrubberParams, | ||
} from './scrubbers' | ||
import { | ||
unixTimestampScrubber, | ||
UnixTimestampScrubberFn, | ||
UnixTimestampScrubberParams, | ||
} from './scrubbers' | ||
import { | ||
charsFromRightScrubber, | ||
CharsFromRightScrubberFn, | ||
CharsFromRightScrubberParams, | ||
} from './scrubbers' | ||
import { randomScrubber, RandomScrubberFn, RandomScrubberParams } from './scrubbers' | ||
import { randomEmailScrubber, RandomEmailScrubberFn, RandomEmailScrubberParams } from './scrubbers' | ||
import { saltedHashScrubber, SaltedHashScrubberFn, SaltedHashScrubberParams } from './scrubbers' | ||
|
||
export type { | ||
ScrubberConfig, | ||
UndefinedScrubberFn, | ||
PreserveOriginalScrubberFn, | ||
StaticScrubberParams, | ||
StaticScrubberFn, | ||
UnixTimestampScrubberFn, | ||
UnixTimestampScrubberParams, | ||
ISODateStringScrubberFn, | ||
ISODateStringScrubberParams, | ||
CharsFromRightScrubberFn, | ||
CharsFromRightScrubberParams, | ||
RandomScrubberFn, | ||
RandomScrubberParams, | ||
RandomEmailScrubberFn, | ||
RandomEmailScrubberParams, | ||
SaltedHashScrubberFn, | ||
SaltedHashScrubberParams, | ||
} | ||
|
||
export { Scrubber } | ||
export { undefinedScrubber } | ||
export { preserveOriginalScrubber } | ||
export { staticScrubber } | ||
export { unixTimestampScrubber } | ||
export { isoDateStringScrubber } | ||
export { charsFromRightScrubber } | ||
export { randomScrubber } | ||
export { randomEmailScrubber } | ||
export { saltedHashScrubber } | ||
export * from './scrubber' | ||
export * from './scrubber.model' | ||
export * from './scrubbers' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { nanoid } from 'nanoid' | ||
import { deepFreeze } from '@naturalcycles/dev-lib/dist/testing' | ||
import { _deepFreeze } from '@naturalcycles/js-lib' | ||
import { nanoid } from '@naturalcycles/nodejs-lib' | ||
import { Scrubber } from './scrubber' | ||
import { ScrubberConfig, ScrubberFn, ScrubbersMap } from './scrubber.model' | ||
import { saltedHashEmailScrubber, saltedHashScrubber } from './scrubbers' | ||
|
@@ -36,22 +36,22 @@ test('returns an array with one object when input is an array with one object', | |
|
||
test('applies to more than a field', () => { | ||
const data = [{ pw: 'secret', name: 'Real Name' }] | ||
deepFreeze(data) // Ensure data doesnt mutate | ||
_deepFreeze(data) // Ensure data doesnt mutate | ||
const result = scrub(data) | ||
expect(result).toEqual([{ pw: 'notsecret', name: 'Jane Doe' }]) | ||
}) | ||
|
||
test('applies to nested fields (deep transverse, 2 levels)', () => { | ||
const data = [{ account: { pw: 'secret', name: 'Real Name' } }] | ||
deepFreeze(data) // Ensure data doesnt mutate | ||
_deepFreeze(data) // Ensure data doesnt mutate | ||
|
||
const result = scrub(data) | ||
expect(result).toEqual([{ account: { pw: 'notsecret', name: 'Jane Doe' } }]) | ||
}) | ||
|
||
test('applies to nested fields (deep transverse, 3 levels)', () => { | ||
const data = [{ object: { account: { pw: 'secret', name: 'Real Name' } } }] | ||
deepFreeze(data) // Ensure data doesnt mutate | ||
_deepFreeze(data) // Ensure data doesnt mutate | ||
|
||
const result = scrub(data) | ||
expect(result).toEqual([{ object: { account: { pw: 'notsecret', name: 'Jane Doe' } } }]) | ||
|
@@ -61,7 +61,7 @@ test('applies to nested arrays', () => { | |
const obj1 = { pw: 'shouldChange', safe: 'shouldStay' } | ||
const obj2 = { name: 'personalInformation', safe2: 'isSafe' } | ||
const users = [{ users: [obj1, obj2] }] | ||
deepFreeze(users) | ||
_deepFreeze(users) | ||
|
||
const result = scrub(users) | ||
expect(result[0]!['users'][0]).toEqual({ pw: 'notsecret', safe: 'shouldStay' }) | ||
|
@@ -71,7 +71,7 @@ test('applies to nested arrays', () => { | |
|
||
test('keeps not modified fields', () => { | ||
const data = [{ safeField: 'keep', email: '[email protected]' }] | ||
deepFreeze(data) // Ensure data doesnt mutate | ||
_deepFreeze(data) // Ensure data doesnt mutate | ||
|
||
const result = scrub(data, configEmailScrubberMock()) | ||
expect(result).toEqual([{ safeField: 'keep', email: '[email protected]' }]) | ||
|
@@ -90,15 +90,15 @@ test('supports additional scrubbers', () => { | |
} | ||
|
||
const data = [{ target: 'original' }] | ||
deepFreeze(data) // Ensure data doesnt mutate | ||
_deepFreeze(data) // Ensure data doesnt mutate | ||
|
||
const result = scrub(data, cfg, additionalScrubbers) | ||
expect(result).toEqual([{ target: 'modified' }]) | ||
}) | ||
|
||
test('supports comma-separated fields in field name', () => { | ||
const data = [{ field1: 'orig1', field2: 'orig2' }] | ||
deepFreeze(data) // Ensure data doesnt mutate | ||
_deepFreeze(data) // Ensure data doesnt mutate | ||
|
||
const result = scrub(data, configMultiFieldMock()) | ||
expect(result).toEqual([{ field1: 'modified', field2: 'modified' }]) | ||
|
@@ -216,7 +216,7 @@ test('initializationVector is passed as param to scrubbers', () => { | |
} | ||
|
||
const data = [{ pw: 'secret' }] | ||
deepFreeze(data) // Ensure data doesnt mutate | ||
_deepFreeze(data) // Ensure data doesnt mutate | ||
|
||
const scrubber = new Scrubber(cfg, additionalScrubbers) | ||
scrubber.scrub(data) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.