MCPcopy
hub / github.com/encode/httpx / test_basic_auth

Function test_basic_auth

tests/test_auth.py:14–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12
13
14def test_basic_auth():
15 auth = httpx.BasicAuth(username="user", password="pass")
16 request = httpx.Request("GET", "https://www.example.com")
17
18 # The initial request should include a basic auth header.
19 flow = auth.sync_auth_flow(request)
20 request = next(flow)
21 assert request.headers["Authorization"].startswith("Basic")
22
23 # No other requests are made.
24 response = httpx.Response(content=b"Hello, world!", status_code=200)
25 with pytest.raises(StopIteration):
26 flow.send(response)
27
28
29def test_digest_auth_with_200():

Callers

nothing calls this directly

Calls 2

sync_auth_flowMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected