Skip to content

test(server): add regression test for /schema upload size limit #49

Description

@ax1s-x1zz

Summary

The server's /schema upload path enforces MAX_UPLOAD_BYTES (50 MiB) and rejects oversized files with 413 PAYLOAD_TOO_LARGE (xazz-server/src/main.rs ~line 501), but this behavior has no test. A regression could silently allow unbounded uploads (disk DoS).

Context

  • Constant: MAX_UPLOAD_BYTES in xazz-server/src/main.rs.
  • Handler: handle_schema reads the multipart field, checks data.len() > MAX_UPLOAD_BYTES, and returns (StatusCode::PAYLOAD_TOO_LARGE, ...).
  • Existing tests in #[cfg(test)] mod tests call handlers directly (see handle_execute tests) — no HTTP server is needed.
  • The axum Multipart extractor is the hard part: you can build a Multipart from a reqwest::multipart-style body, or test the size check by extracting the reusable validation into a helper function that takes &[u8] and asserting on that helper directly.

Task

Add a test that proves an upload larger than MAX_UPLOAD_BYTES is rejected with 413. Two acceptable approaches:

  1. Preferred: extract the size-check into a small pure helper (e.g. fn validate_upload_size(len: usize) -> Result<(), StatusCode>) used by handle_schema, and unit-test it with MAX_UPLOAD_BYTES and MAX_UPLOAD_BYTES + 1.
  2. Or build a real multipart body and invoke handle_schema with it.

Definition of Done

  • A test named something like oversized_upload_is_rejected passes.
  • Boundary covered: == MAX_UPLOAD_BYTES allowed, +1 rejected.
  • cargo test -p xazz-server passes; cargo fmt --all -- --check clean.

Notes

  • This is the server crate; it links tokio/axum, so builds are a bit heavier than xazz-compiler, but cargo test -p xazz-server is the scope.
  • User-facing error strings in the handler are English; if you add any, keep them English.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions