mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
(test) missing Bearer in custom auth
This commit is contained in:
parent
5ee62b25f5
commit
e6bc73d131
1 changed files with 27 additions and 0 deletions
|
@ -65,3 +65,30 @@ def test_custom_auth(client):
|
|||
assert e.code == 401
|
||||
assert e.message == "Authentication Error, Failed custom auth"
|
||||
pass
|
||||
|
||||
|
||||
def test_custom_auth_bearer(client):
|
||||
try:
|
||||
# Your test data
|
||||
test_data = {
|
||||
"model": "openai-model",
|
||||
"messages": [
|
||||
{"role": "user", "content": "hi"},
|
||||
],
|
||||
"max_tokens": 10,
|
||||
}
|
||||
# Your bearer token
|
||||
token = os.getenv("PROXY_MASTER_KEY")
|
||||
|
||||
headers = {"Authorization": f"WITHOUT BEAR Er {token}"}
|
||||
response = client.post("/chat/completions", json=test_data, headers=headers)
|
||||
pytest.fail("LiteLLM Proxy test failed. This request should have been rejected")
|
||||
except Exception as e:
|
||||
print(vars(e))
|
||||
print("got an exception")
|
||||
assert e.code == 401
|
||||
assert (
|
||||
e.message
|
||||
== "Authentication Error, CustomAuth - Malformed API Key passed in. Ensure Key has `Bearer` prefix"
|
||||
)
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue