Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

1.5 KB
Raw Blame
"""Regression coverage for credential-bearing notification service URLs.

The service_url name makes the configured value sensitive while its textarea
control preserves explicit clearing. Use the shipped metadata so these checks
catch losing name-based redaction without relying on a password-only override.
"""

import json
from pathlib import Path

from local_deep_research.security.data_sanitizer import DataSanitizer

_KEY = "notifications.service_url"
_SECRET = "discord://1234567890/abcdEFGH_realtoken"


def _service_url_ui_element() -> str:
    path = (
        Path(__file__).resolve().parents[2]
        / "src"
        / "local_deep_research"
        / "defaults"
        / "default_settings.json"
    )
    return json.loads(path.read_text())[_KEY]["ui_element"]


def test_service_url_is_sensitive_with_shipped_metadata():
    """Removing service_url from the sensitive names must not expose it."""
    assert (
        DataSanitizer.is_sensitive_setting(_KEY, _service_url_ui_element())
        is True
    )


def test_redact_value_masks_configured_service_url():
    """A configured service URL is masked using its actual control type."""
    redacted = DataSanitizer.redact_value(
        _KEY, _service_url_ui_element(), _SECRET
    )
    assert redacted == DataSanitizer.REDACTION_TEXT
    assert _SECRET not in str(redacted)


def test_empty_service_url_passes_through():
    """An unset value stays readable so the UI can tell configured from not."""
    assert DataSanitizer.redact_value(_KEY, _service_url_ui_element(), "") == ""