Skip to content
QA Knowledge Hub

Test cases for file upload

Updated 2026-11-13 · 6 min read

Thirty private-attachment cases using explicit PDF and PNG limits. Covers byte boundaries, spoofed metadata, scan failures and safe recovery after interrupted uploads.

How to answer in an interview

Ask what file types, sizes and counts are allowed, who may download them and whether processing is asynchronous. Start with upload followed by download and content comparison. Then separate selection, transfer, validation and processing failures: an upload progress bar reaching 100 percent does not necessarily mean the document is usable.

Scope and test data

Assume a private attachment form accepting PDF and PNG, at most three files and at most 5,242,880 bytes per file. Empty files are rejected. Files remain unavailable until validation and a configured scanner complete. Duplicate names are allowed as distinct attachments. Use harmless synthetic documents, valid images padded through an appropriate fixture tool and a scanner stub that can report clean, rejected or unavailable. Do not use live malware. OWASP recommends layered file validation and access controls; a filename extension or browser filter alone is not sufficient.

The 30 cases below are a test design, not an execution report. Replace the example rules with approved requirements before recording pass or fail. Performance budgets and supported device versions must be agreed before execution.

Selection and basic upload

IDCategoryTest caseExpected result
F01FunctionalUpload one valid small PDFOne attachment becomes ready after validation and can be downloaded
F02FunctionalUpload a valid PNG and download itDownloaded content matches the accepted fixture or documented transformed output
F03FunctionalSelect three valid files togetherThree distinct attachments reach ready state
F04BoundarySelect a fourth file when three are already attachedFourth file is refused and existing three remain intact
F05FunctionalCancel the operating-system file chooserExisting attachment selection remains unchanged
F06FunctionalUpload two different files with the same visible filenameSeparate attachment identifiers preserve both contents
F07FunctionalRemove a selected file before submissionRemoved file is not uploaded or attached
F08FunctionalRemove an uploaded attachmentIt is detached and subsequent access follows the configured deletion policy

Size and type boundaries

IDCategoryTest caseExpected result
F09BoundaryUpload a valid fixture of 5,242,879 bytesFile passes the size rule
F10BoundaryUpload a valid fixture of exactly 5,242,880 bytesFile passes the inclusive size limit
F11BoundaryUpload a fixture of 5,242,881 bytesServer rejects it with the stated limit and no ready attachment
F12NegativeUpload a zero-byte fileEmpty-file error appears and no attachment becomes ready
F13NegativeRename a disallowed file to end in .pdfContent validation rejects the mismatch
F14SecuritySpoof the request Content-Type for disallowed bytesServer does not accept the file merely because of the claimed MIME type
F15NegativeUpload a truncated PDF fixtureProcessing fails clearly without exposing a corrupt ready document
F16NegativeUse a double-extension filename for disallowed contentServer rejects the disallowed content despite the allowed-looking name
F17FunctionalUpload a valid file with spaces and local-script characters in its nameDisplay name remains readable and stored content is retrievable

Failure handling and access

IDCategoryTest caseExpected result
F18NegativeDisconnect during transferPartial upload is not attached as ready; user can retry
F19FunctionalRetry after losing the response to a successful uploadRecovery does not attach the same logical submission twice
F20NegativeMake the scanner return a rejected fixture resultFile remains unavailable and a rejection status is shown
F21NegativeMake the scanner unavailableFile stays pending or fails safely; it is not released as clean
F22SecurityRequest another account private attachment by identifierDownload is denied without returning file contents
F23SecurityUpload after the user session expiresServer refuses the unauthenticated attachment operation
F24SecuritySupply path traversal segments in a controlled filenameStored object cannot escape its designated location or overwrite another file
F25SecurityUse a filename containing harmless HTML-like textFilename is rendered as text without becoming markup
F26SecuritySend an upload through an unauthorised cross-site form in a cookie-authenticated setupRequest is refused by the application cross-site request protection

Usability and resource limits

IDCategoryTest caseExpected result
F27UIUse keyboard and screen reader to select, remove and inspect a rejected fileControls have names and each file error is associated with its file
F28UIUpload several files with one invalid fixtureEach outcome is visible; accepted files are not silently discarded
F29PerformanceUpload the permitted batch on the agreed slow-network profileProgress and cancellation remain usable and completion meets the defined budget
F30CompatibilityRepeat picker selection on supported desktop and mobile browsersAccepted types upload successfully and cancellation preserves form state

Evidence and prioritisation

Prioritise F01, F11, F14, F21 and F22. Record byte size, content type, hash where originals are preserved, attachment ID and processing transitions. Keep transfer success separate from scan success. A follow-up about archives needs a separate decompression and extraction policy; archives are outside this PDF/PNG suite. The common mistake is trusting a disabled file-picker choice as server-side validation.

Downloads

Quick answers

Does an allowed extension prove a file is safe?

No. Validate content and permissions in layers; client-provided names and MIME types are untrusted.

Should a scanner outage allow the file through?

Not under this private-attachment contract. Keep it inaccessible until the approved validation completes.

Sources

Want a project you can show in interviews?

The portfolio project kit walks you through testing a deliberately buggy app with Selenium or Playwright and API tests, then explaining it. The app itself is free.