mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
(test) proxy_custom_auth use new exceptions
This commit is contained in:
parent
d2675a1ff3
commit
b3ce0ac728
2 changed files with 7 additions and 6 deletions
|
@ -13,4 +13,4 @@ async def user_api_key_auth(request: Request, api_key: str) -> UserAPIKeyAuth:
|
||||||
return UserAPIKeyAuth(api_key=api_key)
|
return UserAPIKeyAuth(api_key=api_key)
|
||||||
raise Exception
|
raise Exception
|
||||||
except:
|
except:
|
||||||
raise Exception
|
raise Exception("Failed custom auth")
|
||||||
|
|
|
@ -58,9 +58,10 @@ def test_custom_auth(client):
|
||||||
|
|
||||||
headers = {"Authorization": f"Bearer {token}"}
|
headers = {"Authorization": f"Bearer {token}"}
|
||||||
response = client.post("/chat/completions", json=test_data, headers=headers)
|
response = client.post("/chat/completions", json=test_data, headers=headers)
|
||||||
print(f"response: {response.text}")
|
pytest.fail("LiteLLM Proxy test failed. This request should have been rejected")
|
||||||
assert response.status_code == 401
|
|
||||||
result = response.json()
|
|
||||||
print(f"Received response: {result}")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pytest.fail("LiteLLM Proxy test failed. Exception", e)
|
print(vars(e))
|
||||||
|
print("got an exception")
|
||||||
|
assert e.code == 401
|
||||||
|
assert e.message == "Authentication Error, Failed custom auth"
|
||||||
|
pass
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue