~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
"""Origin comparison used to bind an endpoint API key to its endpoint."""
import pytest
from local_deep_research.utilities.url_utils import (
endpoint_origin,
same_endpoint_origin,
)
class TestEndpointOrigin:
def test_default_https_port_is_filled_in(self):
assert endpoint_origin("https://openrouter.ai/api/v1") == (
"https",
"openrouter.ai",
443,
)
def test_scheme_less_url_is_normalized_like_the_provider(self):
# normalize_url picks http for private hosts.
assert endpoint_origin("localhost:8000") == ("http", "localhost", 8000)
@pytest.mark.parametrize("value", [None, "", " ", 123])
def test_unparseable_values_have_no_origin(self, value):
assert endpoint_origin(value) is None
class TestSameEndpointOrigin:
@pytest.mark.parametrize(
("a", "b"),
[
# case
("https://OpenRouter.AI/api/v1", "https://openrouter.ai/api/v1"),
# default ports
(
"https://openrouter.ai:443/api/v1",
"https://openrouter.ai/api/v1",
),
("http://gateway.internal:80/v1", "http://gateway.internal/v1"),
# trailing slash and path
("https://openrouter.ai/api/v1/", "https://openrouter.ai"),
("https://openrouter.ai/other", "https://openrouter.ai/api/v1"),
# trailing dot on the host
("https://openrouter.ai./api/v1", "https://openrouter.ai/api/v1"),
],
)
def test_equivalent_urls_share_an_origin(self, a, b):
assert same_endpoint_origin(a, b)
assert same_endpoint_origin(b, a)
@pytest.mark.parametrize(
("a", "b"),
[
("https://gateway.corp.example/v1", "https://openrouter.ai/api/v1"),
("http://openrouter.ai/api/v1", "https://openrouter.ai/api/v1"),
(
"https://openrouter.ai:8443/api/v1",
"https://openrouter.ai/api/v1",
),
("https://api.openrouter.ai/v1", "https://openrouter.ai/api/v1"),
# userinfo cannot smuggle a different host past the comparison
(
"https://[email protected]/api/v1",
"https://openrouter.ai/api/v1",
),
],
)
def test_different_origins_do_not_match(self, a, b):
assert not same_endpoint_origin(a, b)
assert not same_endpoint_origin(b, a)
def test_two_unparseable_urls_never_match(self):
assert not same_endpoint_origin(None, None)
assert not same_endpoint_origin("", "")