Skip to content
Myr

test `is_https_redirect` via public api (#3064)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* test `is_https_redirect` via public api * Update tests/test_utils.py

authored by T-256 · committed by GitHub · parent 4de1370 · Browse files · 1 file+27 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+27 added−10 removed

  • tests:+27 added−10 removed

1 file+27 added−10 removed

modified:tests/test_utils.py+27 added-10 removed
9 unmodified lines
10from httpx._utils import (11 URLPattern,12 get_ca_bundle_from_env,13 get_environment_proxies,14 is_https_redirect,14 same_origin,15)1617from .common import TESTS_DIR
217 unmodified lines
235 assert not same_origin(origin1, origin2)236237238def test_is_https_redirect():240 url = httpx.URL("http://example.com")241 location = httpx.URL("https://example.com")242 assert is_https_redirect(url, location)239 url = httpx.URL("https://example.com")240 request = httpx.Request(241 "GET", "http://example.com", headers={"Authorization": "empty"}242 )243244 client = httpx.Client()245 headers = client._redirect_headers(request, url, "GET")246247 assert "Authorization" in headers248249250def test_is_not_https_redirect():246 url = httpx.URL("http://example.com")247 location = httpx.URL("https://www.example.com")248 assert not is_https_redirect(url, location)251 url = httpx.URL("https://www.example.com")252 request = httpx.Request(253 "GET", "http://example.com", headers={"Authorization": "empty"}254 )255256 client = httpx.Client()257 headers = client._redirect_headers(request, url, "GET")258259 assert "Authorization" not in headers260261262def test_is_not_https_redirect_if_not_default_ports():252 url = httpx.URL("http://example.com:9999")253 location = httpx.URL("https://example.com:1337")254 assert not is_https_redirect(url, location)263 url = httpx.URL("https://example.com:1337")264 request = httpx.Request(265 "GET", "http://example.com:9999", headers={"Authorization": "empty"}266 )267268 client = httpx.Client()269 headers = client._redirect_headers(request, url, "GET")270271 assert "Authorization" not in headers272273274@pytest.mark.parametrize(275 ["pattern", "url", "expected"],276 [277 ("http://example.com", "http://example.com", True),
32 unmodified lines