DocHub/backend/tests/test_config.py
Tianyang 9ef22f9f0a Fix wave 2: CORS default, path traversal, delete UI, shared clients, bucket check
- Default CORS_ORIGINS to http://localhost:5173 instead of "*" (still overridable)
- Reject ".." and leading "/" in document keys/paths across get/save/delete/upload,
  mapped to HTTP 400 via new InvalidPathError
- Add a delete button to DocumentEditor wired to deleteDocument + onDeleted,
  giving the existing DELETE API an actual UI entry point
- Share a single lru_cache'd Meilisearch (and Minio) SDK client instance instead
  of constructing duplicates in dependencies.py
- Add a startup check that creates the MinIO bucket if missing, tolerating
  MinIO being unreachable at boot without crashing the app
2026-08-01 09:15:16 +08:00

18 lines
427 B
Python

from app.config import Settings
def test_cors_origins_defaults_to_localhost_dev_port(monkeypatch):
monkeypatch.delenv("CORS_ORIGINS", raising=False)
settings = Settings()
assert settings.cors_origins == ["http://localhost:5173"]
def test_cors_origins_can_be_overridden_to_wildcard(monkeypatch):
monkeypatch.setenv("CORS_ORIGINS", "*")
settings = Settings()
assert settings.cors_origins == ["*"]