2014-11-12 06:14:37 -05:00
|
|
|
var assert = require('assert')
|
|
|
|
var Storage = require('../../lib/up-storage')
|
2013-11-24 12:07:18 -05:00
|
|
|
|
2013-12-21 07:09:29 -05:00
|
|
|
require('../../lib/logger').setup([])
|
2013-11-24 12:07:18 -05:00
|
|
|
|
|
|
|
function setup(host, config, mainconfig) {
|
2014-11-12 06:14:37 -05:00
|
|
|
config.url = host
|
|
|
|
return Storage(config, mainconfig)
|
2013-11-24 12:07:18 -05:00
|
|
|
}
|
|
|
|
|
2013-12-19 10:11:54 -05:00
|
|
|
describe('Use proxy', function() {
|
2014-11-12 06:14:37 -05:00
|
|
|
it('should work fine without proxy', function() {
|
|
|
|
var x = setup('http://x/x', {}, {})
|
|
|
|
assert.equal(x.proxy, null)
|
|
|
|
})
|
2013-11-24 12:07:18 -05:00
|
|
|
|
2014-11-12 06:14:37 -05: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 12:07:18 -05:00
|
|
|
|
2014-11-12 06:14:37 -05: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 12:07:18 -05:00
|
|
|
|
2014-11-12 06:14:37 -05: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 12:07:18 -05:00
|
|
|
|
2014-11-12 06:14:37 -05: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 12:07:18 -05:00
|
|
|
|
2014-11-12 06:14:37 -05: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 12:07:18 -05:00
|
|
|
|
2014-11-12 06:14:37 -05: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 12:07:18 -05:00
|
|
|
|
2014-11-12 06:14:37 -05: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 12:07:18 -05:00
|
|
|
|
2014-11-12 06:14:37 -05: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 10:11:54 -05:00
|
|
|
})
|