79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
const expect = require('chai').expect
|
|
const { redactSensitiveVariables } = require('@/logging/loggingHelper')
|
|
|
|
describe('loggingHelper', () => {
|
|
describe('filterSensitiveVariables', () => {
|
|
it('should filter sensitive variables at root', () => {
|
|
const variables = {
|
|
email: 'exampleValue',
|
|
emailaddress: 'exampleValue',
|
|
// eslint-disable-next-line camelcase
|
|
email_address: 'exampleValue',
|
|
emails: 'exampleValue',
|
|
notsensitive: 'exampleValue'
|
|
}
|
|
const result = redactSensitiveVariables(variables)
|
|
expect(result).to.deep.equal({
|
|
email: '[REDACTED]',
|
|
emailaddress: '[REDACTED]',
|
|
// eslint-disable-next-line camelcase
|
|
email_address: '[REDACTED]',
|
|
emails: '[REDACTED]',
|
|
notsensitive: 'exampleValue'
|
|
})
|
|
})
|
|
it('should filter nested sensitive variables', () => {
|
|
const variables = {
|
|
nest1: {
|
|
email: 'exampleValue',
|
|
emailaddress: 'exampleValue',
|
|
// eslint-disable-next-line camelcase
|
|
email_address: 'exampleValue',
|
|
emails: 'exampleValue'
|
|
}
|
|
}
|
|
const result = redactSensitiveVariables(variables)
|
|
expect(result).to.deep.equal({
|
|
nest1: {
|
|
email: '[REDACTED]',
|
|
emailaddress: '[REDACTED]',
|
|
// eslint-disable-next-line camelcase
|
|
email_address: '[REDACTED]',
|
|
emails: '[REDACTED]'
|
|
}
|
|
})
|
|
})
|
|
it('should filter sensitive variables in tree structure', () => {
|
|
const variables = {
|
|
nest1: {
|
|
nest2: {
|
|
// eslint-disable-next-line camelcase
|
|
email_address: 'exampleValue',
|
|
emails: 'exampleValue',
|
|
notsensitive: 'exampleValue'
|
|
},
|
|
nest3: {
|
|
email: 'exampleValue',
|
|
emailaddress: 'exampleValue'
|
|
}
|
|
}
|
|
}
|
|
const result = redactSensitiveVariables(variables)
|
|
expect(result).to.deep.equal({
|
|
nest1: {
|
|
nest2: {
|
|
// eslint-disable-next-line camelcase
|
|
email_address: '[REDACTED]',
|
|
emails: '[REDACTED]',
|
|
notsensitive: 'exampleValue'
|
|
},
|
|
nest3: {
|
|
email: '[REDACTED]',
|
|
emailaddress: '[REDACTED]'
|
|
}
|
|
}
|
|
})
|
|
})
|
|
})
|
|
})
|