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.3 KB
Raw Blame
from io import StringIO

import pytest
import requests
from loguru import logger

from local_deep_research.security.safe_requests import SafeSession

_SECRET = "credential-do-not-log"
_DESTINATION = f"http://user:{_SECRET}@127.0.0.1/private?token={_SECRET}"
_ORIGIN = "http://127.0.0.1"


def test_blocked_redirect_logs_only_destination_origin():
    session = SafeSession()
    original = requests.Request("GET", "https://origin.example/start").prepare()
    redirect = requests.Response()
    redirect.status_code = 302
    redirect.headers["Location"] = _DESTINATION
    redirect.request = original
    destination = next(
        session.resolve_redirects(redirect, original, yield_requests=True)
    )
    output = StringIO()
    logger.enable("local_deep_research")
    sink_id = logger.add(output, level="DEBUG", format="{message}\n{exception}")

    try:
        with pytest.raises(ValueError) as raised:
            session.send(destination)
    finally:
        logger.remove(sink_id)
        logger.disable("local_deep_research")
        session.close()

    rendered = output.getvalue()
    assert _ORIGIN in rendered
    assert _SECRET not in rendered
    assert "user:" not in rendered
    assert "token=" not in rendered
    assert _SECRET not in str(raised.value)