OXIESEC PANEL
- Current Dir:
/
/
opt
/
gsutil
/
third_party
/
urllib3
/
test
Server IP: 2a02:4780:11:1594:0:ef5:22d7:a
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
12/11/2024 09:39:44 AM
rwxr-xr-x
📄
__init__.py
10.11 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
conftest.py
12.06 KB
06/17/2024 08:00:39 AM
rw-r--r--
📁
contrib
-
06/17/2024 08:00:39 AM
rwxr-xr-x
📄
port_helpers.py
6.08 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_collections.py
13.97 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_compatibility.py
692 bytes
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_connection.py
12.46 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_connectionpool.py
22.24 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_exceptions.py
2.11 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_fields.py
4.33 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_filepost.py
3.66 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_no_ssl.py
978 bytes
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_poolmanager.py
18.36 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_proxymanager.py
3.57 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_queue_monkeypatch.py
761 bytes
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_response.py
56.37 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_retry.py
16.32 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_ssl.py
7.63 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_ssltransport.py
20.63 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_util.py
42.74 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
test_wait.py
5.86 KB
06/17/2024 08:00:39 AM
rw-r--r--
📄
tz_stub.py
1.16 KB
06/17/2024 08:00:39 AM
rw-r--r--
📁
with_dummyserver
-
06/17/2024 08:00:39 AM
rwxr-xr-x
Editing: test_proxymanager.py
Close
from __future__ import annotations import pytest from urllib3.exceptions import MaxRetryError, NewConnectionError, ProxyError from urllib3.poolmanager import ProxyManager from urllib3.util.retry import Retry from urllib3.util.url import parse_url from .port_helpers import find_unused_port class TestProxyManager: @pytest.mark.parametrize("proxy_scheme", ["http", "https"]) def test_proxy_headers(self, proxy_scheme: str) -> None: url = "http://pypi.org/project/urllib3/" proxy_url = f"{proxy_scheme}://something:1234" with ProxyManager(proxy_url) as p: # Verify default headers default_headers = {"Accept": "*/*", "Host": "pypi.org"} headers = p._set_proxy_headers(url) assert headers == default_headers # Verify default headers don't overwrite provided headers provided_headers = { "Accept": "application/json", "custom": "header", "Host": "test.python.org", } headers = p._set_proxy_headers(url, provided_headers) assert headers == provided_headers # Verify proxy with nonstandard port provided_headers = {"Accept": "application/json"} expected_headers = provided_headers.copy() expected_headers.update({"Host": "pypi.org:8080"}) url_with_port = "http://pypi.org:8080/project/urllib3/" headers = p._set_proxy_headers(url_with_port, provided_headers) assert headers == expected_headers def test_default_port(self) -> None: with ProxyManager("http://something") as p: assert p.proxy is not None assert p.proxy.port == 80 with ProxyManager("https://something") as p: assert p.proxy is not None assert p.proxy.port == 443 def test_invalid_scheme(self) -> None: with pytest.raises(AssertionError): ProxyManager("invalid://host/p") with pytest.raises(ValueError): ProxyManager("invalid://host/p") def test_proxy_tunnel(self) -> None: http_url = parse_url("http://example.com") https_url = parse_url("https://example.com") with ProxyManager("http://proxy:8080") as p: assert p._proxy_requires_url_absolute_form(http_url) assert p._proxy_requires_url_absolute_form(https_url) is False with ProxyManager("https://proxy:8080") as p: assert p._proxy_requires_url_absolute_form(http_url) assert p._proxy_requires_url_absolute_form(https_url) is False with ProxyManager("https://proxy:8080", use_forwarding_for_https=True) as p: assert p._proxy_requires_url_absolute_form(http_url) assert p._proxy_requires_url_absolute_form(https_url) def test_proxy_connect_retry(self) -> None: retry = Retry(total=None, connect=False) port = find_unused_port() with ProxyManager(f"http://localhost:{port}") as p: with pytest.raises(ProxyError) as ei: p.urlopen("HEAD", url="http://localhost/", retries=retry) assert isinstance(ei.value.original_error, NewConnectionError) retry = Retry(total=None, connect=2) with ProxyManager(f"http://localhost:{port}") as p: with pytest.raises(MaxRetryError) as ei1: p.urlopen("HEAD", url="http://localhost/", retries=retry) assert ei1.value.reason is not None assert isinstance(ei1.value.reason, ProxyError) assert isinstance(ei1.value.reason.original_error, NewConnectionError)