From e6077fdb6b9aab44cf927dddf93eed1235431d04 Mon Sep 17 00:00:00 2001 From: "glm-5.3-flash" Date: Mon, 31 Aug 2026 00:43:32 +0000 Subject: [PATCH] test(server): static-site decoy resolves directory requests to index.html (COV-12 review-002) --- src/server/decoy.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/server/decoy.rs b/src/server/decoy.rs index 9525011..a551da9 100644 --- a/src/server/decoy.rs +++ b/src/server/decoy.rs @@ -286,6 +286,26 @@ mod tests { assert_eq!(&bytes[..], b"

about

"); } + #[tokio::test] + async fn static_site_decoy_directory_request_resolves_to_index_html() { + let dir = tempfile_dir(); + tokio::fs::create_dir_all(dir.join("docs")).await.unwrap(); + tokio::fs::write(dir.join("docs").join("index.html"), "dir index") + .await + .unwrap(); + + let decoy = DecoyConfig::StaticSite { root: dir }; + let resp = send(decoy_router(decoy), "/docs").await; + assert_eq!(resp.status(), StatusCode::OK); + let ctype = resp + .headers() + .get(header::CONTENT_TYPE) + .map(|v| v.to_str().unwrap().to_string()); + assert!(ctype.as_deref().unwrap_or("").starts_with("text/html")); + let bytes = resp.into_body().collect().await.unwrap().to_bytes(); + assert_eq!(&bytes[..], b"dir index"); + } + #[tokio::test] async fn static_site_decoy_missing_file_returns_fake_404() { let dir = tempfile_dir();