Files
tsumugu/backend/tests/test_paperless_files.py
LarsandCursor b328385561
Deploy Development / deploy (push) Failing after 39s
Lies Paperless-Dateien aus dem Ablageordner, wenn die Vorschau keine anzeigbare Datei liefert.
Eine unbekannte Dokumentnummer wird als solche gemeldet.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-17 07:12:35 +02:00

23 lines
924 B
Python

"""The Paperless disk fallback stays inside the archive directory."""
from __future__ import annotations
from app.sources import read_paperless_file
def test_reads_the_archive_pdf(tmp_path):
target = tmp_path / "documents" / "archive" / "2026" / "brief.pdf"
target.parent.mkdir(parents=True)
target.write_bytes(b"%PDF-1.1 sample")
assert read_paperless_file(str(tmp_path), "archive", "2026/brief.pdf") == b"%PDF-1.1 sample"
def test_rejects_paths_outside_the_archive(tmp_path):
secret = tmp_path / "documents" / "secret.pdf"
secret.parent.mkdir(parents=True)
secret.write_bytes(b"%PDF-1.1 secret")
(tmp_path / "documents" / "archive").mkdir()
assert read_paperless_file(str(tmp_path), "archive", "../secret.pdf") is None
assert read_paperless_file(str(tmp_path), "archive", "/etc/passwd") is None
assert read_paperless_file(str(tmp_path), "other", "2026/brief.pdf") is None