litellm/tests/integration/management/test_smoke.py
devin-ai-integration[bot] 780c504e00
test: migrate tests/proxy_behavior into integration and unit tiers (#45939)
* test: migrate tests/proxy_behavior into integration and unit tiers (partial)

* test(integration): run settings-dependent management tests on an owned proxy

* test(integration): assert stored values in the rewritten management rows

* test(integration): pin sibling team allocations against the org guaranteed throughput cap

* test(integration): keep Prisma clients out of the shared integration conftest import path

---------

Co-authored-by: yuneng <yuneng@berri.ai>
2026-10-11 08:28:42 -07:00

22 lines
695 B
Python

import pytest
pytestmark = pytest.mark.asyncio(loop_scope="session")
async def test_key_generate_lands_in_db(gateway_client, db, resources):
from litellm.proxy.utils import hash_token
resp = await gateway_client.post(
"/key/generate",
headers={"Authorization": f"Bearer {gateway_client.gateway.key}"},
json={"key_alias": resources.prefix},
)
assert resp.status_code == 200, resp.text
cleartext = resp.json()["key"]
assert cleartext.startswith("sk-")
hashed = hash_token(cleartext)
row = await db.db.litellm_verificationtoken.find_unique(where={"token": hashed})
assert row is not None
assert row.token == hashed != cleartext