Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/util/node/test/pathRedaction.spec.ts
13401 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import assert from 'assert';
7
import { beforeEach, suite, test } from 'vitest';
8
import { redactPaths } from '../../common/pathRedaction';
9
10
suite('Path redaction', () => {
11
beforeEach(() => { });
12
13
test('returns input', function () {
14
const input = 'abc';
15
const output = redactPaths(input);
16
assert.deepStrictEqual(output, 'abc');
17
});
18
19
test('leaves urls intact', function () {
20
const input = 'foo http://github.com/github/copilot bar';
21
const output = redactPaths(input);
22
assert.deepStrictEqual(output, 'foo http://github.com/github/copilot bar');
23
});
24
25
test('filter unix path', function () {
26
assertRedacted('foo /Users/copilot bar', 'foo [redacted] bar');
27
});
28
29
test('path in parenthesis', function () {
30
assertRedacted('See details (/Users/copilot)', 'See details ([redacted]');
31
});
32
33
test('filter windows path', function () {
34
assertRedacted('foo C:\\Windows\\System32 bar', 'foo [redacted] bar');
35
assertRedacted('foo d:\\Windows\\System32 bar', 'foo [redacted] bar');
36
assertRedacted(
37
'foo C:/Users/XXX/IdeaProjects/TesteUnitario/src/test/kotlin/MainTest.kt bar',
38
'foo [redacted] bar'
39
);
40
assertRedacted('foo Z:\\projects/MainTest.kt bar', 'foo [redacted] bar');
41
});
42
43
test('filter unc path', function () {
44
assertRedacted('foo \\server-name\\shared-resource-pathname bar', 'foo [redacted] bar');
45
assertRedacted('foo file://\\server-name\\shared-resource-pathname bar', 'foo file://[redacted] bar');
46
});
47
48
test('file urls', function () {
49
assertRedacted(
50
'Invalid file file://C:/Users/XXX/IdeaProjects/kotlin/MainTest.kt bar',
51
'Invalid file file://[redacted] bar'
52
);
53
assertRedacted('Invalid file file:///Users/copilot bar', 'Invalid file file://[redacted] bar');
54
});
55
56
function assertRedacted(input: string, output: string) {
57
assert.deepStrictEqual(redactPaths(input), output);
58
}
59
});
60
61