Skip to content
Myr

test `same_origin` via public api (#3062)

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

authored by T-256 · committed by GitHub · parent e745060 · Browse files · 1 file+14 added−7 removed
This commit

State

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

Trailers

  • Co-authored-by: Tom Christie <tom@tomchristie.com>

Diff stats

1 file+14 added−7 removed

  • tests:+14 added−7 removed

1 file+14 added−7 removed

modified:tests/test_utils.py+14 added-7 removed
9 unmodified lines
10from httpx._utils import (11 URLPattern,12 get_ca_bundle_from_env,13 get_environment_proxies,14 same_origin,14)1516from .common import TESTS_DIR17
204 unmodified lines
222 assert repr(headers_class) == f"Headers({as_dict!r})"223224225def test_same_origin():227 origin1 = httpx.URL("https://example.com")228 origin2 = httpx.URL("HTTPS://EXAMPLE.COM:443")229 assert same_origin(origin1, origin2)226 origin = httpx.URL("https://example.com")227 request = httpx.Request("GET", "HTTPS://EXAMPLE.COM:443")228229 client = httpx.Client()230 headers = client._redirect_headers(request, origin, "GET")231232 assert headers["Host"] == request.url.netloc.decode("ascii")233234235def test_not_same_origin():233 origin1 = httpx.URL("https://example.com")234 origin2 = httpx.URL("HTTP://EXAMPLE.COM")235 assert not same_origin(origin1, origin2)236 origin = httpx.URL("https://example.com")237 request = httpx.Request("GET", "HTTP://EXAMPLE.COM:80")238239 client = httpx.Client()240 headers = client._redirect_headers(request, origin, "GET")241242 assert headers["Host"] == origin.netloc.decode("ascii")243244245def test_is_https_redirect():246 url = httpx.URL("https://example.com")247 request = httpx.Request(248 "GET", "http://example.com", headers={"Authorization": "empty"}
68 unmodified lines