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

Function test_netrc_auth_credentials_exist

tests/client/test_auth.py:237–253  ·  view source on GitHub ↗

When netrc auth is being used and a request is made to a host that is in the netrc file, then the relevant credentials should be applied.

()

Source from the content-addressed store, hash-verified

235
236
237def test_netrc_auth_credentials_exist() -> None:
238 """
239 When netrc auth is being used and a request is made to a host that is
240 in the netrc file, then the relevant credentials should be applied.
241 """
242 netrc_file = str(FIXTURES_DIR / ".netrc")
243 url = "http://netrcexample.org"
244 app = App()
245 auth = httpx.NetRCAuth(netrc_file)
246
247 with httpx.Client(transport=httpx.MockTransport(app), auth=auth) as client:
248 response = client.get(url)
249
250 assert response.status_code == 200
251 assert response.json() == {
252 "auth": "Basic ZXhhbXBsZS11c2VybmFtZTpleGFtcGxlLXBhc3N3b3Jk"
253 }
254
255
256def test_netrc_auth_credentials_do_not_exist() -> None:

Callers

nothing calls this directly

Calls 3

AppClass · 0.85
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected