Path: blob/main/extensions/copilot/src/util/node/test/pathRedaction.spec.ts
13401 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import assert from 'assert';6import { beforeEach, suite, test } from 'vitest';7import { redactPaths } from '../../common/pathRedaction';89suite('Path redaction', () => {10beforeEach(() => { });1112test('returns input', function () {13const input = 'abc';14const output = redactPaths(input);15assert.deepStrictEqual(output, 'abc');16});1718test('leaves urls intact', function () {19const input = 'foo http://github.com/github/copilot bar';20const output = redactPaths(input);21assert.deepStrictEqual(output, 'foo http://github.com/github/copilot bar');22});2324test('filter unix path', function () {25assertRedacted('foo /Users/copilot bar', 'foo [redacted] bar');26});2728test('path in parenthesis', function () {29assertRedacted('See details (/Users/copilot)', 'See details ([redacted]');30});3132test('filter windows path', function () {33assertRedacted('foo C:\\Windows\\System32 bar', 'foo [redacted] bar');34assertRedacted('foo d:\\Windows\\System32 bar', 'foo [redacted] bar');35assertRedacted(36'foo C:/Users/XXX/IdeaProjects/TesteUnitario/src/test/kotlin/MainTest.kt bar',37'foo [redacted] bar'38);39assertRedacted('foo Z:\\projects/MainTest.kt bar', 'foo [redacted] bar');40});4142test('filter unc path', function () {43assertRedacted('foo \\server-name\\shared-resource-pathname bar', 'foo [redacted] bar');44assertRedacted('foo file://\\server-name\\shared-resource-pathname bar', 'foo file://[redacted] bar');45});4647test('file urls', function () {48assertRedacted(49'Invalid file file://C:/Users/XXX/IdeaProjects/kotlin/MainTest.kt bar',50'Invalid file file://[redacted] bar'51);52assertRedacted('Invalid file file:///Users/copilot bar', 'Invalid file file://[redacted] bar');53});5455function assertRedacted(input: string, output: string) {56assert.deepStrictEqual(redactPaths(input), output);57}58});596061