Developer testing guide

Document testing guide for uploads and previews

PDF and Office pipelines combine upload and storage behavior with format-specific parsing and preview conversion. A compact verified set helps isolate each layer.

Verified . Exact bytes, SHA-256, MIME, PDF pages, Office package entries, sheets, and slides are regenerated and compared during asset checks.

Practical checklist

  • Validate signatures and MIME server-side.
  • Apply parser timeouts and decompression limits.
  • Test preview fallbacks for unsupported formats.
  • Preserve original bytes while deriving previews.

Treat documents as untrusted input

Use size limits, parser isolation, safe filenames, and Office package entry limits. Never execute embedded content or trust the client-provided MIME value.

Design preview fallbacks

PDF and Office previews may use separate services. When conversion is unavailable, show verified metadata and a download action instead of an empty frame.

Verify storage and downloads

Check Content-Disposition, MIME headers, cache policy, access controls, original byte integrity, and retry behavior for asynchronous conversions.

Expected results

  • PDF and Office signatures match their published MIME values.
  • Unsupported previews still expose metadata and a safe download.
  • The stored SHA-256 equals the published detail page value.

Common failure modes

  • Treating every ZIP signature as the same Office type.
  • Running untrusted parsers without time or memory limits.
  • Discarding the original after preview conversion.

Check the fixture with curl

Download the representative file and print the response status, MIME type, and transferred byte count.

Shell
curl --fail --location --silent --show-error \
  --output sample-document.pdf \
  --write-out 'status=%{http_code}\ncontent_type=%{content_type}\nbytes=%{size_download}\n' \
  'https://assets.testfiles.dev/documents/sample-document.pdf'

Verify document integrity with Python Requests

Download the document and assert its MIME type, exact byte size, and SHA-256 digest before passing it to a parser or preview service.

Python
import hashlib
import requests

url = "https://assets.testfiles.dev/documents/sample-document.pdf"
response = requests.get(url, timeout=30)
response.raise_for_status()

assert "application/pdf" in response.headers.get("content-type", "")
assert len(response.content) == 9051
assert hashlib.sha256(response.content).hexdigest() == "c0ca139748753dd192bda50ea731868e8f832b5ed97499d12ffb2c995791ffbc"
print("Verified sample-document.pdf", len(response.content), "bytes")

Use stable sample files

These fixtures have stable URLs, recorded MIME types, byte sizes, SHA-256 values, and dedicated detail pages.

Format references

Copied