-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_proxy.py
49 lines (37 loc) · 1.48 KB
/
test_proxy.py
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
48
49
import tls_requests
def test_http_proxy():
proxy = tls_requests.Proxy("http://localhost:8080")
assert proxy.scheme == "http"
assert proxy.host == "localhost"
assert proxy.port == '8080'
assert proxy.url == "http://localhost:8080"
def test_https_proxy():
proxy = tls_requests.Proxy("https://localhost:8080")
assert proxy.scheme == "https"
assert proxy.host == "localhost"
assert proxy.port == '8080'
assert proxy.url == "https://localhost:8080"
def test_socks5_proxy():
proxy = tls_requests.Proxy("socks5://localhost:8080")
assert proxy.scheme == "socks5"
assert proxy.host == "localhost"
assert proxy.port == '8080'
assert proxy.url == "socks5://localhost:8080"
def test_proxy_with_params():
proxy = tls_requests.Proxy("http://localhost:8080?a=b", params={"foo": "bar"})
assert proxy.scheme == "http"
assert proxy.host == "localhost"
assert proxy.port == '8080'
assert proxy.url == "http://localhost:8080"
def test_auth_proxy():
proxy = tls_requests.Proxy("http://username:password@localhost:8080")
assert proxy.scheme == "http"
assert proxy.host == "localhost"
assert proxy.port == '8080'
assert proxy.auth == ("username", "password")
assert proxy.url == "http://username:password@localhost:8080"
def test_unsupported_proxy_scheme():
try:
_ = tls_requests.Proxy("unknown://localhost:8080")
except Exception as e:
assert isinstance(e, tls_requests.exceptions.ProxyError)