-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
librelois
committed
Oct 31, 2017
1 parent
1174af1
commit e1f8f6f
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as assert from 'assert' | ||
import { ProxiesConf } from '../../app/lib/proxy'; | ||
|
||
describe("Proxies Conf", function() { | ||
|
||
// First conf : do not use any sock proxy | ||
let proxiesConf1 = new ProxiesConf() | ||
|
||
// Second conf : use tor only to reach ".onion" endpoints | ||
let proxiesConf2 = new ProxiesConf() | ||
proxiesConf2.proxyTorAddress = "127.0.0.1:9050" | ||
|
||
// Third conf : always use tor | ||
let proxiesConf3 = new ProxiesConf() | ||
proxiesConf3.proxyTorAddress = "127.0.0.1:9050" | ||
proxiesConf3.alwaysUseTor = true | ||
|
||
// Fourth cont : use classical socks proxy | ||
let proxiesConf4 = new ProxiesConf() | ||
proxiesConf4.proxySocksAddress = "127.0.0.1:8888" | ||
|
||
// Fifth : use classical socks proxy + use tor proxy only to reach ".onion" endpoints | ||
let proxiesConf5 = new ProxiesConf() | ||
proxiesConf5.proxySocksAddress = "127.0.0.1:8888" | ||
proxiesConf5.proxyTorAddress = "127.0.0.1:9050" | ||
|
||
it('should do not use any sock proxy', () => { | ||
assert.equal(ProxiesConf.wsProxy("ws://3asufnydqmup533h.onion:80", proxiesConf1) === undefined, true) | ||
assert.equal(ProxiesConf.wsProxy("ws://domain.tld:20900", proxiesConf1) === undefined, true) | ||
}) | ||
|
||
it('should use tor proxy only to reach ".onion" endpoints', () => { | ||
assert.equal(ProxiesConf.wsProxy("ws://3asufnydqmup533h.onion:80", proxiesConf2) === proxiesConf2.proxyTorAddress, true) | ||
assert.equal(ProxiesConf.wsProxy("ws://domain.tld:20900", proxiesConf2) === undefined, true) | ||
}) | ||
|
||
it('should always use tor proxy', () => { | ||
assert.equal(ProxiesConf.wsProxy("ws://3asufnydqmup533h.onion:80", proxiesConf3) === proxiesConf3.proxyTorAddress, true) | ||
assert.equal(ProxiesConf.wsProxy("ws://domain.tld:20900", proxiesConf3) === proxiesConf3.proxyTorAddress, true) | ||
}) | ||
|
||
it('should always use classical socks proxy', () => { | ||
assert.equal(ProxiesConf.wsProxy("ws://3asufnydqmup533h.onion:80", proxiesConf4) === proxiesConf4.proxySocksAddress, true) | ||
assert.equal(ProxiesConf.wsProxy("ws://domain.tld:20900", proxiesConf4) === proxiesConf4.proxySocksAddress, true) | ||
}) | ||
|
||
it('should use or tor proxy for ".onion" endpoints and classical socks proxy for everyone else', () => { | ||
assert.equal(ProxiesConf.wsProxy("ws://3asufnydqmup533h.onion:80", proxiesConf5) === proxiesConf5.proxyTorAddress, true) | ||
assert.equal(ProxiesConf.wsProxy("ws://domain.tld:20900", proxiesConf5) === proxiesConf5.proxySocksAddress, true) | ||
}) | ||
}); |