mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-12 03:48:56 +00:00
* refactor(proxy): expose public names for private proxy helpers Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(proxy): keep original class names behind public aliases Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(proxy): preserve internal callback filtering Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(proxy): keep _PROXY_ class names for managed files hooks Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(proxy): keep old private names in package exports Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(proxy): preserve recursive auth helper name Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(proxy): align MCP limiter tests with server enforcement Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(proxy): match main's MCP limiter tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(proxy): keep old private names bound in importing modules Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(proxy): preserve compatibility imports through strict lint Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(proxy): use exact pyright suppression in password helper test Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * style(proxy): add reasons to compatibility import noqa comments Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(proxy): update IN-list baseline for renamed helpers Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
import json
|
|
import os
|
|
from unittest import mock
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
import asyncio
|
|
import io
|
|
|
|
import openai
|
|
import pytest
|
|
from fastapi import Response
|
|
from fastapi.testclient import TestClient
|
|
|
|
import litellm
|
|
from litellm.proxy.proxy_server import ( # Replace with the actual module where your FastAPI router is defined
|
|
initialize,
|
|
router,
|
|
save_worker_config,
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def client():
|
|
filepath = os.path.dirname(os.path.abspath(__file__))
|
|
config_fp = f"{filepath}/test_configs/test_guardrails_config.yaml"
|
|
with mock.patch("litellm.proxy.proxy_server.premium_user", True):
|
|
asyncio.run(initialize(config=config_fp))
|
|
from litellm.proxy.proxy_server import app
|
|
|
|
return TestClient(app)
|
|
|
|
|
|
# raise openai.AuthenticationError
|
|
def test_active_callbacks(client):
|
|
response = client.get("/active/callbacks")
|
|
|
|
print("response", response)
|
|
print("response.text", response.text)
|
|
print("response.status_code", response.status_code)
|
|
|
|
json_response = response.json()
|
|
print(f"json_response={json_response}")
|
|
_active_callbacks = json_response["litellm.callbacks"]
|
|
|
|
expected_callback_names = [
|
|
"lakeraAI_Moderation",
|
|
"OPTIONAL_PromptInjectionDetection",
|
|
"_ENTERPRISE_SecretDetection",
|
|
]
|
|
|
|
for callback_name in expected_callback_names:
|
|
# check if any of the callbacks have callback_name as a substring
|
|
found_match = False
|
|
for callback in _active_callbacks:
|
|
if callback_name in callback:
|
|
found_match = True
|
|
break
|
|
assert (
|
|
found_match is True
|
|
), f"{callback_name} not found in _active_callbacks={_active_callbacks}"
|
|
|
|
assert not any(
|
|
"ENTERPRISE_OpenAI_Moderation" in callback for callback in _active_callbacks
|
|
), f"ENTERPRISE_OpenAI_Moderation should not be in _active_callbacks={_active_callbacks}"
|