test: add end-to-end upload-pipeline integration test harness#109
Conversation
Refactor `rocket()` to extract a `build_rocket(figment, vk)` builder so tests can inject a `VerifyingKey` (via `pg_core::test::TestSetup`) without needing a live PKG at startup. Add `email_stub` config flag so the finalize happy path does not require an SMTP server. New integration tests in `src/main.rs` (mod `integration`) drive the full init → chunk(s) → finalize flow against a real Rocket client, using payloads sealed with pg-core's streaming Sealer. Covers the happy path (single chunk + multi-chunk), plus cross-handler edge cases (invalid email, wrong cryptify_token on chunk/finalize, unknown uuid, size mismatch, content-range misalignment). Refs #108.
|
/dobby resolve conflicts |
|
Dobby is here, Dobby sees the review approval! Dobby is so happy that Master rubenhensen approved Dobby's work! Dobby will check the CI checks and, if all is well, Dobby will mark the PR ready for review. Dobby serves! |
Resolve conflict around the launch entrypoint by combining both refactors: - keep `default_figment()` / `build_rocket(figment, vk)` split from this branch - adopt configurable `chunk_size` (TOML, default 5 MB) from main Body-size limits (`bytes`, `data-form`, `file`) are now derived from the extracted CryptifyConfig inside `build_rocket` rather than a constant, since chunk_size isn't known until the test harness has merged its overrides on top of `default_figment()`. All 39 tests (30 pre-existing + 9 integration) pass; clippy is clean apart from the pre-existing useless_format warning in src/email.rs.
|
Resolved merge conflict with What I changed during the mergeThe conflict was around the launch entrypoint where this branch's
Net effect: production behaviour is unchanged, integration tests still get the same framework-level limits, and Verification
The three "why draft" questions from the original PR description still stand for reviewer input, but the branch itself is mergeable now. |
|
Rule compliance pass applied:
No code changes beyond formatting. |
There was a problem hiding this comment.
Self-review (cannot --approve own PR). Re-checked after the main merge and fmt pass since the earlier human approval on 24bcd16.
- 'cargo build' clean
- 'cargo test' — 39 passed, 0 failed
- 'cargo clippy --all-targets' — only the pre-existing 'useless_format' warning in src/email.rs:261 (unrelated)
- 'cargo fmt --all -- --check' — clean
The conflict resolution moves the body-size limit computation from default_figment() into build_rocket() so it can read the now-configurable chunk_size after the test figment is layered on top. Behaviour is production-equivalent (same chunk_size + 1 MiB headroom on 'bytes' / 'data-form' / 'file'), and integration tests go through the same builder path as production. No further changes needed — ready to merge from this agent's perspective.
|
/dobby resolve the conflicts |
|
This agent is on it! This agent is happy to roll up its sleeves and resolve the merge conflicts on this PR — checking out the branch, rebasing on main, and reporting back what needed reconciling. |
# Conflicts: # Cargo.lock # src/email.rs # src/error.rs # src/main.rs
|
Conflicts resolved against What needed reconciling
|
|
/dobby fix the conflicts |
|
Dobby hears you, master rubenhensen! Dobby will fix the conflicts on this branch right away! 🧹 |
|
Conflicts resolved against main. What conflicted: Resolution: kept both. The new Verification:
Diff vs main is non-empty (~370 insertions), so this is not a no-op merge. Ready for re-review, @rubenhensen. |
Summary
Adds the integration test harness requested in #108. Boots a real Rocket instance via a new
build_rocket(figment, vk)builder and exercises the fullPOST /fileupload/init→PUT /fileupload/<uuid>→POST /fileupload/finalize/<uuid>flow, with payloads sealed by pg-core's streaming Sealer soupload_finalize's realUnsealerruns.What changed
src/main.rs— extractbuild_rocket(figment, vk)anddefault_figment()from the#[launch]rocket()entrypoint. Production launch is unchanged (still fetchesVerifyingKeyviaminreq); tests inject their own.src/config.rs/src/email.rs— new optionalemail_stub: boolconfig field (defaultfalse). Whentrue,send_emaillogs and returnsOkwithout touching SMTP.Cargo.toml— addpg-corewith thetestfeature and arand 0.8alias as dev-dependencies only (pg-core's APIs use rand 0.8 while the crate itself uses 0.9).src/main.rs— newintegrationtest module (9 tests):upload_happy_path_init_chunk_finalize— single-chunk round-tripupload_happy_path_multi_chunk— two-chunk round-trip (~2 MiB)upload_init_rejects_invalid_emailupload_chunk_rejects_wrong_cryptify_tokenupload_chunk_unknown_uuid_returns_404upload_chunk_rejects_content_range_misalignmentupload_finalize_rejects_wrong_cryptify_tokenupload_finalize_rejects_size_mismatchupload_finalize_unknown_uuid_returns_404Each test uses its own temp
data_dirunderstd::env::temp_dir()so they can run in parallel.Reviewer quickstart
All 36 tests (27 pre-existing + 9 new) pass locally.
Closes #108.