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.8 KB
Raw Blame
from unittest.mock import Mock

import pytest

from local_deep_research.notifications.exceptions import ServiceError
from local_deep_research.notifications.service import NotificationService
from local_deep_research.notifications.manager import NotificationManager


def _unprotected_manager() -> NotificationManager:
    return NotificationManager(
        settings_snapshot={
            "policy.egress_scope": {"value": "unprotected"},
            "search.tool": {"value": "searxng"},
        },
        user_id="u",
    )


@pytest.mark.parametrize(
    "service_urls",
    [
        "slack://t/x/y,::1/x",
        "discord://id/token, [::1]:8080/hook",
        "slack://t/x/y,::ffff:192.0.2.128/hook",
        "slack://t/x/y,[fe80::1%25eth0]:8080/hook",
        "slack://t/x/y,fe80::1%eth0/hook",
        "slack://t/x/y,::1:99999/hook",
        "slack://t/x/y,[::1]/x",
        "slack://t/x/y,[2001:db8::1]:8080/x",
        "slack://t/x/y [::1]/x",
        "slack://t/x/y [2001:db8::1]/x",
        "slack://t/x/y,//[::1]/x",
        "slack://t/x/y //[::1]/x",
        "slack://t/x/y,[::1]:/x",
        "slack://t/x/y [::1]:/x",
        "slack://t/x/y,[::1]:name/x",
        "slack://t/x/y [::1]:name/x",
    ],
)
def test_manager_refuses_ipv6_fragment_configuration(
    service_urls: str,
    monkeypatch: pytest.MonkeyPatch,
) -> None:
    # Given
    manager = _unprotected_manager()
    service = NotificationService(outbound_allowed=True)
    dispatch = Mock()
    monkeypatch.setattr(service, "_dispatch", dispatch)

    # When
    filtered = manager._filter_urls_by_egress_policy(service_urls)

    # Then
    assert filtered == ""
    assert service._partition_urls(service_urls) == ([], [])
    with pytest.raises(ServiceError):
        service.send("title", "body", service_urls=service_urls)
    dispatch.assert_not_called()