Format all source code using Prettier
This commit is contained in:
parent
b4dee3f30b
commit
1dd87ad197
149 changed files with 17847 additions and 15439 deletions
|
@ -4,17 +4,18 @@ const { assert } = require('chai');
|
|||
|
||||
const Privacy = require('../../js/modules/privacy');
|
||||
|
||||
|
||||
const APP_ROOT_PATH = path.join(__dirname, '..', '..', '..');
|
||||
|
||||
describe('Privacy', () => {
|
||||
describe('redactPhoneNumbers', () => {
|
||||
it('should redact all phone numbers', () => {
|
||||
const text = 'This is a log line with a phone number +12223334455\n' +
|
||||
const text =
|
||||
'This is a log line with a phone number +12223334455\n' +
|
||||
'and another one +13334445566';
|
||||
|
||||
const actual = Privacy.redactPhoneNumbers(text);
|
||||
const expected = 'This is a log line with a phone number +[REDACTED]455\n' +
|
||||
const expected =
|
||||
'This is a log line with a phone number +[REDACTED]455\n' +
|
||||
'and another one +[REDACTED]566';
|
||||
assert.equal(actual, expected);
|
||||
});
|
||||
|
@ -22,11 +23,13 @@ describe('Privacy', () => {
|
|||
|
||||
describe('redactGroupIds', () => {
|
||||
it('should redact all group IDs', () => {
|
||||
const text = 'This is a log line with two group IDs: group(123456789)\n' +
|
||||
const text =
|
||||
'This is a log line with two group IDs: group(123456789)\n' +
|
||||
'and group(abcdefghij)';
|
||||
|
||||
const actual = Privacy.redactGroupIds(text);
|
||||
const expected = 'This is a log line with two group IDs: group([REDACTED]789)\n' +
|
||||
const expected =
|
||||
'This is a log line with two group IDs: group([REDACTED]789)\n' +
|
||||
'and group([REDACTED]hij)';
|
||||
assert.equal(actual, expected);
|
||||
});
|
||||
|
@ -35,7 +38,8 @@ describe('Privacy', () => {
|
|||
describe('redactAll', () => {
|
||||
it('should redact all sensitive information', () => {
|
||||
const encodedAppRootPath = APP_ROOT_PATH.replace(/ /g, '%20');
|
||||
const text = 'This is a log line with sensitive information:\n' +
|
||||
const text =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
`path1 ${APP_ROOT_PATH}/main.js\n` +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
|
@ -44,7 +48,8 @@ describe('Privacy', () => {
|
|||
'group2 group(abcdefghij) doloret\n';
|
||||
|
||||
const actual = Privacy.redactAll(text);
|
||||
const expected = 'This is a log line with sensitive information:\n' +
|
||||
const expected =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
'path1 [REDACTED]/main.js\n' +
|
||||
'phone1 +[REDACTED]455 ipsum\n' +
|
||||
'group1 group([REDACTED]789) doloret\n' +
|
||||
|
@ -58,12 +63,14 @@ describe('Privacy', () => {
|
|||
describe('_redactPath', () => {
|
||||
it('should redact file paths', () => {
|
||||
const testPath = '/Users/meow/Library/Application Support/Signal Beta';
|
||||
const text = 'This is a log line with sensitive information:\n' +
|
||||
const text =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
`path1 ${testPath}/main.js\n` +
|
||||
'phone1 +12223334455 ipsum\n';
|
||||
|
||||
const actual = Privacy._redactPath(testPath)(text);
|
||||
const expected = 'This is a log line with sensitive information:\n' +
|
||||
const expected =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
'path1 [REDACTED]/main.js\n' +
|
||||
'phone1 +12223334455 ipsum\n';
|
||||
assert.equal(actual, expected);
|
||||
|
@ -72,14 +79,16 @@ describe('Privacy', () => {
|
|||
it('should redact URL-encoded paths', () => {
|
||||
const testPath = '/Users/meow/Library/Application Support/Signal Beta';
|
||||
const encodedTestPath = encodeURI(testPath);
|
||||
const text = 'This is a log line with sensitive information:\n' +
|
||||
const text =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
`path1 ${testPath}/main.js\n` +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
`path2 file:///${encodedTestPath}/js/background.js.`;
|
||||
|
||||
const actual = Privacy._redactPath(testPath)(text);
|
||||
const expected = 'This is a log line with sensitive information:\n' +
|
||||
const expected =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
'path1 [REDACTED]/main.js\n' +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
|
@ -88,17 +97,20 @@ describe('Privacy', () => {
|
|||
});
|
||||
|
||||
it('should redact stack traces with both forward and backslashes', () => {
|
||||
const testPath = 'C:/Users/Meow/AppData/Local/Programs/signal-desktop-beta';
|
||||
const testPath =
|
||||
'C:/Users/Meow/AppData/Local/Programs/signal-desktop-beta';
|
||||
const modifiedTestPath =
|
||||
'C:\\Users\\Meow\\AppData\\Local\\Programs\\signal-desktop-beta';
|
||||
const text = 'This is a log line with sensitive information:\n' +
|
||||
const text =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
`path1 ${testPath}\\main.js\n` +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
`path2 ${modifiedTestPath}\\js\\background.js.`;
|
||||
|
||||
const actual = Privacy._redactPath(testPath)(text);
|
||||
const expected = 'This is a log line with sensitive information:\n' +
|
||||
const expected =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
'path1 [REDACTED]\\main.js\n' +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
|
@ -107,17 +119,20 @@ describe('Privacy', () => {
|
|||
});
|
||||
|
||||
it('should redact stack traces with escaped backslashes', () => {
|
||||
const testPath = 'C:\\Users\\Meow\\AppData\\Local\\Programs\\signal-desktop-beta';
|
||||
const testPath =
|
||||
'C:\\Users\\Meow\\AppData\\Local\\Programs\\signal-desktop-beta';
|
||||
const modifiedTestPath =
|
||||
'C:\\\\Users\\\\Meow\\\\AppData\\\\Local\\\\Programs\\\\signal-desktop-beta';
|
||||
const text = 'This is a log line with sensitive information:\n' +
|
||||
const text =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
`path1 ${testPath}\\main.js\n` +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
`path2 ${modifiedTestPath}\\js\\background.js.`;
|
||||
|
||||
const actual = Privacy._redactPath(testPath)(text);
|
||||
const expected = 'This is a log line with sensitive information:\n' +
|
||||
const expected =
|
||||
'This is a log line with sensitive information:\n' +
|
||||
'path1 [REDACTED]\\main.js\n' +
|
||||
'phone1 +12223334455 ipsum\n' +
|
||||
'group1 group(123456789) doloret\n' +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue