mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
test(proxy): lock the allowed_ips enterprise gate and the delete 404 branch
Self-review found two mutants that survived the first round of tests. Disabling the boot-time Enterprise check for allowed_ips entirely, and disabling the 404 branch that rejects deleting an IP that was never added, both left every test green. Neither branch was exercised anywhere in the suite.
This commit is contained in:
parent
cfcf0b0997
commit
8ac229033f
2 changed files with 43 additions and 0 deletions
|
|
@ -4399,3 +4399,37 @@ async def test_add_deployment_syncs_ui_settings_even_when_the_model_reconcile_fa
|
|||
await config.add_deployment(prisma_client=prisma_client, proxy_logging_obj=MagicMock())
|
||||
|
||||
assert general_settings["allow_agents_for_team_admins"] is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
("allowed_ips_yaml", "expected_error"),
|
||||
[
|
||||
(" allowed_ips: []\n", None),
|
||||
("", None),
|
||||
(" allowed_ips:\n - 127.0.0.1\n", "allowed_ips is an Enterprise Feature"),
|
||||
],
|
||||
)
|
||||
async def test_ProxyConfig_load_config_enterprise_gate_ignores_an_empty_allowed_ips(
|
||||
tmp_path, monkeypatch, allowed_ips_yaml, expected_error
|
||||
):
|
||||
"""An empty allowed_ips is no allowlist at all, so it must not trip the Enterprise
|
||||
gate and refuse to boot a non-premium proxy. Deleting the last entry used to leave
|
||||
[] behind, which would have bricked startup as well as request handling."""
|
||||
config_file = tmp_path / "allowed_ips.yaml"
|
||||
config_file.write_text("model_list: []\nlitellm_settings: {}\ngeneral_settings:\n master_key: null\n" + allowed_ips_yaml)
|
||||
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", None)
|
||||
monkeypatch.setattr("litellm.proxy.proxy_server.store_model_in_db", False)
|
||||
monkeypatch.setattr("litellm.proxy.proxy_server.premium_user", False)
|
||||
monkeypatch.delenv("LITELLM_CONFIG_BUCKET_NAME", raising=False)
|
||||
|
||||
try:
|
||||
await ProxyConfig().load_config(router=None, config_file_path=str(config_file))
|
||||
raised = None
|
||||
except ValueError as exc:
|
||||
raised = str(exc)
|
||||
|
||||
if expected_error is None:
|
||||
assert raised is None
|
||||
else:
|
||||
assert raised is not None and expected_error in raised
|
||||
|
|
|
|||
|
|
@ -3563,3 +3563,12 @@ class TestDeleteAllowedIpClearsTheKeyWhenTheListEmpties:
|
|||
|
||||
assert saved["config"]["general_settings"]["allowed_ips"] == ["198.51.100.1"]
|
||||
assert general_settings["allowed_ips"] == ["198.51.100.1"]
|
||||
|
||||
def test_removing_an_ip_that_was_never_added_is_rejected(self, monkeypatch):
|
||||
general_settings, saved = self._harness(monkeypatch, ["203.0.113.77"])
|
||||
|
||||
resp = self._delete("198.51.100.99")
|
||||
|
||||
assert resp.status_code == 404
|
||||
assert general_settings["allowed_ips"] == ["203.0.113.77"]
|
||||
assert "config" not in saved
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue