Files
wehub-resource-sync 7a0da7932b
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:08:55 +08:00

102 lines
3.7 KiB
Python

"""Edge-case tests for url_utils.normalize_url and network_utils.is_private_ip."""
class TestNormalizeUrlIPv6:
"""IPv6 handling in normalize_url."""
def test_bracketed_ipv6_public_gets_https(self):
"""Public IPv6 like [2607:f8b0::] should get https scheme."""
from local_deep_research.utilities.url_utils import normalize_url
result = normalize_url("[2607:f8b0::]:8080")
assert result.startswith("https://")
assert "[2607:f8b0::]" in result
def test_bracketed_ipv6_link_local_gets_http(self):
"""Link-local fe80:: should be treated as private -> http."""
from local_deep_research.utilities.url_utils import normalize_url
result = normalize_url("[fe80::1]:8080")
assert result.startswith("http://")
class TestNormalizeUrlMalformed:
"""Malformed URL handling."""
def test_http_triple_slash_passthrough(self):
"""http:///path is already prefixed with http:// so it passes through."""
from local_deep_research.utilities.url_utils import normalize_url
result = normalize_url("http:///path")
# Starts with http:// so the early return fires
assert result == "http:///path"
def test_https_malformed_with_path(self):
"""https:host.com/api/v1 -> https://host.com/api/v1."""
from local_deep_research.utilities.url_utils import normalize_url
result = normalize_url("https:host.com/api/v1")
assert result == "https://host.com/api/v1"
class TestNormalizeUrlPreservation:
"""Query strings and fragments are preserved."""
def test_url_with_query_parameters(self):
"""Query strings preserved through normalization."""
from local_deep_research.utilities.url_utils import normalize_url
result = normalize_url("https://example.com/search?q=test&page=2")
assert "?q=test&page=2" in result
def test_url_with_fragment(self):
"""#section fragments preserved."""
from local_deep_research.utilities.url_utils import normalize_url
result = normalize_url("https://example.com/page#section")
assert "#section" in result
class TestIsPrivateIpBoundary:
"""Boundary tests for is_private_ip."""
def test_172_15_boundary_is_public(self):
"""172.15.255.255 is just below the 172.16.0.0/12 private range."""
from local_deep_research.security.network_utils import is_private_ip
assert is_private_ip("172.15.255.255") is False
def test_172_16_is_private(self):
"""172.16.0.0 is the start of the private range."""
from local_deep_research.security.network_utils import is_private_ip
assert is_private_ip("172.16.0.0") is True
def test_169_254_link_local(self):
"""169.254.x.x (APIPA) is link-local and should be private."""
from local_deep_research.security.network_utils import is_private_ip
assert is_private_ip("169.254.1.1") is True
def test_empty_hostname_not_private(self):
"""Empty string edge case — not a valid IP, doesn't end with .local."""
from local_deep_research.security.network_utils import is_private_ip
assert is_private_ip("") is False
class TestIsPrivateIpLocalSuffix:
"""Tests for .local mDNS domain detection."""
def test_local_suffix_is_private(self):
"""printer.local is a valid mDNS name -> private."""
from local_deep_research.security.network_utils import is_private_ip
assert is_private_ip("printer.local") is True
def test_local_substring_is_not_private(self):
"""localnet.com should NOT be detected as private."""
from local_deep_research.security.network_utils import is_private_ip
assert is_private_ip("localnet.com") is False