renovate/lib/util/sanitize.spec.ts
2020-03-05 21:57:24 +01:00

25 lines
671 B
TypeScript

import { add, clear, sanitize } from './sanitize';
describe('util/sanitize', () => {
beforeEach(() => {
clear();
});
it('sanitizes empty string', () => {
expect(sanitize(null)).toEqual(null);
});
it('sanitizes secrets from strings', () => {
const token = 'abc123token';
const username = 'userabc';
const password = 'password123';
add(token);
const hashed = Buffer.from(`${username}:${password}`).toString('base64');
add(hashed);
add(password);
expect(
sanitize(
`My token is ${token}, username is "${username}" and password is "${password}" (hashed: ${hashed})`
)
).toMatchSnapshot();
});
});