forked from felicienfrancois/node-electron-proxy-agent
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsanitizeProxyResultCredentials.test.ts
More file actions
57 lines (49 loc) · 1.88 KB
/
sanitizeProxyResultCredentials.test.ts
File metadata and controls
57 lines (49 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import * as assert from 'assert';
import { sanitizeProxyResultCredentials } from '../../src/agent';
describe('sanitizeProxyResultCredentials', function () {
it('should replace user:pass with placeholder in PROXY target', function () {
assert.strictEqual(
sanitizeProxyResultCredentials('PROXY testuser:testpass@host:8080'),
'PROXY <credentials>@host:8080'
);
});
it('should replace user:pass with special chars', function () {
assert.strictEqual(
sanitizeProxyResultCredentials('PROXY jane.fictional%40corp.example.com:fictional123@proxy.fictional.example.com:8080'),
'PROXY <credentials>@proxy.fictional.example.com:8080'
);
});
it('should replace user-only (no password) with placeholder', function () {
assert.strictEqual(
sanitizeProxyResultCredentials('PROXY fictional-user@proxy.fictional.example.com:3128'),
'PROXY <credentials>@proxy.fictional.example.com:3128'
);
});
it('should replace credentials from HTTPS proxy', function () {
assert.strictEqual(
sanitizeProxyResultCredentials('HTTPS fictional-user:fictional-pass@proxy.fictional.example.com:8443'),
'HTTPS <credentials>@proxy.fictional.example.com:8443'
);
});
it('should not modify PROXY without credentials', function () {
assert.strictEqual(
sanitizeProxyResultCredentials('PROXY proxy.fictional.example.com:8080'),
'PROXY proxy.fictional.example.com:8080'
);
});
it('should not modify DIRECT', function () {
assert.strictEqual(
sanitizeProxyResultCredentials('DIRECT'),
'DIRECT'
);
});
it('should handle undefined', function () {
assert.strictEqual(sanitizeProxyResultCredentials(undefined), '');
});
it('should handle multiple proxies with semicolons', function () {
assert.strictEqual(
sanitizeProxyResultCredentials('PROXY testuser:testpass@host1:8080; PROXY host2:8080; DIRECT'),
'PROXY <credentials>@host1:8080; PROXY host2:8080; DIRECT'
);
});
});