Estructura inicial funcional con documentación en el README.md de la FastAPI

This commit is contained in:
2026-09-25 11:20:50 -03:00
parent edc71742fa
commit 774e227642
2710 changed files with 1012769 additions and 0 deletions

48
tests/test_linux.py Normal file
View File

@@ -0,0 +1,48 @@
"""Casos propios de Linux al DESCARGAR: aunque FSCrawler indexe un enlace simbólico
o una FIFO, la API no debe entregarlos ni colgarse. Y nombres con ':' funcionan."""
import os
import pytest
@pytest.fixture()
def storage(tmp_path, monkeypatch):
raiz = tmp_path / "archivos"
(raiz / "docs").mkdir(parents=True)
afuera = tmp_path / "afuera"
afuera.mkdir()
(afuera / "secreto.txt").write_text("secreto")
(raiz / "docs" / "Reunión 10:30.txt").write_text("acta") # ':' es válido en Linux
(raiz / "docs" / "enlace.txt").symlink_to(afuera / "secreto.txt") # apunta fuera de la raíz
(raiz / "docs" / "interno.txt").symlink_to(raiz / "docs" / "Reunión 10:30.txt") # enlace interno
os.mkfifo(raiz / "docs" / "tuberia.txt") # leerla colgaría la API
monkeypatch.setenv("STORAGE_TYPE", "local")
monkeypatch.setenv("STORAGE_ROOT", str(raiz))
import app.config
import app.storage
app.config.get_settings.cache_clear()
app.storage.get_storage.cache_clear()
yield app.storage.get_storage()
app.storage.get_storage.cache_clear()
def test_nombre_con_dos_puntos(storage):
assert storage.existe("docs/Reunión 10:30.txt") is True
with storage.abrir("docs/Reunión 10:30.txt") as f:
assert f.read() == b"acta"
def test_no_entrega_enlaces_ni_fifos(storage):
assert storage.existe("docs/enlace.txt") is False # sale de la raíz
assert storage.existe("docs/tuberia.txt") is False # no es un archivo regular
def test_no_sale_de_la_raiz(storage):
from app.storage import RutaInvalidaError
for ruta in ("../afuera/secreto.txt", "/etc/passwd", "C:/Windows/win.ini", "docs/../../afuera/secreto.txt"):
with pytest.raises(RutaInvalidaError):
storage.ruta_absoluta(ruta)
assert storage.existe(ruta) is False