|
| 1 | +import { readFileSync, existsSync } from 'fs'; |
| 2 | +import { join } from 'path'; |
| 3 | +import './test-framework'; |
| 4 | + |
| 5 | +const PATCHED_VSCODE_DIR = join(process.cwd(), 'code-editor-src'); |
| 6 | + |
| 7 | +describe('disable-telemetry.diff validation', () => { |
| 8 | + test('telemetryService.ts should have telemetry disabled by default', () => { |
| 9 | + const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/platform/telemetry/common/telemetryService.ts'); |
| 10 | + |
| 11 | + if (!existsSync(filePath)) { |
| 12 | + throw new Error(`File not found: ${filePath}`); |
| 13 | + } |
| 14 | + |
| 15 | + const content = readFileSync(filePath, 'utf8'); |
| 16 | + |
| 17 | + // Check that enum only contains OFF |
| 18 | + const enumLine = "'enum': [TelemetryConfiguration.OFF],"; |
| 19 | + if (!content.includes(enumLine)) { |
| 20 | + throw new Error(`Expected telemetry enum restriction not found in ${filePath}`); |
| 21 | + } |
| 22 | + |
| 23 | + // Check that default is OFF |
| 24 | + const defaultLine = "'default': TelemetryConfiguration.OFF,"; |
| 25 | + if (!content.includes(defaultLine)) { |
| 26 | + throw new Error(`Expected telemetry default OFF not found in ${filePath}`); |
| 27 | + } |
| 28 | + |
| 29 | + console.log('PASS: Telemetry disabled by default in telemetryService.ts'); |
| 30 | + }); |
| 31 | + |
| 32 | + test('desktop.contribution.ts should have crash reporter disabled', () => { |
| 33 | + const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/workbench/electron-sandbox/desktop.contribution.ts'); |
| 34 | + |
| 35 | + if (!existsSync(filePath)) { |
| 36 | + throw new Error(`File not found: ${filePath}`); |
| 37 | + } |
| 38 | + |
| 39 | + const content = readFileSync(filePath, 'utf8'); |
| 40 | + |
| 41 | + // Check crash reporter is disabled |
| 42 | + const crashReporterDisabled = "'default': false,"; |
| 43 | + if (!content.includes(crashReporterDisabled)) { |
| 44 | + throw new Error(`Expected crash reporter disabled not found in ${filePath}`); |
| 45 | + } |
| 46 | + |
| 47 | + console.log('PASS: Crash reporter disabled in desktop.contribution.ts'); |
| 48 | + }); |
| 49 | + |
| 50 | + test('1dsAppender.ts should have Microsoft endpoints blocked', () => { |
| 51 | + const filePath = join(PATCHED_VSCODE_DIR, 'src/vs/platform/telemetry/common/1dsAppender.ts'); |
| 52 | + |
| 53 | + if (!existsSync(filePath)) { |
| 54 | + throw new Error(`File not found: ${filePath}`); |
| 55 | + } |
| 56 | + |
| 57 | + const content = readFileSync(filePath, 'utf8'); |
| 58 | + |
| 59 | + // Check endpoints are redirected to 0.0.0.0 |
| 60 | + const blockedEndpoint = "const endpointUrl = 'https://0.0.0.0/OneCollector/1.0';"; |
| 61 | + const blockedHealthEndpoint = "const endpointHealthUrl = 'https://0.0.0.0/ping';"; |
| 62 | + |
| 63 | + if (!content.includes(blockedEndpoint)) { |
| 64 | + throw new Error(`Expected blocked endpoint not found in ${filePath}`); |
| 65 | + } |
| 66 | + |
| 67 | + if (!content.includes(blockedHealthEndpoint)) { |
| 68 | + throw new Error(`Expected blocked health endpoint not found in ${filePath}`); |
| 69 | + } |
| 70 | + |
| 71 | + console.log('PASS: Microsoft telemetry endpoints blocked in 1dsAppender.ts'); |
| 72 | + }); |
| 73 | +}); |
0 commit comments