mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-23 22:27:34 -05:00
66f4197236
* chore: test * chore: add * chore: more progress * chore: progress in migration, fix prettier parser * chore: reduce tsc errors * chore: refactor storage utils types * chore: refactor utils types * chore: refactor local storage types * chore: refactor config utils types * chore: refactor tsc types * refactor: apply eslint fix, tabs etc * chore: fix lint errors * test: update unit test conf to typescript setup few test refactored to typescript * chore: enable more unit test migrate to typescript * chore: migrate storage test to tsc * chore: migrate up storage test to tsc * refactor: enable plugin and auth test * chore: migrate plugin loader test * chore: update dependencies * chore: migrate functional test to typescript * chore: add codecove * chore: update express * chore: downgrade puppeteer The latest version does not seems to work properly fine. * chore: update dependencies
96 lines
3.6 KiB
TypeScript
96 lines
3.6 KiB
TypeScript
import ProxyStorage from '../../../../src/lib/up-storage';
|
|
|
|
require('../../../../src/lib/logger').setup([]);
|
|
|
|
function setupProxy(host, uplinkConf, appConfig) {
|
|
uplinkConf.url = host;
|
|
|
|
return new ProxyStorage(uplinkConf, appConfig);
|
|
}
|
|
|
|
describe('Use proxy', () => {
|
|
test('should work fine without proxy', () => {
|
|
let x = setupProxy('http://x/x', {}, {});
|
|
|
|
expect(x.proxy).toEqual(undefined);
|
|
});
|
|
|
|
test('local config should take priority', () => {
|
|
let x = setupProxy('http://x/x', {http_proxy: '123'}, {http_proxy: '456'});
|
|
expect(x.proxy).toEqual('123');
|
|
});
|
|
|
|
test('no_proxy is invalid', () => {
|
|
let x = setupProxy('http://x/x', {http_proxy: '123', no_proxy: false}, {});
|
|
|
|
expect(x.proxy).toEqual('123');
|
|
x = setupProxy('http://x/x', {http_proxy: '123', no_proxy: null}, {});
|
|
expect(x.proxy).toEqual('123');
|
|
x = setupProxy('http://x/x', {http_proxy: '123', no_proxy: []}, {});
|
|
expect(x.proxy).toEqual('123');
|
|
x = setupProxy('http://x/x', {http_proxy: '123', no_proxy: ''}, {});
|
|
expect(x.proxy).toEqual('123');
|
|
});
|
|
|
|
test('no_proxy - simple/include', () => {
|
|
let x = setupProxy('http://localhost', {http_proxy: '123'}, {no_proxy: 'localhost'});
|
|
|
|
expect(x.proxy).toEqual(undefined);
|
|
});
|
|
|
|
test('no_proxy - simple/not', () => {
|
|
let x = setupProxy('http://localhost', {http_proxy: '123'}, {no_proxy: 'blah'});
|
|
|
|
expect(x.proxy).toEqual('123');
|
|
});
|
|
|
|
test('no_proxy - various, single string', () => {
|
|
let x = setupProxy('http://blahblah', {http_proxy: '123'}, {no_proxy: 'blah'});
|
|
|
|
expect(x.proxy).toEqual('123');
|
|
x = setupProxy('http://blah.blah', {}, {http_proxy: '123', no_proxy: 'blah'});
|
|
expect(x.proxy).toEqual(undefined);
|
|
x = setupProxy('http://blahblah', {}, {http_proxy: '123', no_proxy: '.blah'});
|
|
expect(x.proxy).toEqual('123');
|
|
x = setupProxy('http://blah.blah', {http_proxy: '123', no_proxy: '.blah'}, {});
|
|
expect(x.proxy).toEqual(undefined);
|
|
x = setupProxy('http://blah', {http_proxy: '123', no_proxy: '.blah'}, {});
|
|
expect(x.proxy).toEqual(undefined);
|
|
x = setupProxy('http://blahh', {http_proxy: '123', no_proxy: 'blah'}, {});
|
|
expect(x.proxy).toEqual('123');
|
|
});
|
|
|
|
test('no_proxy - various, array', () => {
|
|
let x = setupProxy('http://blahblah', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'});
|
|
|
|
expect(x.proxy).toEqual('123');
|
|
x = setupProxy('http://blah.blah', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'});
|
|
expect(x.proxy).toEqual(undefined);
|
|
x = setupProxy('http://blah.foo', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'});
|
|
expect(x.proxy).toEqual(undefined);
|
|
x = setupProxy('http://foo.baz', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'});
|
|
expect(x.proxy).toEqual('123');
|
|
x = setupProxy('http://blahblah', {http_proxy: '123'}, {no_proxy: ['foo', 'bar', 'blah']});
|
|
expect(x.proxy).toEqual('123');
|
|
x = setupProxy('http://blah.blah', {http_proxy: '123'}, {no_proxy: ['foo', 'bar', 'blah']});
|
|
expect(x.proxy).toEqual(undefined);
|
|
});
|
|
|
|
test('no_proxy - hostport', () => {
|
|
let x = setupProxy('http://localhost:80', {http_proxy: '123'}, {no_proxy: 'localhost'});
|
|
|
|
expect(x.proxy).toEqual(undefined);
|
|
x = setupProxy('http://localhost:8080', {http_proxy: '123'}, {no_proxy: 'localhost'});
|
|
expect(x.proxy).toEqual(undefined);
|
|
});
|
|
|
|
test('no_proxy - secure', () => {
|
|
let x = setupProxy('https://something', {http_proxy: '123'}, {});
|
|
|
|
expect(x.proxy).toEqual(undefined);
|
|
x = setupProxy('https://something', {https_proxy: '123'}, {});
|
|
expect(x.proxy).toEqual('123');
|
|
x = setupProxy('https://something', {http_proxy: '456', https_proxy: '123'}, {});
|
|
expect(x.proxy).toEqual('123');
|
|
});
|
|
});
|