Browse Source

Fix `scopes` -> `oauth_scopes`

pull/14407/head
Yurii Motov 5 months ago
parent
commit
ca186edcf3
  1. 8
      tests/test_security_oauth2_authorization_code_bearer_scopes_openapi.py
  2. 2
      tests/test_security_oauth2_authorization_code_bearer_scopes_openapi_simple.py

8
tests/test_security_oauth2_authorization_code_bearer_scopes_openapi.py

@ -29,20 +29,20 @@ async def root():
@app.get(
"/with-oauth2-scheme",
dependencies=[Security(oauth2_scheme, scopes=["read", "write"])],
dependencies=[Security(oauth2_scheme, oauth_scopes=["read", "write"])],
)
async def read_with_oauth2_scheme():
return {"message": "Admin Access"}
@app.get(
"/with-get-token", dependencies=[Security(get_token, scopes=["read", "write"])]
"/with-get-token", dependencies=[Security(get_token, oauth_scopes=["read", "write"])]
)
async def read_with_get_token():
return {"message": "Admin Access"}
router = APIRouter(dependencies=[Security(oauth2_scheme, scopes=["read"])])
router = APIRouter(dependencies=[Security(oauth2_scheme, oauth_scopes=["read"])])
@router.get("/items/")
@ -52,7 +52,7 @@ async def read_items(token: Optional[str] = Depends(oauth2_scheme)):
@router.post("/items/")
async def create_item(
token: Optional[str] = Security(oauth2_scheme, scopes=["read", "write"]),
token: Optional[str] = Security(oauth2_scheme, oauth_scopes=["read", "write"]),
):
return {"token": token}

2
tests/test_security_oauth2_authorization_code_bearer_scopes_openapi_simple.py

@ -21,7 +21,7 @@ async def get_token(token: Annotated[str, Depends(oauth2_scheme)]) -> str:
app = FastAPI(dependencies=[Depends(get_token)])
@app.get("/admin", dependencies=[Security(get_token, scopes=["read", "write"])])
@app.get("/admin", dependencies=[Security(get_token, oauth_scopes=["read", "write"])])
async def read_admin():
return {"message": "Admin Access"}

Loading…
Cancel
Save