diff --git a/tests/test_litellm/proxy/proxy_server/test_proxy_config.py b/tests/test_litellm/proxy/proxy_server/test_proxy_config.py index 42cd6e4ed78..d0130adb099 100644 --- a/tests/test_litellm/proxy/proxy_server/test_proxy_config.py +++ b/tests/test_litellm/proxy/proxy_server/test_proxy_config.py @@ -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 diff --git a/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py b/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py index ab8542ca06c..8f781c73acc 100644 --- a/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py +++ b/tests/test_litellm/proxy/ui_crud_endpoints/test_proxy_setting_endpoints.py @@ -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