mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-14 16:46:25 +00:00
25 lines
668 B
TypeScript
25 lines
668 B
TypeScript
import { add, clear, sanitize } from './sanitize';
|
|
|
|
describe('util/sanitize', () => {
|
|
beforeEach(() => {
|
|
clear();
|
|
});
|
|
|
|
it('sanitizes empty string', () => {
|
|
expect(sanitize(null)).toBeNull();
|
|
});
|
|
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();
|
|
});
|
|
});
|