Merge branch 'more-pac' of https://github.com/abbradar/qutebrowser into abbradar-more-pac
This commit is contained in:
commit
4c14b2983b
@ -614,7 +614,7 @@ def proxy_from_url(url):
|
||||
|
||||
scheme = url.scheme()
|
||||
if scheme in ['pac+http', 'pac+https']:
|
||||
return pac.PACFetcher
|
||||
return pac.PACFetcher(url)
|
||||
|
||||
types = {
|
||||
'http': QNetworkProxy.HttpProxy,
|
||||
|
@ -125,6 +125,47 @@ def test_invalid_port():
|
||||
res.resolve(QNetworkProxyQuery(QUrl("https://example.com/test")))
|
||||
|
||||
|
||||
def test_no_function():
|
||||
with pytest.raises(pac.EvalProxyError):
|
||||
pac.PACResolver("")
|
||||
|
||||
|
||||
def test_fail_eval():
|
||||
with pytest.raises(pac.EvalProxyError):
|
||||
pac.PACResolver("{")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [
|
||||
"",
|
||||
"DIRECT FOO",
|
||||
"PROXY",
|
||||
"SOCKS",
|
||||
"FOOBAR",
|
||||
])
|
||||
def test_fail_parse(value):
|
||||
test_str_f = """
|
||||
function FindProxyForURL(domain, host) {{
|
||||
return "{}";
|
||||
}}
|
||||
"""
|
||||
|
||||
res = pac.PACResolver(test_str_f.format(value))
|
||||
with pytest.raises(pac.ParseProxyError):
|
||||
res.resolve(QNetworkProxyQuery(QUrl("https://example.com/test")))
|
||||
|
||||
|
||||
def test_fail_return():
|
||||
test_str = """
|
||||
function FindProxyForURL(domain, host) {
|
||||
return null;
|
||||
}
|
||||
"""
|
||||
|
||||
res = pac.PACResolver(test_str)
|
||||
with pytest.raises(pac.EvalProxyError):
|
||||
res.resolve(QNetworkProxyQuery(QUrl("https://example.com/test")))
|
||||
|
||||
|
||||
# See https://github.com/The-Compiler/qutebrowser/pull/1891#issuecomment-259222615
|
||||
|
||||
try:
|
||||
|
@ -765,7 +765,7 @@ class TestProxyFromUrl:
|
||||
@pytest.mark.parametrize('scheme', ['pac+http', 'pac+https'])
|
||||
def test_proxy_from_url_pac(self, scheme):
|
||||
fetcher = urlutils.proxy_from_url(QUrl('{}://foo'.format(scheme)))
|
||||
assert fetcher is pac.PACFetcher
|
||||
assert isinstance(fetcher, pac.PACFetcher)
|
||||
|
||||
@pytest.mark.parametrize('url, exception', [
|
||||
('blah', urlutils.InvalidProxyTypeError),
|
||||
|
Loading…
Reference in New Issue
Block a user