From 4bff1d0abe3f90fa804c79c4a8b69fb2a0595216 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 3 Feb 2023 20:35:19 -0500 Subject: [PATCH 1/2] require safe tokio version range see https://rustsec.org/advisories/RUSTSEC-2023-0005 --- actix-http-test/Cargo.toml | 2 +- actix-http/Cargo.toml | 4 ++-- actix-multipart/Cargo.toml | 2 +- actix-test/Cargo.toml | 2 +- actix-web-actors/Cargo.toml | 2 +- actix-web/Cargo.toml | 2 +- awc/Cargo.toml | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/actix-http-test/Cargo.toml b/actix-http-test/Cargo.toml index 0942556da..23fffdc17 100644 --- a/actix-http-test/Cargo.toml +++ b/actix-http-test/Cargo.toml @@ -47,7 +47,7 @@ serde_json = "1.0" slab = "0.4" serde_urlencoded = "0.7" tls-openssl = { version = "0.10.9", package = "openssl", optional = true } -tokio = { version = "1.18.4", features = ["sync"] } +tokio = { version = "1.18.5", features = ["sync"] } [dev-dependencies] actix-web = { version = "4", default-features = false, features = ["cookies"] } diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index d7fb19757..19302d002 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -77,7 +77,7 @@ mime = "0.3" percent-encoding = "2.1" pin-project-lite = "0.2" smallvec = "1.6.1" -tokio = { version = "1.18.4", features = [] } +tokio = { version = "1.18.5", features = [] } tokio-util = { version = "0.7", features = ["io", "codec"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] } @@ -119,7 +119,7 @@ serde_json = "1.0" static_assertions = "1" tls-openssl = { package = "openssl", version = "0.10.9" } tls-rustls = { package = "rustls", version = "0.20.0" } -tokio = { version = "1.18.4", features = ["net", "rt", "macros"] } +tokio = { version = "1.18.5", features = ["net", "rt", "macros"] } [[example]] name = "ws" diff --git a/actix-multipart/Cargo.toml b/actix-multipart/Cargo.toml index 7ed67e951..8f768563c 100644 --- a/actix-multipart/Cargo.toml +++ b/actix-multipart/Cargo.toml @@ -30,5 +30,5 @@ memchr = "2.5" actix-rt = "2.2" actix-http = "3" futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] } -tokio = { version = "1.18.4", features = ["sync"] } +tokio = { version = "1.18.5", features = ["sync"] } tokio-stream = "0.1" diff --git a/actix-test/Cargo.toml b/actix-test/Cargo.toml index d489d4a05..213d6bc36 100644 --- a/actix-test/Cargo.toml +++ b/actix-test/Cargo.toml @@ -45,4 +45,4 @@ serde_json = "1" serde_urlencoded = "0.7" tls-openssl = { package = "openssl", version = "0.10.9", optional = true } tls-rustls = { package = "rustls", version = "0.20.0", optional = true } -tokio = { version = "1.18.4", features = ["sync"] } +tokio = { version = "1.18.5", features = ["sync"] } diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index 4a610ab95..4eb9ddc62 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -23,7 +23,7 @@ bytes = "1" bytestring = "1" futures-core = { version = "0.3.17", default-features = false } pin-project-lite = "0.2" -tokio = { version = "1.18.4", features = ["sync"] } +tokio = { version = "1.18.5", features = ["sync"] } tokio-util = { version = "0.7", features = ["codec"] } [dev-dependencies] diff --git a/actix-web/Cargo.toml b/actix-web/Cargo.toml index 3c7cef19c..44755035c 100644 --- a/actix-web/Cargo.toml +++ b/actix-web/Cargo.toml @@ -115,7 +115,7 @@ serde = { version = "1.0", features = ["derive"] } static_assertions = "1" tls-openssl = { package = "openssl", version = "0.10.9" } tls-rustls = { package = "rustls", version = "0.20.0" } -tokio = { version = "1.18.4", features = ["rt-multi-thread", "macros"] } +tokio = { version = "1.18.5", features = ["rt-multi-thread", "macros"] } zstd = "0.12" [[test]] diff --git a/awc/Cargo.toml b/awc/Cargo.toml index a717774f7..a69a07d67 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -80,7 +80,7 @@ rand = "0.8" serde = "1.0" serde_json = "1.0" serde_urlencoded = "0.7" -tokio = { version = "1.18.4", features = ["sync"] } +tokio = { version = "1.18.5", features = ["sync"] } cookie = { version = "0.16", features = ["percent-encode"], optional = true } @@ -106,7 +106,7 @@ futures-util = { version = "0.3.17", default-features = false } static_assertions = "1.1" rcgen = "0.9" rustls-pemfile = "1" -tokio = { version = "1.18.4", features = ["rt-multi-thread", "macros"] } +tokio = { version = "1.18.5", features = ["rt-multi-thread", "macros"] } zstd = "0.12" [[example]] From b933ed445611c752401342a3a020bbf185d2031d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 3 Feb 2023 21:04:07 -0500 Subject: [PATCH 2/2] add tests for files_listing_renderer --- actix-files/src/files.rs | 43 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/actix-files/src/files.rs b/actix-files/src/files.rs index a30ce6fd3..be2a450d2 100644 --- a/actix-files/src/files.rs +++ b/actix-files/src/files.rs @@ -142,7 +142,7 @@ impl Files { self } - /// Set custom directory renderer + /// Set custom directory renderer. pub fn files_listing_renderer(mut self, f: F) -> Self where for<'r, 's> F: @@ -152,7 +152,7 @@ impl Files { self } - /// Specifies mime override callback + /// Specifies MIME override callback. pub fn mime_override(mut self, f: F) -> Self where F: Fn(&mime::Name<'_>) -> DispositionType + 'static, @@ -390,3 +390,42 @@ impl ServiceFactory for Files { } } } + +#[cfg(test)] +mod tests { + use actix_web::{ + http::StatusCode, + test::{self, TestRequest}, + App, HttpResponse, + }; + + use super::*; + + #[actix_web::test] + async fn custom_files_listing_renderer() { + let srv = test::init_service( + App::new().service( + Files::new("/", "./tests") + .show_files_listing() + .files_listing_renderer(|dir, req| { + Ok(ServiceResponse::new( + req.clone(), + HttpResponse::Ok().body(dir.path.to_str().unwrap().to_owned()), + )) + }), + ), + ) + .await; + + let req = TestRequest::with_uri("/").to_request(); + let res = test::call_service(&srv, req).await; + + assert_eq!(res.status(), StatusCode::OK); + let body = test::read_body(res).await; + assert!( + body.ends_with(b"actix-files/tests/"), + "body {:?} does not end with `actix-files/tests/`", + body + ); + } +}