mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-11 08:38:24 +00:00
test(logging): cover invalid worker config privacy
This commit is contained in:
parent
a6f8d0e0b1
commit
56372ea04f
1 changed files with 31 additions and 0 deletions
|
|
@ -4105,6 +4105,37 @@ def test_worker_config_privacy_applies_before_global_setting(
|
|||
assert "PRIVATE_SYSTEM_PROMPT" in str(result)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("as_json", [False, True])
|
||||
def test_worker_config_invalid_privacy_setting_does_not_expose_content(
|
||||
monkeypatch: pytest.MonkeyPatch, as_json: bool
|
||||
) -> None:
|
||||
from litellm.proxy.proxy_server import _redact_worker_config_for_logging
|
||||
|
||||
monkeypatch.setattr(litellm, "redact_messages_in_debug_logs", False)
|
||||
config: Final = {
|
||||
"litellm_settings": {"redact_messages_in_debug_logs": "invalid-boolean"},
|
||||
"model_list": [{"litellm_params": {"messages": [{"content": "PRIVATE_SYSTEM_PROMPT"}]}}],
|
||||
}
|
||||
original: Final = json.dumps(config)
|
||||
result: Final = _redact_worker_config_for_logging(original if as_json else config)
|
||||
|
||||
assert result == "redacted-by-litellm"
|
||||
assert json.dumps(config) == original
|
||||
assert litellm.redact_messages_in_debug_logs is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize("worker_config", ['{"messages": "PRIVATE_SYSTEM_PROMPT"', None])
|
||||
@pytest.mark.parametrize("enabled", [False, True])
|
||||
def test_worker_config_global_privacy_covers_unparseable_config(
|
||||
monkeypatch: pytest.MonkeyPatch, worker_config: str | None, enabled: bool
|
||||
) -> None:
|
||||
from litellm.proxy.proxy_server import _redact_worker_config_for_logging
|
||||
|
||||
monkeypatch.setattr(litellm, "redact_messages_in_debug_logs", enabled)
|
||||
|
||||
assert _redact_worker_config_for_logging(worker_config) == ("redacted-by-litellm" if enabled else worker_config)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_queue_request_labels_an_upstream_failure_a_server_error_not_an_auth_error(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue