Files
bookish-fork-dokerized/tests/conftest.py
T
truetype 0f15b7958f feat: self-hosted frontend JS (offline) + docker hardening
- Vendored epub.js/pdf.js+worker/JSZip/DOMPurify in static/vendor/
- reader.html/reader.js servono i JS da /static (niente CDN, offline-ready)
- CSP: rimosse allowlist CDN, aggiunto worker-src 'self' blob:
- Test CSP aggiornati; tutti 16 verdi; verificato smoke test offline in container
2026-08-29 22:32:10 +02:00

31 lines
1002 B
Python

"""Configurazione pytest comune: env PRIMA dell'import di config.py.
config.py alza RuntimeError se BOOKISH_DEBUG=false senza BOOKISH_SECRET:
per i test usiamo sempre DEBUG + secret di test.
Per isolare i test dal volume reale, BOOKISH_DATA_DIR punta a una tmp
dedicata, impostata qui così config.py la legge all'import.
"""
import os
import tempfile
import pytest
_DATA_TMP = tempfile.mkdtemp(prefix="bookish-test-")
os.environ["BOOKISH_DEBUG"] = "true"
os.environ["BOOKISH_SECRET"] = "test-secret-dummy"
os.environ["BOOKISH_CLEANUP_HOURS"] = "0"
os.environ["BOOKISH_DATA_DIR"] = _DATA_TMP
# Rate limit disattivato di default nei test: i test lo abilitano
# esplicitamente quando vogliono verificarlo (evita budget esauriti).
os.environ["BOOKISH_RATE_LIMIT_UPLOAD"] = "0"
@pytest.fixture(autouse=True)
def _reset_rate_state():
"""Pulisce lo stato globale del rate-limit tra i test."""
import bookish.services.security as sec
with sec._rate_lock:
sec._rate.clear()
yield