mirror of https://github.com/tiangolo/fastapi.git
Remove code examples for Python 3.8 in `authentication_error_status_code`
This commit is contained in:
parent
b3a3ebba6f
commit
3b563725ee
|
|
@ -1,20 +0,0 @@
|
||||||
from fastapi import Depends, FastAPI, HTTPException, status
|
|
||||||
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
|
||||||
from typing_extensions import Annotated
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
|
|
||||||
class HTTPBearer403(HTTPBearer):
|
|
||||||
def make_not_authenticated_error(self) -> HTTPException:
|
|
||||||
return HTTPException(
|
|
||||||
status_code=status.HTTP_403_FORBIDDEN, detail="Not authenticated"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
CredentialsDep = Annotated[HTTPAuthorizationCredentials, Depends(HTTPBearer403())]
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/me")
|
|
||||||
def read_me(credentials: CredentialsDep):
|
|
||||||
return {"message": "You are authenticated", "token": credentials.credentials}
|
|
||||||
|
|
@ -4,14 +4,11 @@ import pytest
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
from inline_snapshot import snapshot
|
from inline_snapshot import snapshot
|
||||||
|
|
||||||
from ...utils import needs_py39
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(
|
@pytest.fixture(
|
||||||
name="client",
|
name="client",
|
||||||
params=[
|
params=[
|
||||||
"tutorial001_an",
|
"tutorial001_an_py39",
|
||||||
pytest.param("tutorial001_an_py39", marks=needs_py39),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def get_client(request: pytest.FixtureRequest):
|
def get_client(request: pytest.FixtureRequest):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue