-
Notifications
You must be signed in to change notification settings - Fork 137
/
Copy pathresolve-proxy.test.js
47 lines (39 loc) · 1.54 KB
/
resolve-proxy.test.js
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
const test = require('ava');
const resolveProxy = require('../lib/resolve-proxy');
test('Resolve proxy with no proxy configuration', (t) => {
t.is(resolveProxy(undefined, {}), false);
});
test('Resolve proxy with no exclusions', (t) => {
t.is(resolveProxy(undefined, {http_proxy: 'proxy.example.com'}), 'proxy.example.com');
});
test('Resolve proxy with no matching exclusion', (t) => {
t.is(
resolveProxy(undefined, {
http_proxy: 'proxy.example.com',
no_proxy: 'notapi.github.com,.example.org,example.net',
}),
'proxy.example.com'
);
});
test('Resolve proxy with matching exclusion', (t) => {
t.is(resolveProxy(undefined, {http_proxy: 'proxy.example.com', no_proxy: 'github.com'}), false);
});
test('Resolve proxy with matching exclusion (leading .)', (t) => {
t.is(resolveProxy(undefined, {http_proxy: 'proxy.example.com', no_proxy: '.github.heygears.com'}), false);
});
test('Resolve proxy with global exclusion', (t) => {
t.is(resolveProxy(undefined, {http_proxy: 'proxy.example.com', no_proxy: '*'}), false);
});
test('Resolve proxy with matching GitHub Enterprise exclusion', (t) => {
t.is(
resolveProxy('https://github.example.com/api/v3', {http_proxy: 'proxy.example.com', no_proxy: 'example.com'}),
false
);
});
test('Resolve proxy with uppercase environment variables', (t) => {
t.is(resolveProxy(undefined, {HTTP_PROXY: 'proxy.example.com', NO_PROXY: 'github.com'}), false);
t.is(
resolveProxy(undefined, {HTTP_PROXY: 'proxy.example.com', NO_PROXY: 'subdomain.github.com'}),
'proxy.example.com'
);
});