From 1b4b5185bba87e2d8492af4046b573357f75a389 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 1 Feb 2024 13:56:54 -0800 Subject: [PATCH] (test) custom_auth bearer tokens --- litellm/tests/test_configs/custom_auth.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/litellm/tests/test_configs/custom_auth.py b/litellm/tests/test_configs/custom_auth.py index e4747ee5320..1b6bec43b5e 100644 --- a/litellm/tests/test_configs/custom_auth.py +++ b/litellm/tests/test_configs/custom_auth.py @@ -9,8 +9,14 @@ load_dotenv() async def user_api_key_auth(request: Request, api_key: str) -> UserAPIKeyAuth: try: print(f"api_key: {api_key}") + if api_key == "": + raise Exception( + f"CustomAuth - Malformed API Key passed in. Ensure Key has `Bearer` prefix" + ) if api_key == f"{os.getenv('PROXY_MASTER_KEY')}-1234": return UserAPIKeyAuth(api_key=api_key) raise Exception - except: + except Exception as e: + if len(str(e)) > 0: + raise e raise Exception("Failed custom auth")