1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/unit/no_proxy.js

89 lines
3.4 KiB
JavaScript
Raw Normal View History

var assert = require('assert')
var Storage = require('../../lib/up-storage')
2013-11-24 18:07:18 +01:00
2013-12-21 13:09:29 +01:00
require('../../lib/logger').setup([])
2013-11-24 18:07:18 +01:00
function setup(host, config, mainconfig) {
config.url = host
return Storage(config, mainconfig)
2013-11-24 18:07:18 +01:00
}
2013-12-19 16:11:54 +01:00
describe('Use proxy', function() {
it('should work fine without proxy', function() {
var x = setup('http://x/x', {}, {})
assert.equal(x.proxy, null)
})
2013-11-24 18:07:18 +01:00
it('local config should take priority', function() {
var x = setup('http://x/x', {http_proxy: '123'}, {http_proxy: '456'})
assert.equal(x.proxy, '123')
})
2013-11-24 18:07:18 +01:00
it('no_proxy is invalid', function() {
var x = setup('http://x/x', {http_proxy: '123', no_proxy: false}, {})
assert.equal(x.proxy, '123')
var x = setup('http://x/x', {http_proxy: '123', no_proxy: null}, {})
assert.equal(x.proxy, '123')
var x = setup('http://x/x', {http_proxy: '123', no_proxy: []}, {})
assert.equal(x.proxy, '123')
var x = setup('http://x/x', {http_proxy: '123', no_proxy: ''}, {})
assert.equal(x.proxy, '123')
})
2013-11-24 18:07:18 +01:00
it('no_proxy - simple/include', function() {
var x = setup('http://localhost', {http_proxy: '123'}, {no_proxy: 'localhost'})
assert.equal(x.proxy, undefined)
})
2013-11-24 18:07:18 +01:00
it('no_proxy - simple/not', function() {
var x = setup('http://localhost', {http_proxy: '123'}, {no_proxy: 'blah'})
assert.equal(x.proxy, '123')
})
2013-11-24 18:07:18 +01:00
it('no_proxy - various, single string', function() {
var x = setup('http://blahblah', {http_proxy: '123'}, {no_proxy: 'blah'})
assert.equal(x.proxy, '123')
var x = setup('http://blah.blah', {}, {http_proxy: '123', no_proxy: 'blah'})
assert.equal(x.proxy, null)
var x = setup('http://blahblah', {}, {http_proxy: '123', no_proxy: '.blah'})
assert.equal(x.proxy, '123')
var x = setup('http://blah.blah', {http_proxy: '123', no_proxy: '.blah'}, {})
assert.equal(x.proxy, null)
var x = setup('http://blah', {http_proxy: '123', no_proxy: '.blah'}, {})
assert.equal(x.proxy, null)
var x = setup('http://blahh', {http_proxy: '123', no_proxy: 'blah'}, {})
assert.equal(x.proxy, '123')
})
2013-11-24 18:07:18 +01:00
it('no_proxy - various, array', function() {
var x = setup('http://blahblah', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'})
assert.equal(x.proxy, '123')
var x = setup('http://blah.blah', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'})
assert.equal(x.proxy, null)
var x = setup('http://blah.foo', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'})
assert.equal(x.proxy, null)
var x = setup('http://foo.baz', {http_proxy: '123'}, {no_proxy: 'foo,bar,blah'})
assert.equal(x.proxy, '123')
var x = setup('http://blahblah', {http_proxy: '123'}, {no_proxy: ['foo','bar','blah']})
assert.equal(x.proxy, '123')
var x = setup('http://blah.blah', {http_proxy: '123'}, {no_proxy: ['foo','bar','blah']})
assert.equal(x.proxy, null)
})
2013-11-24 18:07:18 +01:00
it('no_proxy - hostport', function() {
var x = setup('http://localhost:80', {http_proxy: '123'}, {no_proxy: 'localhost'})
assert.equal(x.proxy, null)
var x = setup('http://localhost:8080', {http_proxy: '123'}, {no_proxy: 'localhost'})
assert.equal(x.proxy, null)
})
2013-11-24 18:07:18 +01:00
it('no_proxy - secure', function() {
var x = setup('https://something', {http_proxy: '123'}, {})
assert.equal(x.proxy, null)
var x = setup('https://something', {https_proxy: '123'}, {})
assert.equal(x.proxy, '123')
var x = setup('https://something', {http_proxy: '456', https_proxy: '123'}, {})
assert.equal(x.proxy, '123')
})
2013-12-19 16:11:54 +01:00
})