test: fix proxy server testing

This commit is contained in:
Krrish Dholakia 2023-12-06 18:38:44 -08:00
parent 19b1deb200
commit c0eedf28fc
3 changed files with 27 additions and 11 deletions

View file

@ -234,7 +234,8 @@ async def user_api_key_auth(request: Request, api_key: str = fastapi.Security(ap
return UserAPIKeyAuth()
if api_key is None: # only require api key if master key is set
raise Exception("No api key passed in.")
raise Exception(f"No api key passed in.")
route = request.url.path
# note: never string compare api keys, this is vulenerable to a time attack. Use secrets.compare_digest instead
@ -816,11 +817,12 @@ async def startup_event():
@router.on_event("shutdown")
async def shutdown_event():
global prisma_client
global prisma_client, master_key, user_custom_auth
if prisma_client:
print("Disconnecting from Prisma")
await prisma_client.disconnect()
master_key = None
user_custom_auth = None
#### API ENDPOINTS ####
@router.get("/v1/models", dependencies=[Depends(user_api_key_auth)])
@router.get("/models", dependencies=[Depends(user_api_key_auth)]) # if project requires model list