Skip to content

Commit 33d9fb2

Browse files
test: add regression test for invalid_uuid reason on upload_chunk
The previous PR moved the UUID parse check above the store.get lookup so the 'invalid_uuid' reason code is actually emitted. Add a regression test that asserts the response body for a malformed UUID contains reason="invalid_uuid" (pre-fix it would have been "expired_or_unknown").
1 parent 832b8b6 commit 33d9fb2

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/main.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,6 +2485,29 @@ mod integration {
24852485
let _ = std::fs::remove_dir_all(dir);
24862486
}
24872487

2488+
#[rocket::async_test]
2489+
async fn upload_chunk_invalid_uuid_reports_invalid_uuid_reason() {
2490+
let mut rng = rand08::thread_rng();
2491+
let setup = TestSetup::new(&mut rng);
2492+
let (client, dir) = test_client(&setup).await;
2493+
2494+
let res = client
2495+
.put("/fileupload/not-a-uuid")
2496+
.header(Header::new("CryptifyToken", "any-token"))
2497+
.header(Header::new("Content-Range", "bytes 0-4/*"))
2498+
.body(b"xxxx" as &[u8])
2499+
.dispatch()
2500+
.await;
2501+
assert_eq!(res.status(), Status::NotFound);
2502+
let body = res.into_string().await.unwrap_or_default();
2503+
assert!(
2504+
body.contains("\"reason\":\"invalid_uuid\""),
2505+
"expected invalid_uuid reason, got: {body}"
2506+
);
2507+
2508+
let _ = std::fs::remove_dir_all(dir);
2509+
}
2510+
24882511
#[rocket::async_test]
24892512
async fn upload_finalize_rejects_wrong_cryptify_token() {
24902513
let mut rng = rand08::thread_rng();

0 commit comments

Comments
 (0)