Some checks failed
/ build (push) Failing after 5s
174 tests covering URL normalization, FTS5 query sanitization, SSRF/CSRF guards, sharing-mode logic, DB schema and upsert paths, handler end-to-end flows, and gateway body-size / mesh-whitelist guards. Each recent bug-fix commit (6ffd38d,1bc695f,8dffd8c) has an explicit regression test in test_regressions.py. One xfail documents a minor latent bug in clean_url where port 80 is not stripped from upgraded https URLs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
"""Tests for `_page_is_shared`.
|
|
|
|
This function decides whether a page is exposed over Reticulum to
|
|
subscribers. Getting it wrong means either a privacy leak or silently
|
|
hiding pages the user meant to share — both are worth a regression net.
|
|
"""
|
|
import pytest
|
|
|
|
from handlers import _page_is_shared
|
|
|
|
|
|
@pytest.mark.parametrize("mode", ["exclude_private", "require_public"])
|
|
def test_private_tag_always_excludes(mode):
|
|
"""`private` tag overrides every mode — the most important invariant."""
|
|
assert _page_is_shared(["private"], mode) is False
|
|
assert _page_is_shared(["public", "private"], mode) is False
|
|
|
|
|
|
def test_exclude_private_defaults_to_shared():
|
|
assert _page_is_shared([], "exclude_private") is True
|
|
assert _page_is_shared(["random-tag"], "exclude_private") is True
|
|
|
|
|
|
def test_require_public_needs_public_tag():
|
|
assert _page_is_shared([], "require_public") is False
|
|
assert _page_is_shared(["rust"], "require_public") is False
|
|
assert _page_is_shared(["public"], "require_public") is True
|
|
|
|
|
|
def test_require_public_still_vetoes_private():
|
|
# public AND private → private wins.
|
|
assert _page_is_shared(["public", "private"], "require_public") is False
|
|
|
|
|
|
def test_unknown_mode_treated_as_exclude_private():
|
|
"""The default mode is 'exclude_private'; unknown modes fall through to it."""
|
|
assert _page_is_shared([], "totally-bogus-mode") is True
|
|
assert _page_is_shared(["private"], "totally-bogus-mode") is False
|