Mid-LevelAPI & Integration Testing
How do you test file upload and download APIs?
- file upload
- file download
- multipart
Answer it first, then compare. Nothing here is saved or scored.
Model answer
Upload tests: verify multipart/form-data handling, file size limits (test at boundary and over), allowed file types (reject .exe, accept .pdf), filename sanitization (special characters, path traversal attempts like "../"), and virus scanning if applicable. Download tests: verify Content-Disposition header, correct MIME type, file integrity (checksum comparison), range requests for large files, and authorization (user A can't download user B's files).
What interviewers listen for
- Schema-first thinkingYou validate response shape before you assert on values, every time.
- Status-code literacyYou can defend why 401 vs 403 vs 422 matters for the consumer.
- Contract awarenessYou know when consumer-driven contract tests beat end-to-end checks.
- Auth fluencyYou can describe rotating tokens across parallel workers without secrets in logs.