feat: 账号可配置 HTTP/HTTPS/SOCKS 代理
This commit is contained in:
@@ -3,7 +3,7 @@ import asyncio
|
||||
import pytest
|
||||
|
||||
from euniv.autostudy import HoursWatcher, _parse_minutes, _study_video, wait_stop
|
||||
from euniv.proxy import parse_proxy
|
||||
from euniv.proxy import ProxyError, build_proxy_url, parse_proxy
|
||||
|
||||
|
||||
def test_parse_proxy_accepts_http_and_socks() -> None:
|
||||
@@ -16,6 +16,15 @@ def test_parse_proxy_accepts_http_and_socks() -> None:
|
||||
assert parse_proxy("socks5://user:pass@127.0.0.1:1080") == "socks5://user:pass@127.0.0.1:1080"
|
||||
|
||||
|
||||
def test_build_proxy_url_auth_is_optional_and_quoted() -> None:
|
||||
assert build_proxy_url("http", "10.0.0.1", 8080) == "http://10.0.0.1:8080"
|
||||
assert build_proxy_url("socks5", "127.0.0.1", 1080, "u", "p@ss") == "socks5://u:p%40ss@127.0.0.1:1080"
|
||||
assert build_proxy_url("http", "10.0.0.1", 8080, "u", "") == "http://u:@10.0.0.1:8080"
|
||||
assert build_proxy_url("socks4", "127.0.0.1", 1080, "", "s3cret") == "socks4://:s3cret@127.0.0.1:1080"
|
||||
with pytest.raises(ProxyError):
|
||||
build_proxy_url("ss", "127.0.0.1", 1080)
|
||||
|
||||
|
||||
def test_parse_proxy_rejects_other_schemes() -> None:
|
||||
with pytest.raises(ValueError):
|
||||
parse_proxy("ss://secret")
|
||||
|
||||
Reference in New Issue
Block a user