diff --git a/starlette/testclient.py b/starlette/testclient.py index 63d879098..55973b735 100644 --- a/starlette/testclient.py +++ b/starlette/testclient.py @@ -418,6 +418,19 @@ def __init__( cookies=cookies, ) + @property + def auth(self) -> httpx.Auth | None: + """ + Authentication class used when none is passed at the request-level. + + See also [HTTPX Authentication](https://www.python-httpx.org/quickstart/#authentication). + """ + return self._auth + + @auth.setter + def auth(self, auth: httpx._types.AuthTypes) -> None: + self._auth = self._build_auth(auth) + @contextlib.contextmanager def _portal_factory(self) -> Generator[anyio.abc.BlockingPortal, None, None]: if self.portal is not None: