forked from phoenix/litellm-mirror
fix raise correct error 404 when /key/info is called on non-existent key (#6653)
* fix raise correct error on /key/info * add not_found_error error * fix key not found in DB error * use 1 helper for checking token hash * fix error code on key info * fix test key gen prisma * test_generate_and_call_key_info * test fix test_call_with_valid_model_using_all_models * fix key info tests
This commit is contained in:
parent
25bae4cc23
commit
de2f9aed3a
8 changed files with 3593 additions and 57 deletions
|
@ -412,7 +412,7 @@ async def test_key_info():
|
|||
Get key info
|
||||
- as admin -> 200
|
||||
- as key itself -> 200
|
||||
- as random key -> 403
|
||||
- as non existent key -> 404
|
||||
"""
|
||||
async with aiohttp.ClientSession() as session:
|
||||
key_gen = await generate_key(session=session, i=0)
|
||||
|
@ -425,10 +425,9 @@ async def test_key_info():
|
|||
# as key itself, use the auth param, and no query key needed
|
||||
await get_key_info(session=session, call_key=key)
|
||||
# as random key #
|
||||
key_gen = await generate_key(session=session, i=0)
|
||||
random_key = key_gen["key"]
|
||||
status = await get_key_info(session=session, get_key=key, call_key=random_key)
|
||||
assert status == 403
|
||||
random_key = f"sk-{uuid.uuid4()}"
|
||||
status = await get_key_info(session=session, get_key=random_key, call_key=key)
|
||||
assert status == 404
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue