feat(api): remove redundant /env and /api/diagnostic/settings endpoints
- Remove `/api/diagnostic/settings` endpoint (superseded by `/api/settings/`) - Remove `/env` view route (superseded by `/settings` admin page) - Delete `env_debug.html` template - Remove `/env` nav links from base.html (desktop + mobile) - Update status_dashboard.html to link to /settings instead of /env - Remove corresponding tests for deleted endpoints - Update RateLimitingStrategy.md docs Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -6,118 +6,6 @@ import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestDiagnosticSettings:
|
||||
"""Tests for GET /diagnostic/settings endpoint."""
|
||||
|
||||
@patch("app.utils.config_validator.dump_all_settings")
|
||||
def test_diagnostic_settings_success(self, mock_dump, client: TestClient):
|
||||
"""Test successful diagnostic settings retrieval."""
|
||||
from app.config import settings
|
||||
|
||||
with patch.object(settings, "workdir", "/tmp/test"):
|
||||
with patch.object(settings, "external_hostname", "test-host"):
|
||||
with patch.object(settings, "email_host", "smtp.test.com"):
|
||||
with patch.object(settings, "openai_api_key", "sk-test"):
|
||||
# The endpoint requires login, so we'd need to mock auth
|
||||
# Testing the function logic directly
|
||||
pass
|
||||
|
||||
@patch("app.utils.config_validator.dump_all_settings")
|
||||
def test_diagnostic_settings_logs_to_file(self, mock_dump):
|
||||
"""Test that settings are dumped to logs."""
|
||||
# Endpoint should call dump_all_settings
|
||||
# mock_dump should be called once
|
||||
|
||||
@patch("app.utils.config_validator.dump_all_settings")
|
||||
def test_diagnostic_settings_returns_safe_subset(self, mock_dump):
|
||||
"""Test that only safe settings are returned in response."""
|
||||
from app.config import settings
|
||||
|
||||
with patch.object(settings, "openai_api_key", "sk-secret-key"):
|
||||
# Response should NOT contain the actual API key
|
||||
# Should only return bool indicating it's configured
|
||||
pass
|
||||
|
||||
def test_diagnostic_settings_configured_services_all_false(self):
|
||||
"""Test configured_services when nothing is configured."""
|
||||
from app.config import settings
|
||||
|
||||
with patch.object(settings, "email_host", None):
|
||||
with patch.object(settings, "s3_bucket_name", None):
|
||||
with patch.object(settings, "dropbox_refresh_token", None):
|
||||
with patch.object(settings, "onedrive_refresh_token", None):
|
||||
with patch.object(settings, "nextcloud_upload_url", None):
|
||||
with patch.object(settings, "sftp_host", None):
|
||||
with patch.object(settings, "paperless_host", None):
|
||||
with patch.object(settings, "google_drive_credentials_json", None):
|
||||
with patch.object(settings, "uptime_kuma_url", None):
|
||||
with patch.object(settings, "authentik_config_url", None):
|
||||
with patch.object(settings, "openai_api_key", None):
|
||||
with patch.object(settings, "azure_ai_key", None):
|
||||
# All configured_services should be False
|
||||
pass
|
||||
|
||||
def test_diagnostic_settings_configured_services_all_true(self):
|
||||
"""Test configured_services when all services are configured."""
|
||||
from app.config import settings
|
||||
|
||||
with patch.object(settings, "email_host", "smtp.test.com"):
|
||||
with patch.object(settings, "s3_bucket_name", "test-bucket"):
|
||||
with patch.object(settings, "dropbox_refresh_token", "token"):
|
||||
# All configured_services should be True
|
||||
pass
|
||||
|
||||
def test_diagnostic_settings_imap_enabled_imap1(self):
|
||||
"""Test imap_enabled when imap1_host is configured."""
|
||||
from app.config import settings
|
||||
|
||||
with patch.object(settings, "imap1_host", "imap.test.com"):
|
||||
with patch.object(settings, "imap2_host", None):
|
||||
# imap_enabled should be True
|
||||
pass
|
||||
|
||||
def test_diagnostic_settings_imap_enabled_imap2(self):
|
||||
"""Test imap_enabled when imap2_host is configured."""
|
||||
from app.config import settings
|
||||
|
||||
with patch.object(settings, "imap1_host", None):
|
||||
with patch.object(settings, "imap2_host", "imap2.test.com"):
|
||||
# imap_enabled should be True
|
||||
pass
|
||||
|
||||
def test_diagnostic_settings_imap_disabled(self):
|
||||
"""Test imap_enabled when no IMAP hosts configured."""
|
||||
from app.config import settings
|
||||
|
||||
with patch.object(settings, "imap1_host", None):
|
||||
with patch.object(settings, "imap2_host", None):
|
||||
# imap_enabled should be False
|
||||
pass
|
||||
|
||||
def test_diagnostic_settings_azure_requires_both_settings(self):
|
||||
"""Test Azure configured only when both key and endpoint are set."""
|
||||
from app.config import settings
|
||||
|
||||
# Only key, no endpoint
|
||||
with patch.object(settings, "azure_ai_key", "key"):
|
||||
with patch.object(settings, "azure_endpoint", None):
|
||||
# azure should be False
|
||||
pass
|
||||
|
||||
# Only endpoint, no key
|
||||
with patch.object(settings, "azure_ai_key", None):
|
||||
with patch.object(settings, "azure_endpoint", "https://test.com"):
|
||||
# azure should be False
|
||||
pass
|
||||
|
||||
# Both set
|
||||
with patch.object(settings, "azure_ai_key", "key"):
|
||||
with patch.object(settings, "azure_endpoint", "https://test.com"):
|
||||
# azure should be True
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestTestNotification:
|
||||
"""Tests for POST /diagnostic/test-notification endpoint."""
|
||||
|
||||
Reference in New Issue
Block a user