Skip to content
Myr

test_auth.py

This file

Path

tests/client/test_auth.py

684 lines · 21.6 KiB · Python

Last changed by

Drop ContentStream (#1295)Tom Christiebefore adoptionfbb21fb

History of this file

Take it

The walk stopped after 200 commits: lines older than 19bf211 point at it.

Add support for sync-specific or async-specific auth flows (#1217)Florimond Mancabefore adoption016e4ee

lines 1–6why, one step back
1"""
2Integration tests for authentication.34Unit tests for auth classes also exist in tests/test_auth.py5"""6import asyncio

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 7why, one step back
7import hashlib

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 8why, one step back
8import json

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 9why, one step back
9import os

Add support for sync-specific or async-specific auth flows (#1217)Florimond Mancabefore adoption016e4ee

line 10why, one step back
10import threading

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 11–14why, one step back
11import typing
1213import pytest14

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 15why, one step back
15import httpx

Drop ContentStream (#1295)Tom Christiebefore adoptionfbb21fb

line 16why, one step back
16from httpx import URL, Auth, BasicAuth, DigestAuth, ProtocolError, Request, Response

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 17why, one step back
17from tests.utils import AsyncMockTransport, MockTransport

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 18why, one step back
18

Use relative tests directory references (#1052)Florimond Mancabefore adoption09672a9

line 19why, one step back
19from ..common import FIXTURES_DIR

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 20why, one step back
20

Use relative tests directory references (#1052)Florimond Mancabefore adoption09672a9

line 21why, one step back
21

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 22–23why, one step back
22class App:
23 def __init__(self, auth_header: str = "", status_code: int = 200) -> None:

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 24–26why, one step back
24 self.auth_header = auth_header
25 self.status_code = status_code26

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 27–31why, one step back
27 def __call__(self, request: httpx.Request) -> httpx.Response:
28 headers = {"www-authenticate": self.auth_header} if self.auth_header else {}29 data = {"auth": request.headers.get("Authorization")}30 content = json.dumps(data).encode("utf-8")31 return httpx.Response(self.status_code, headers=headers, content=content)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 32–33why, one step back
32
33

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 34why, one step back
34class DigestApp:

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 35–47why, one step back
35 def __init__(
36 self,37 algorithm: str = "SHA-256",38 send_response_after_attempt: int = 1,39 qop: str = "auth",40 regenerate_nonce: bool = True,41 ) -> None:42 self.algorithm = algorithm43 self.send_response_after_attempt = send_response_after_attempt44 self.qop = qop45 self._regenerate_nonce = regenerate_nonce46 self._response_count = 047

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 48why, one step back
48 def __call__(self, request: httpx.Request) -> httpx.Response:

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 49why, one step back
49 if self._response_count < self.send_response_after_attempt:

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 50why, one step back
50 return self.challenge_send(request)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 51why, one step back
51

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 52–54why, one step back
52 data = {"auth": request.headers.get("Authorization")}
53 content = json.dumps(data).encode("utf-8")54 return httpx.Response(200, content=content)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 55why, one step back
55

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 56why, one step back
56 def challenge_send(self, request: httpx.Request) -> httpx.Response:

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 57–77why, one step back
57 self._response_count += 1
58 nonce = (59 hashlib.sha256(os.urandom(8)).hexdigest()60 if self._regenerate_nonce61 else "ee96edced2a0b43e4869e96ebe27563f369c1205a049d06419bb51d8aeddf3d3"62 )63 challenge_data = {64 "nonce": nonce,65 "qop": self.qop,66 "opaque": (67 "ee6378f3ee14ebfd2fff54b70a91a7c9390518047f242ab2271380db0e14bda1"68 ),69 "algorithm": self.algorithm,70 "stale": "FALSE",71 }72 challenge_str = ", ".join(73 '{}="{}"'.format(key, value)74 for key, value in challenge_data.items()75 if value76 )77

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 78–81why, one step back
78 headers = {
79 "www-authenticate": f'Digest realm="httpx@example.org", {challenge_str}',80 }81 return Response(401, headers=headers)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 82–83why, one step back
82
83

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 84–129why, one step back
84class RepeatAuth(Auth):
85 """86 A mock authentication scheme that requires clients to send87 the request a fixed number of times, and then send a last request containing88 an aggregation of nonces that the server sent in 'WWW-Authenticate' headers89 of intermediate responses.90 """9192 requires_request_body = True9394 def __init__(self, repeat: int):95 self.repeat = repeat9697 def auth_flow(self, request: Request) -> typing.Generator[Request, Response, None]:98 nonces = []99100 for index in range(self.repeat):101 request.headers["Authorization"] = f"Repeat {index}"102 response = yield request103 nonces.append(response.headers["www-authenticate"])104105 key = ".".join(nonces)106 request.headers["Authorization"] = f"Repeat {key}"107 yield request108109110class ResponseBodyAuth(Auth):111 """112 A mock authentication scheme that requires clients to send an 'Authorization'113 header, then send back the contents of the response in the 'Authorization'114 header.115 """116117 requires_response_body = True118119 def __init__(self, token):120 self.token = token121122 def auth_flow(self, request: Request) -> typing.Generator[Request, Response, None]:123 request.headers["Authorization"] = self.token124 response = yield request125 data = response.text126 request.headers["Authorization"] = data127 yield request128129

Add support for sync-specific or async-specific auth flows (#1217)Florimond Mancabefore adoption016e4ee

lines 130–154why, one step back
130class SyncOrAsyncAuth(Auth):
131 """132 A mock authentication scheme that uses a different implementation for the133 sync and async cases.134 """135136 def __init__(self) -> None:137 self._lock = threading.Lock()138 self._async_lock = asyncio.Lock()139140 def sync_auth_flow(141 self, request: Request142 ) -> typing.Generator[Request, Response, None]:143 with self._lock:144 request.headers["Authorization"] = "sync-auth"145 yield request146147 async def async_auth_flow(148 self, request: Request149 ) -> typing.AsyncGenerator[Request, Response]:150 async with self._async_lock:151 request.headers["Authorization"] = "async-auth"152 yield request153154

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 155–158why, one step back
155@pytest.mark.asyncio
156async def test_basic_auth() -> None:157 url = "https://example.org/"158 auth = ("tomchristie", "password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 159why, one step back
159 app = App()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 160why, one step back
160

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 161why, one step back
161 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 162why, one step back
162 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 163–170why, one step back
163
164 assert response.status_code == 200165 assert response.json() == {"auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="}166167168@pytest.mark.asyncio169async def test_basic_auth_in_url() -> None:170 url = "https://tomchristie:password123@example.org/"

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 171why, one step back
171 app = App()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 172why, one step back
172

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 173why, one step back
173 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 174why, one step back
174 response = await client.get(url)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 175–183why, one step back
175
176 assert response.status_code == 200177 assert response.json() == {"auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="}178179180@pytest.mark.asyncio181async def test_basic_auth_on_session() -> None:182 url = "https://example.org/"183 auth = ("tomchristie", "password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 184why, one step back
184 app = App()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 185why, one step back
185

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 186–188why, one step back
186 async with httpx.AsyncClient(
187 transport=AsyncMockTransport(app), auth=auth188 ) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 189why, one step back
189 response = await client.get(url)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 190–197why, one step back
190
191 assert response.status_code == 200192 assert response.json() == {"auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="}193194195@pytest.mark.asyncio196async def test_custom_auth() -> None:197 url = "https://example.org/"

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 198why, one step back
198 app = App()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 199–203why, one step back
199
200 def auth(request: Request) -> Request:201 request.headers["Authorization"] = "Token 123"202 return request203

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 204why, one step back
204 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 205why, one step back
205 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 206–212why, one step back
206
207 assert response.status_code == 200208 assert response.json() == {"auth": "Token 123"}209210211@pytest.mark.asyncio212async def test_netrc_auth() -> None:

Use relative tests directory references (#1052)Florimond Mancabefore adoption09672a9

line 213why, one step back
213 os.environ["NETRC"] = str(FIXTURES_DIR / ".netrc")

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 214why, one step back
214 url = "http://netrcexample.org"

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 215why, one step back
215 app = App()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 216why, one step back
216

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 217why, one step back
217 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 218why, one step back
218 response = await client.get(url)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 219–227why, one step back
219
220 assert response.status_code == 200221 assert response.json() == {222 "auth": "Basic ZXhhbXBsZS11c2VybmFtZTpleGFtcGxlLXBhc3N3b3Jk"223 }224225226@pytest.mark.asyncio227async def test_auth_header_has_priority_over_netrc() -> None:

Use relative tests directory references (#1052)Florimond Mancabefore adoption09672a9

line 228why, one step back
228 os.environ["NETRC"] = str(FIXTURES_DIR / ".netrc")

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 229why, one step back
229 url = "http://netrcexample.org"

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 230why, one step back
230 app = App()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 231why, one step back
231

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 232why, one step back
232 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 233why, one step back
233 response = await client.get(url, headers={"Authorization": "Override"})

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 234–240why, one step back
234
235 assert response.status_code == 200236 assert response.json() == {"auth": "Override"}237238239@pytest.mark.asyncio240async def test_trust_env_auth() -> None:

Use relative tests directory references (#1052)Florimond Mancabefore adoption09672a9

line 241why, one step back
241 os.environ["NETRC"] = str(FIXTURES_DIR / ".netrc")

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 242why, one step back
242 url = "http://netrcexample.org"

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 243why, one step back
243 app = App()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 244why, one step back
244

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 245why, one step back
245 async with httpx.AsyncClient(

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 246why, one step back
246 transport=AsyncMockTransport(app), trust_env=False

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 247–248why, one step back
247 ) as client:
248 response = await client.get(url)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 249–252why, one step back
249
250 assert response.status_code == 200251 assert response.json() == {"auth": None}252

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 253why, one step back
253 async with httpx.AsyncClient(

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 254why, one step back
254 transport=AsyncMockTransport(app), trust_env=True

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 255–256why, one step back
255 ) as client:
256 response = await client.get(url)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 257–263why, one step back
257
258 assert response.status_code == 200259 assert response.json() == {260 "auth": "Basic ZXhhbXBsZS11c2VybmFtZTpleGFtcGxlLXBhc3N3b3Jk"261 }262263

Allow disabling auth per-request using `auth=None` (#1115)Florimond Mancabefore adoptiona4463d0

lines 264–267why, one step back
264@pytest.mark.asyncio
265async def test_auth_disable_per_request() -> None:266 url = "https://example.org/"267 auth = ("tomchristie", "password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 268why, one step back
268 app = App()

Allow disabling auth per-request using `auth=None` (#1115)Florimond Mancabefore adoptiona4463d0

line 269why, one step back
269

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 270–272why, one step back
270 async with httpx.AsyncClient(
271 transport=AsyncMockTransport(app), auth=auth272 ) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 273why, one step back
273 response = await client.get(url, auth=None)

Allow disabling auth per-request using `auth=None` (#1115)Florimond Mancabefore adoptiona4463d0

lines 274–278why, one step back
274
275 assert response.status_code == 200276 assert response.json() == {"auth": None}277278

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 279–289why, one step back
279def test_auth_hidden_url() -> None:
280 url = "http://example-username:example-password@example.org/"281 expected = "URL('http://example-username:[secure]@example.org/')"282 assert url == URL(url)283 assert expected == repr(URL(url))284285286@pytest.mark.asyncio287async def test_auth_hidden_header() -> None:288 url = "https://example.org/"289 auth = ("example-username", "example-password")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 290why, one step back
290 app = App()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 291why, one step back
291

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 292why, one step back
292 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 293why, one step back
293 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 294–298why, one step back
294
295 assert "'authorization': '[secure]'" in str(response.request.headers)296297298@pytest.mark.asyncio

Add `Client.auth` setter (#1185)Florimond Mancabefore adoptioncb620e6

line 299why, one step back
299async def test_auth_property() -> None:

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 300–302why, one step back
300 app = App()
301302 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 303why, one step back
303 assert client.auth is None

Add `Client.auth` setter (#1185)Florimond Mancabefore adoptioncb620e6

line 304why, one step back
304

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 305–306why, one step back
305 client.auth = ("tomchristie", "password123") # type: ignore
306 assert isinstance(client.auth, BasicAuth)

Add `Client.auth` setter (#1185)Florimond Mancabefore adoptioncb620e6

line 307why, one step back
307

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 308–311why, one step back
308 url = "https://example.org/"
309 response = await client.get(url)310 assert response.status_code == 200311 assert response.json() == {"auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="}

Add `Client.auth` setter (#1185)Florimond Mancabefore adoptioncb620e6

lines 312–315why, one step back
312
313314@pytest.mark.asyncio315async def test_auth_invalid_type() -> None:

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 316–317why, one step back
316 app = App()
317

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 318why, one step back
318 with pytest.raises(TypeError):

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 319why, one step back
319 client = httpx.AsyncClient(

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 320why, one step back
320 transport=AsyncMockTransport(app),

Add `Client.auth` setter (#1185)Florimond Mancabefore adoptioncb620e6

lines 321–323why, one step back
321 auth="not a tuple, not a callable", # type: ignore
322 )323

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 324why, one step back
324 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 325–326why, one step back
325 with pytest.raises(TypeError):
326 await client.get(auth="not a tuple, not a callable") # type: ignore

Add `Client.auth` setter (#1185)Florimond Mancabefore adoptioncb620e6

line 327why, one step back
327

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 328–329why, one step back
328 with pytest.raises(TypeError):
329 client.auth = "not a tuple, not a callable" # type: ignore

Add `Client.auth` setter (#1185)Florimond Mancabefore adoptioncb620e6

line 330why, one step back
330

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 331–335why, one step back
331
332@pytest.mark.asyncio333async def test_digest_auth_returns_no_auth_if_no_digest_header_in_response() -> None:334 url = "https://example.org/"335 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 336why, one step back
336 app = App()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 337why, one step back
337

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 338why, one step back
338 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 339why, one step back
339 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 340–345why, one step back
340
341 assert response.status_code == 200342 assert response.json() == {"auth": None}343 assert len(response.history) == 0344345

Handle multiple auth headers correctly (#1240)Tom Christiebefore adoption33d339a

lines 346–348why, one step back
346def test_digest_auth_returns_no_auth_if_alternate_auth_scheme() -> None:
347 url = "https://example.org/"348 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 349–350why, one step back
349 auth_header = "Token ..."
350 app = App(auth_header=auth_header, status_code=401)

Handle multiple auth headers correctly (#1240)Tom Christiebefore adoption33d339a

line 351why, one step back
351

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 352why, one step back
352 client = httpx.Client(transport=MockTransport(app))

Handle multiple auth headers correctly (#1240)Tom Christiebefore adoption33d339a

lines 353–359why, one step back
353 response = client.get(url, auth=auth)
354355 assert response.status_code == 401356 assert response.json() == {"auth": None}357 assert len(response.history) == 0358359

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 360–363why, one step back
360@pytest.mark.asyncio
361async def test_digest_auth_200_response_including_digest_auth_header() -> None:362 url = "https://example.org/"363 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 364–365why, one step back
364 auth_header = 'Digest realm="realm@host.com",qop="auth",nonce="abc",opaque="xyz"'
365 app = App(auth_header=auth_header, status_code=200)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 366why, one step back
366

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 367why, one step back
367 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 368why, one step back
368 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 369–378why, one step back
369
370 assert response.status_code == 200371 assert response.json() == {"auth": None}372 assert len(response.history) == 0373374375@pytest.mark.asyncio376async def test_digest_auth_401_response_without_digest_auth_header() -> None:377 url = "https://example.org/"378 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 379why, one step back
379 app = App(auth_header="", status_code=401)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 380why, one step back
380

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 381why, one step back
381 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 382why, one step back
382 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 383–407why, one step back
383
384 assert response.status_code == 401385 assert response.json() == {"auth": None}386 assert len(response.history) == 0387388389@pytest.mark.parametrize(390 "algorithm,expected_hash_length,expected_response_length",391 [392 ("MD5", 64, 32),393 ("MD5-SESS", 64, 32),394 ("SHA", 64, 40),395 ("SHA-SESS", 64, 40),396 ("SHA-256", 64, 64),397 ("SHA-256-SESS", 64, 64),398 ("SHA-512", 64, 128),399 ("SHA-512-SESS", 64, 128),400 ],401)402@pytest.mark.asyncio403async def test_digest_auth(404 algorithm: str, expected_hash_length: int, expected_response_length: int405) -> None:406 url = "https://example.org/"407 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 408why, one step back
408 app = DigestApp(algorithm=algorithm)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 409why, one step back
409

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 410why, one step back
410 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 411why, one step back
411 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 412–438why, one step back
412
413 assert response.status_code == 200414 assert len(response.history) == 1415416 authorization = typing.cast(dict, response.json())["auth"]417 scheme, _, fields = authorization.partition(" ")418 assert scheme == "Digest"419420 response_fields = [field.strip() for field in fields.split(",")]421 digest_data = dict(field.split("=") for field in response_fields)422423 assert digest_data["username"] == '"tomchristie"'424 assert digest_data["realm"] == '"httpx@example.org"'425 assert "nonce" in digest_data426 assert digest_data["uri"] == '"/"'427 assert len(digest_data["response"]) == expected_response_length + 2 # extra quotes428 assert len(digest_data["opaque"]) == expected_hash_length + 2429 assert digest_data["algorithm"] == algorithm430 assert digest_data["qop"] == "auth"431 assert digest_data["nc"] == "00000001"432 assert len(digest_data["cnonce"]) == 16 + 2433434435@pytest.mark.asyncio436async def test_digest_auth_no_specified_qop() -> None:437 url = "https://example.org/"438 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 439why, one step back
439 app = DigestApp(qop="")

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 440why, one step back
440

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 441why, one step back
441 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 442why, one step back
442 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 443–470why, one step back
443
444 assert response.status_code == 200445 assert len(response.history) == 1446447 authorization = typing.cast(dict, response.json())["auth"]448 scheme, _, fields = authorization.partition(" ")449 assert scheme == "Digest"450451 response_fields = [field.strip() for field in fields.split(",")]452 digest_data = dict(field.split("=") for field in response_fields)453454 assert "qop" not in digest_data455 assert "nc" not in digest_data456 assert "cnonce" not in digest_data457 assert digest_data["username"] == '"tomchristie"'458 assert digest_data["realm"] == '"httpx@example.org"'459 assert len(digest_data["nonce"]) == 64 + 2 # extra quotes460 assert digest_data["uri"] == '"/"'461 assert len(digest_data["response"]) == 64 + 2462 assert len(digest_data["opaque"]) == 64 + 2463 assert digest_data["algorithm"] == "SHA-256"464465466@pytest.mark.parametrize("qop", ("auth, auth-int", "auth,auth-int", "unknown,auth"))467@pytest.mark.asyncio468async def test_digest_auth_qop_including_spaces_and_auth_returns_auth(qop: str) -> None:469 url = "https://example.org/"470 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 471why, one step back
471 app = DigestApp(qop=qop)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 472why, one step back
472

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 473why, one step back
473 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 474why, one step back
474 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 475–483why, one step back
475
476 assert response.status_code == 200477 assert len(response.history) == 1478479480@pytest.mark.asyncio481async def test_digest_auth_qop_auth_int_not_implemented() -> None:482 url = "https://example.org/"483 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 484why, one step back
484 app = DigestApp(qop="auth-int")

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 485why, one step back
485

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 486why, one step back
486 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 487–488why, one step back
487 with pytest.raises(NotImplementedError):
488 await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 489–494why, one step back
489
490491@pytest.mark.asyncio492async def test_digest_auth_qop_must_be_auth_or_auth_int() -> None:493 url = "https://example.org/"494 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 495why, one step back
495 app = DigestApp(qop="not-auth")

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 496why, one step back
496

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 497why, one step back
497 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 498–499why, one step back
498 with pytest.raises(ProtocolError):
499 await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 500–505why, one step back
500
501502@pytest.mark.asyncio503async def test_digest_auth_incorrect_credentials() -> None:504 url = "https://example.org/"505 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 506why, one step back
506 app = DigestApp(send_response_after_attempt=2)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 507why, one step back
507

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 508why, one step back
508 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 509why, one step back
509 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 510–517why, one step back
510
511 assert response.status_code == 401512 assert len(response.history) == 1513514515@pytest.mark.parametrize(516 "auth_header",517 [

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 518–519why, one step back
518 'Digest realm="httpx@example.org", qop="auth"', # missing fields
519 'Digest realm="httpx@example.org", qop="auth,au', # malformed fields list

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 520–522why, one step back
520 ],
521)522@pytest.mark.asyncio

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

line 523why, one step back
523async def test_async_digest_auth_raises_protocol_error_on_malformed_header(

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 524why, one step back
524 auth_header: str,

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 525–527why, one step back
525) -> None:
526 url = "https://example.org/"527 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 528–530why, one step back
528 app = App(auth_header=auth_header, status_code=401)
529530 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 531–532why, one step back
531 with pytest.raises(ProtocolError):
532 await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 533–534why, one step back
533
534

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 535–537why, one step back
535@pytest.mark.parametrize(
536 "auth_header",537 [

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 538–539why, one step back
538 'Digest realm="httpx@example.org", qop="auth"', # missing fields
539 'Digest realm="httpx@example.org", qop="auth,au', # malformed fields list

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 540–542why, one step back
540 ],
541)542def test_sync_digest_auth_raises_protocol_error_on_malformed_header(

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 543why, one step back
543 auth_header: str,

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 544–546why, one step back
544) -> None:
545 url = "https://example.org/"546 auth = DigestAuth(username="tomchristie", password="password123")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 547why, one step back
547 app = App(auth_header=auth_header, status_code=401)

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 548why, one step back
548

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 549why, one step back
549 with httpx.Client(transport=MockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 550–551why, one step back
550 with pytest.raises(ProtocolError):
551 client.get(url, auth=auth)

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 552–553why, one step back
552
553

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 554why, one step back
554@pytest.mark.asyncio

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

line 555why, one step back
555async def test_async_auth_history() -> None:

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 556–559why, one step back
556 """
557 Test that intermediate requests sent as part of an authentication flow558 are recorded in the response history.559 """

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 560–561why, one step back
560 url = "https://example.org/"
561 auth = RepeatAuth(repeat=2)

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 562why, one step back
562 app = App(auth_header="abc")

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 563why, one step back
563

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 564why, one step back
564 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 565–566why, one step back
565 response = await client.get(url, auth=auth)
566

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 567–568why, one step back
567 assert response.status_code == 200
568 assert response.json() == {"auth": "Repeat abc.abc"}

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 569why, one step back
569

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 570–573why, one step back
570 assert len(response.history) == 2
571 resp1, resp2 = response.history572 assert resp1.json() == {"auth": "Repeat 0"}573 assert resp2.json() == {"auth": "Repeat 1"}

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 574why, one step back
574

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 575–576why, one step back
575 assert len(resp2.history) == 1
576 assert resp2.history == [resp1]

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 577why, one step back
577

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

line 578why, one step back
578 assert len(resp1.history) == 0

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 579–580why, one step back
579
580

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 581–585why, one step back
581def test_sync_auth_history() -> None:
582 """583 Test that intermediate requests sent as part of an authentication flow584 are recorded in the response history.585 """

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 586–587why, one step back
586 url = "https://example.org/"
587 auth = RepeatAuth(repeat=2)

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 588why, one step back
588 app = App(auth_header="abc")

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 589why, one step back
589

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 590why, one step back
590 with httpx.Client(transport=MockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 591–592why, one step back
591 response = client.get(url, auth=auth)
592

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 593–610why, one step back
593 assert response.status_code == 200
594 assert response.json() == {"auth": "Repeat abc.abc"}595596 assert len(response.history) == 2597 resp1, resp2 = response.history598 assert resp1.json() == {"auth": "Repeat 0"}599 assert resp2.json() == {"auth": "Repeat 1"}600601 assert len(resp2.history) == 1602 assert resp2.history == [resp1]603604 assert len(resp1.history) == 0605606607@pytest.mark.asyncio608async def test_digest_auth_unavailable_streaming_body():609 url = "https://example.org/"610 auth = DigestAuth(username="tomchristie", password="password123")

Drop ContentStream (#1295)Tom Christiebefore adoptionfbb21fb

line 611why, one step back
611 app = DigestApp()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 612–613why, one step back
612
613 async def streaming_body():

Transport API (#963)Yeray Diaz Diazbefore adoptiond2816c9

line 614why, one step back
614 yield b"Example request body" # pragma: nocover

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 615why, one step back
615

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 616why, one step back
616 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Drop ContentStream (#1295)Tom Christiebefore adoptionfbb21fb

line 617why, one step back
617 with pytest.raises(httpx.StreamConsumed):

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 618why, one step back
618 await client.post(url, data=streaming_body(), auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 619–621why, one step back
619
620621@pytest.mark.asyncio

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

line 622why, one step back
622async def test_async_auth_reads_response_body() -> None:

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 623–626why, one step back
623 """
624 Test that we can read the response body in an auth flow if `requires_response_body`625 is set.626 """

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 627–628why, one step back
627 url = "https://example.org/"
628 auth = ResponseBodyAuth("xyz")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

lines 629–631why, one step back
629 app = App()
630631 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

line 632why, one step back
632 response = await client.get(url, auth=auth)

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 633why, one step back
633

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 634–635why, one step back
634 assert response.status_code == 200
635 assert response.json() == {"auth": '{"auth": "xyz"}'}

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 636–637why, one step back
636
637

Increase test coverage - take 2 (#1012)Josep Cugatbefore adoption620b067

lines 638–642why, one step back
638def test_sync_auth_reads_response_body() -> None:
639 """640 Test that we can read the response body in an auth flow if `requires_response_body`641 is set.642 """

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 643–644why, one step back
643 url = "https://example.org/"
644 auth = ResponseBodyAuth("xyz")

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 645why, one step back
645 app = App()

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

line 646why, one step back
646

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 647why, one step back
647 with httpx.Client(transport=MockTransport(app)) as client:

Closing AsyncClient in all tests (#871) (#1219)cdelerbefore adoptionfa7661b

lines 648–649why, one step back
648 response = client.get(url, auth=auth)
649

Test Suite on GitHub Actions (#907)Tom Christiebefore adoption19bf211

lines 650–651why, one step back
650 assert response.status_code == 200
651 assert response.json() == {"auth": '{"auth": "xyz"}'}

Add support for sync-specific or async-specific auth flows (#1217)Florimond Mancabefore adoption016e4ee

lines 652–662why, one step back
652
653654@pytest.mark.asyncio655async def test_async_auth() -> None:656 """657 Test that we can use an auth implementation specific to the async case, to658 support cases that require performing I/O or using concurrency primitives (such659 as checking a disk-based cache or fetching a token from a remote auth server).660 """661 url = "https://example.org/"662 auth = SyncOrAsyncAuth()

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 663why, one step back
663 app = App()

Add support for sync-specific or async-specific auth flows (#1217)Florimond Mancabefore adoption016e4ee

line 664why, one step back
664

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 665why, one step back
665 async with httpx.AsyncClient(transport=AsyncMockTransport(app)) as client:

Add support for sync-specific or async-specific auth flows (#1217)Florimond Mancabefore adoption016e4ee

lines 666–677why, one step back
666 response = await client.get(url, auth=auth)
667668 assert response.status_code == 200669 assert response.json() == {"auth": "async-auth"}670671672def test_sync_auth() -> None:673 """674 Test that we can use an auth implementation specific to the sync case.675 """676 url = "https://example.org/"677 auth = SyncOrAsyncAuth()

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 678why, one step back
678 app = App()

Add support for sync-specific or async-specific auth flows (#1217)Florimond Mancabefore adoption016e4ee

line 679why, one step back
679

Refactor test_auth.py to use `MockTransport` class. (#1288)Tom Christiebefore adoption2d6c30d

line 680why, one step back
680 with httpx.Client(transport=MockTransport(app)) as client:

Add support for sync-specific or async-specific auth flows (#1217)Florimond Mancabefore adoption016e4ee

lines 681–684why, one step back
681 response = client.get(url, auth=auth)
682683 assert response.status_code == 200684 assert response.json() == {"auth": "sync-auth"}