paste-bin/tests/test_headers.py
Jarian 985e070757 port: FastAPI rewrite built by the arch-llm spec pipeline
Spec-first port of the Flask app (still on main):
- schema.arch: signed arch-llm spec (single source of truth)
- paste_bin/: generated FastAPI backend, verified 51/51 frozen owner
  tests, 92.5% coverage (build r3, 2026-11-18)
- ui/: SPA + emitted OpenAPI contract (openapi.json + generated
  client.js); the app calls only window.PasteBinAPI
- 7 old bugs fixed (file raw 500, silent expiry, AVI-as-webp,
  stripped content, limiter leak, trusted mimetype, stale tmp)
- 62/62 live probe green; /health + JSON index added; JSON API

Full report on the wiki: 'FastAPI port (arch-llm pipeline)'.
2026-11-18 23:00:23 +00:00

22 lines
791 B
Python

# tests for module headers (paste_bin/headers.py)
from paste_bin.headers import security_headers
def test_base_headers():
h = security_headers()
assert h["X-Content-Type-Options"] == "nosniff"
assert h["X-Frame-Options"] == "DENY"
assert h["X-XSS-Protection"] == "1; mode=block"
assert h["Referrer-Policy"] == "strict-origin-when-cross-origin"
assert h["Content-Security-Policy"] == (
"default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'"
)
assert "Strict-Transport-Security" not in h
def test_hsts_only_when_secure():
assert "Strict-Transport-Security" not in security_headers(is_secure=False)
h = security_headers(is_secure=True)
assert h["Strict-Transport-Security"] == "max-age=31536000; includeSubDomains"