aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--build.rs2
-rw-r--r--src/args.rs8
-rw-r--r--src/auth.rs6
-rw-r--r--src/config.rs4
-rw-r--r--src/listing.rs2
-rw-r--r--src/main.rs12
-rw-r--r--src/renderer.rs22
-rw-r--r--tests/create_directories.rs4
-rw-r--r--tests/fixtures/mod.rs10
-rw-r--r--tests/navigation.rs18
-rw-r--r--tests/qrcode.rs2
-rw-r--r--tests/raw.rs8
-rw-r--r--tests/readme.rs8
-rw-r--r--tests/serve_request.rs30
-rw-r--r--tests/tls.rs4
-rw-r--r--tests/upload_files.rs6
16 files changed, 72 insertions, 74 deletions
diff --git a/build.rs b/build.rs
index 8c354d0..e65b294 100644
--- a/build.rs
+++ b/build.rs
@@ -6,7 +6,7 @@ fn main() {
let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env var missing");
let dest_path = Path::new(&out_dir).join("style.css");
fs::write(
- &dest_path,
+ dest_path,
grass::from_string(
include_str!("data/style.scss").to_string(),
&grass::Options::default(),
diff --git a/src/args.rs b/src/args.rs
index 4ba5f24..243eecf 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -239,7 +239,7 @@ fn parse_auth(src: &str) -> Result<auth::RequiredAuth, ContextualError> {
/// Custom header parser (allow multiple headers input)
pub fn parse_header(src: &str) -> Result<HeaderMap, httparse::Error> {
let mut headers = [httparse::EMPTY_HEADER; 1];
- let header = format!("{}\n", src);
+ let header = format!("{src}\n");
httparse::parse_headers(header.as_bytes(), &mut headers)?;
let mut header_map = HeaderMap::new();
@@ -269,8 +269,8 @@ mod tests {
let password = match encrypt {
"plain" => Plain(password.to_owned()),
- "sha256" => Sha256(hex::decode(password.to_owned()).unwrap()),
- "sha512" => Sha512(hex::decode(password.to_owned()).unwrap()),
+ "sha256" => Sha256(hex::decode(password).unwrap()),
+ "sha512" => Sha512(hex::decode(password).unwrap()),
_ => panic!("Unknown encryption type"),
};
@@ -314,6 +314,6 @@ mod tests {
)]
fn parse_auth_invalid(auth_string: &str, err_msg: &str) {
let err = parse_auth(auth_string).unwrap_err();
- assert_eq!(format!("{}", err), err_msg.to_owned());
+ assert_eq!(format!("{err}"), err_msg.to_owned());
}
}
diff --git a/src/auth.rs b/src/auth.rs
index c7d0b78..92157c9 100644
--- a/src/auth.rs
+++ b/src/auth.rs
@@ -114,7 +114,7 @@ mod tests {
fn test_get_hash(password: &str, hash_method: &str, hash: &str) {
let hash_func = get_hash_func(hash_method);
let expected = hex::decode(hash).expect("Provided hash is not a valid hex code");
- let received = hash_func(&password.to_owned());
+ let received = hash_func(password);
assert_eq!(received, expected);
}
@@ -124,8 +124,8 @@ mod tests {
let password = match encrypt {
"plain" => Plain(password.to_owned()),
- "sha256" => Sha256(get_hash::<sha2::Sha256>(&password.to_owned())),
- "sha512" => Sha512(get_hash::<sha2::Sha512>(&password.to_owned())),
+ "sha256" => Sha256(get_hash::<sha2::Sha256>(password)),
+ "sha512" => Sha512(get_hash::<sha2::Sha512>(password)),
_ => panic!("Unknown encryption type"),
};
diff --git a/src/config.rs b/src/config.rs
index 9223dec..d3f125f 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -190,10 +190,10 @@ impl MiniserveConfig {
{
let cert_file = &mut BufReader::new(
File::open(&tls_cert)
- .context(format!("Couldn't access TLS certificate {:?}", tls_cert))?,
+ .context(format!("Couldn't access TLS certificate {tls_cert:?}"))?,
);
let key_file = &mut BufReader::new(
- File::open(&tls_key).context(format!("Couldn't access TLS key {:?}", tls_key))?,
+ File::open(&tls_key).context(format!("Couldn't access TLS key {tls_key:?}"))?,
);
let cert_chain = pemfile::certs(cert_file).context("Reading cert file")?;
let key = pemfile::read_all(key_file)
diff --git a/src/listing.rs b/src/listing.rs
index bca531a..ba4789a 100644
--- a/src/listing.rs
+++ b/src/listing.rs
@@ -368,7 +368,7 @@ pub fn directory_listing(
.append_header(("Content-Transfer-Encoding", "binary"))
.append_header((
"Content-Disposition",
- format!("attachment; filename={:?}", file_name),
+ format!("attachment; filename={file_name:?}"),
))
.body(actix_web::body::BodyStream::new(rx)),
))
diff --git a/src/main.rs b/src/main.rs
index e2d34e9..cf02025 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -123,7 +123,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> {
.flush()
.map_err(|e| ContextualError::IoError("Failed to write data".to_string(), e))?;
for c in "3… 2… 1… \n".chars() {
- print!("{}", c);
+ print!("{c}");
io::stdout()
.flush()
.map_err(|e| ContextualError::IoError("Failed to write data".to_string(), e))?;
@@ -161,8 +161,8 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> {
IpAddr::V6(_) => format!("[{}]:{}", addr, miniserve_config.port),
})
.map(|addr| match miniserve_config.tls_rustls_config {
- Some(_) => format!("https://{}", addr),
- None => format!("http://{}", addr),
+ Some(_) => format!("https://{addr}"),
+ None => format!("http://{addr}"),
})
.map(|url| format!("{}{}", url, miniserve_config.route_prefix))
.collect::<Vec<_>>()
@@ -202,7 +202,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> {
let srv = socket_addresses.iter().try_fold(srv, |srv, addr| {
let listener = create_tcp_listener(*addr).map_err(|e| {
- ContextualError::IoError(format!("Failed to bind server to {}", addr), e)
+ ContextualError::IoError(format!("Failed to bind server to {addr}"), e)
})?;
#[cfg(feature = "tls")]
@@ -214,7 +214,7 @@ async fn run(miniserve_config: MiniserveConfig) -> Result<(), ContextualError> {
#[cfg(not(feature = "tls"))]
let srv = srv.listen(listener);
- srv.map_err(|e| ContextualError::IoError(format!("Failed to bind server to {}", addr), e))
+ srv.map_err(|e| ContextualError::IoError(format!("Failed to bind server to {addr}"), e))
})?;
let srv = srv.shutdown_timeout(0).run();
@@ -297,7 +297,7 @@ fn configure_app(app: &mut web::ServiceConfig, conf: &MiniserveConfig) {
// Note: --spa requires --index in clap.
if conf.spa {
files = files.default_handler(
- NamedFile::open(&conf.path.join(index_file))
+ NamedFile::open(conf.path.join(index_file))
.expect("Can't open SPA index file."),
);
}
diff --git a/src/renderer.rs b/src/renderer.rs
index 5ba69a2..0937be4 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -47,7 +47,7 @@ pub fn page(
|| conf
.allowed_upload_dir
.iter()
- .any(|x| encoded_dir.starts_with(&format!("/{}", x)));
+ .any(|x| encoded_dir.starts_with(&format!("/{x}")));
html! {
(DOCTYPE)
@@ -286,7 +286,7 @@ fn wget_footer(title_path: &str, current_user: Option<&CurrentUser>) -> Markup {
html! {
div.downloadDirectory {
p { "Download folder:" }
- div.cmd { (format!("wget -r -c -nH -np --cut-dirs={} -R \"index.html*\"{} \"http://{}/?raw=true\"", count, user_params, title_path)) }
+ div.cmd { (format!("wget -r -c -nH -np --cut-dirs={count} -R \"index.html*\"{user_params} \"http://{title_path}/?raw=true\"")) }
}
}
}
@@ -298,7 +298,7 @@ fn build_upload_action(
sort_method: Option<SortingMethod>,
sort_order: Option<SortingOrder>,
) -> String {
- let mut upload_action = format!("{}?path={}", upload_route, encoded_dir);
+ let mut upload_action = format!("{upload_route}?path={encoded_dir}");
if let Some(sorting_method) = sort_method {
upload_action = format!("{}&sort={}", upload_action, &sorting_method);
}
@@ -311,7 +311,7 @@ fn build_upload_action(
/// Build the action of the mkdir form
fn build_mkdir_action(mkdir_route: &str, encoded_dir: &str) -> String {
- format!("{}?path={}", mkdir_route, encoded_dir)
+ format!("{mkdir_route}?path={encoded_dir}")
}
const THEME_PICKER_CHOICES: &[(&str, &str)] = &[
@@ -345,7 +345,7 @@ fn qr_spoiler(show_qrcode: bool, content: impl AsRef<str>) -> Markup {
div.qrcode #qrcode title=(PreEscaped(content.as_ref())) {
@match qr_code_svg(content, consts::SVG_QR_MARGIN) {
Ok(svg) => (PreEscaped(svg)),
- Err(err) => (format!("QR generation error: {:?}", err)),
+ Err(err) => (format!("QR generation error: {err:?}")),
}
}
}
@@ -391,7 +391,7 @@ fn archive_button(
sort_order: Option<SortingOrder>,
) -> Markup {
let link = if sort_method.is_none() && sort_order.is_none() {
- format!("?download={}", archive_method)
+ format!("?download={archive_method}")
} else {
format!(
"{}&download={}",
@@ -414,7 +414,7 @@ fn make_link_with_trailing_slash(link: &str) -> String {
if link.ends_with('/') {
link.to_string()
} else {
- format!("{}/", link)
+ format!("{link}/")
}
}
@@ -452,8 +452,8 @@ fn build_link(
sort_method: Option<SortingMethod>,
sort_order: Option<SortingOrder>,
) -> Markup {
- let mut link = format!("?sort={}&order=asc", name);
- let mut help = format!("Sort by {} in ascending order", name);
+ let mut link = format!("?sort={name}&order=asc");
+ let mut help = format!("Sort by {name} in ascending order");
let mut chevron = chevron_up();
let mut class = "";
@@ -462,8 +462,8 @@ fn build_link(
class = "active";
if let Some(order) = sort_order {
if order.to_string() == "asc" {
- link = format!("?sort={}&order=desc", name);
- help = format!("Sort by {} in descending order", name);
+ link = format!("?sort={name}&order=desc");
+ help = format!("Sort by {name} in descending order");
chevron = chevron_down();
}
}
diff --git a/tests/create_directories.rs b/tests/create_directories.rs
index fa8f4b8..380c796 100644
--- a/tests/create_directories.rs
+++ b/tests/create_directories.rs
@@ -117,7 +117,7 @@ fn creating_directories_through_symlinks_is_prevented(
.post(
server
.url()
- .join(format!("/upload?path=/{}", symlink_directory_str).as_str())?
+ .join(format!("/upload?path=/{symlink_directory_str}").as_str())?
)
.multipart(form)
.send()?
@@ -153,7 +153,7 @@ fn prevent_path_transversal_attacks(
// This should fail
assert!(Client::new()
- .post(server.url().join(&format!("/upload/path={}", path))?)
+ .post(server.url().join(&format!("/upload/path={path}"))?)
.multipart(form)
.send()?
.error_for_status()
diff --git a/tests/fixtures/mod.rs b/tests/fixtures/mod.rs
index ec17f3e..05b72f9 100644
--- a/tests/fixtures/mod.rs
+++ b/tests/fixtures/mod.rs
@@ -64,14 +64,14 @@ pub fn tmpdir() -> TempDir {
for directory in directories {
for file in &files {
tmpdir
- .child(format!("{}{}", directory, file))
- .write_str(&format!("This is {}{}", directory, file))
+ .child(format!("{directory}{file}"))
+ .write_str(&format!("This is {directory}{file}"))
.expect("Couldn't write to file");
}
}
tmpdir
- .child(&DEEPLY_NESTED_FILE)
+ .child(DEEPLY_NESTED_FILE)
.write_str("File in a deeply nested directory.")
.expect("Couldn't write to file");
tmpdir
@@ -144,11 +144,11 @@ where
fn wait_for_port(port: u16) {
let start_wait = Instant::now();
- while !port_check::is_port_reachable(format!("localhost:{}", port)) {
+ while !port_check::is_port_reachable(format!("localhost:{port}")) {
sleep(Duration::from_millis(100));
if start_wait.elapsed().as_secs() > 1 {
- panic!("timeout waiting for port {}", port);
+ panic!("timeout waiting for port {port}");
}
}
}
diff --git a/tests/navigation.rs b/tests/navigation.rs
index f4a2e1f..fa58456 100644
--- a/tests/navigation.rs
+++ b/tests/navigation.rs
@@ -34,7 +34,7 @@ fn cant_navigate_up_the_root(server: TestServer) -> Result<(), Error> {
.arg("-s")
.arg("--fail")
.arg("--path-as-is")
- .arg(format!("{}/../", base_url))
+ .arg(format!("{base_url}/../"))
.stdout(Stdio::null())
.status()?
.success();
@@ -50,13 +50,13 @@ fn can_navigate_into_dirs_and_back(server: TestServer) -> Result<(), Error> {
let initial_body = reqwest::blocking::get(base_url.as_str())?.error_for_status()?;
let initial_parsed = Document::from_read(initial_body)?;
for &directory in DIRECTORIES {
- let dir_elem = get_link_from_text(&initial_parsed, &directory).expect("Dir not found.");
+ let dir_elem = get_link_from_text(&initial_parsed, directory).expect("Dir not found.");
let body =
- reqwest::blocking::get(&format!("{}{}", base_url, dir_elem))?.error_for_status()?;
+ reqwest::blocking::get(&format!("{base_url}{dir_elem}"))?.error_for_status()?;
let parsed = Document::from_read(body)?;
let back_link =
get_link_from_text(&parsed, "Parent directory").expect("Back link not found.");
- let resp = reqwest::blocking::get(&format!("{}{}", base_url, back_link))?;
+ let resp = reqwest::blocking::get(&format!("{base_url}{back_link}"))?;
// Now check that we can actually get back to the original location we came from using the
// link.
@@ -73,8 +73,8 @@ fn can_navigate_deep_into_dirs_and_back(server: TestServer) -> Result<(), Error>
// remove that part.
let dir_names = {
let mut comps = DEEPLY_NESTED_FILE
- .split("/")
- .map(|d| format!("{}/", d))
+ .split('/')
+ .map(|d| format!("{d}/"))
.collect::<Vec<String>>();
comps.pop();
comps
@@ -88,7 +88,7 @@ fn can_navigate_deep_into_dirs_and_back(server: TestServer) -> Result<(), Error>
let resp = reqwest::blocking::get(next_url.as_str())?;
let body = resp.error_for_status()?;
let parsed = Document::from_read(body)?;
- let dir_elem = get_link_from_text(&parsed, &dir_name).expect("Dir not found.");
+ let dir_elem = get_link_from_text(&parsed, dir_name).expect("Dir not found.");
next_url = next_url.join(&dir_elem)?;
}
assert_ne!(base_url, next_url);
@@ -119,8 +119,8 @@ fn can_navigate_using_breadcrumbs(
// remove that part.
let dir: String = {
let mut comps = DEEPLY_NESTED_FILE
- .split("/")
- .map(|d| format!("{}/", d))
+ .split('/')
+ .map(|d| format!("{d}/"))
.collect::<Vec<String>>();
comps.pop();
comps.join("")
diff --git a/tests/qrcode.rs b/tests/qrcode.rs
index c47e634..48fa8c8 100644
--- a/tests/qrcode.rs
+++ b/tests/qrcode.rs
@@ -46,7 +46,7 @@ fn run_in_faketty_kill_and_get_stdout(template: &Command) -> Result<String, Erro
.map(|s| s.to_str().expect("not UTF8"))
.collect::<Vec<_>>()
.join(" ");
- format!("{} {}", bin, args)
+ format!("{bin} {args}")
};
let mut child = bash_command(&cmd)?.stdin(Stdio::null()).spawn()?;
diff --git a/tests/raw.rs b/tests/raw.rs
index 99d6661..f212f58 100644
--- a/tests/raw.rs
+++ b/tests/raw.rs
@@ -67,13 +67,11 @@ fn raw_mode_links_to_directories_end_with_raw_true(
"doesn't end with ?raw=true"
);
} else if class == "file" {
- assert!(true);
+ return;
} else {
- println!(
- "This node is a link and neither of class directory, root or file: {:?}",
- node
+ panic!(
+ "This node is a link and neither of class directory, root or file: {node:?}"
);
- assert!(false);
}
}
}
diff --git a/tests/readme.rs b/tests/readme.rs
index 3fcbe29..2a0ad13 100644
--- a/tests/readme.rs
+++ b/tests/readme.rs
@@ -52,7 +52,7 @@ fn show_root_readme_contents(
assert!(parsed.find(|x: &Node| x.text() == file).next().is_some());
}
// ...in addition to the readme contents below the file listing.
- assert_readme_contents(&parsed, &readme_name);
+ assert_readme_contents(&parsed, readme_name);
remove_file(readme_path).unwrap();
Ok(())
}
@@ -84,7 +84,7 @@ fn show_nested_readme_contents(
assert!(parsed.find(|x: &Node| x.text() == file).next().is_some());
}
// ...in addition to the readme contents below the file listing.
- assert_readme_contents(&parsed, &readme_name);
+ assert_readme_contents(&parsed, readme_name);
remove_file(readme_path).unwrap();
}
Ok(())
@@ -94,7 +94,7 @@ fn write_readme_contents(path: PathBuf, filename: &str) -> PathBuf {
let readme_path = path.join(filename);
let mut readme_file = File::create(&readme_path).unwrap();
readme_file
- .write(format!("Contents of {}", filename).to_string().as_bytes())
+ .write(format!("Contents of {filename}").as_bytes())
.expect("Couldn't write readme");
readme_path
}
@@ -123,5 +123,5 @@ fn assert_readme_contents(parsed_dom: &Document, filename: &str) {
.unwrap()
.text()
.trim()
- .contains(&format!("Contents of {}", filename)));
+ .contains(&format!("Contents of {filename}")));
}
diff --git a/tests/serve_request.rs b/tests/serve_request.rs
index f376469..5ad0d60 100644
--- a/tests/serve_request.rs
+++ b/tests/serve_request.rs
@@ -51,7 +51,7 @@ fn serves_requests_with_non_default_port(server: TestServer) -> Result<(), Error
let f = parsed.find(|x: &Node| x.text() == file).next().unwrap();
reqwest::blocking::get(server.url().join(f.attr("href").unwrap())?)?.error_for_status()?;
assert_eq!(
- format!("/{}", file),
+ format!("/{file}"),
percent_encoding::percent_decode_str(f.attr("href").unwrap()).decode_utf8_lossy(),
);
}
@@ -62,7 +62,7 @@ fn serves_requests_with_non_default_port(server: TestServer) -> Result<(), Error
.next()
.is_some());
let dir_body =
- reqwest::blocking::get(server.url().join(&directory)?)?.error_for_status()?;
+ reqwest::blocking::get(server.url().join(directory)?)?.error_for_status()?;
let dir_body_parsed = Document::from_read(dir_body)?;
for &file in FILES {
assert!(dir_body_parsed
@@ -80,23 +80,23 @@ fn serves_requests_hidden_files(#[with(&["--hidden"])] server: TestServer) -> Re
let body = reqwest::blocking::get(server.url())?.error_for_status()?;
let parsed = Document::from_read(body)?;
- for &file in FILES.into_iter().chain(HIDDEN_FILES) {
+ for &file in FILES.iter().chain(HIDDEN_FILES) {
let f = parsed.find(|x: &Node| x.text() == file).next().unwrap();
assert_eq!(
- format!("/{}", file),
+ format!("/{file}"),
percent_encoding::percent_decode_str(f.attr("href").unwrap()).decode_utf8_lossy(),
);
}
- for &directory in DIRECTORIES.into_iter().chain(HIDDEN_DIRECTORIES) {
+ for &directory in DIRECTORIES.iter().chain(HIDDEN_DIRECTORIES) {
assert!(parsed
.find(|x: &Node| x.text() == directory)
.next()
.is_some());
let dir_body =
- reqwest::blocking::get(server.url().join(&directory)?)?.error_for_status()?;
+ reqwest::blocking::get(server.url().join(directory)?)?.error_for_status()?;
let dir_body_parsed = Document::from_read(dir_body)?;
- for &file in FILES.into_iter().chain(HIDDEN_FILES) {
+ for &file in FILES.iter().chain(HIDDEN_FILES) {
assert!(dir_body_parsed
.find(|x: &Node| x.text() == file)
.next()
@@ -112,12 +112,12 @@ fn serves_requests_no_hidden_files_without_flag(server: TestServer) -> Result<()
let body = reqwest::blocking::get(server.url())?.error_for_status()?;
let parsed = Document::from_read(body)?;
- for &hidden_item in HIDDEN_FILES.into_iter().chain(HIDDEN_DIRECTORIES) {
+ for &hidden_item in HIDDEN_FILES.iter().chain(HIDDEN_DIRECTORIES) {
assert!(parsed
.find(|x: &Node| x.text() == hidden_item)
.next()
.is_none());
- let resp = reqwest::blocking::get(server.url().join(&hidden_item)?)?;
+ let resp = reqwest::blocking::get(server.url().join(hidden_item)?)?;
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
}
@@ -139,8 +139,8 @@ fn serves_requests_symlinks(
// Set up some basic symlinks:
// to dir, to file, to non-existent location
- let orig = DIRECTORIES[0].strip_suffix("/").unwrap();
- let link = server.path().join(dir.strip_suffix("/").unwrap());
+ let orig = DIRECTORIES[0].strip_suffix('/').unwrap();
+ let link = server.path().join(dir.strip_suffix('/').unwrap());
symlink_dir(orig, link).expect("Couldn't create symlink");
symlink_file(FILES[0], server.path().join(file)).expect("Couldn't create symlink");
symlink_file("should-not-exist.xxx", server.path().join(broken))
@@ -150,7 +150,7 @@ fn serves_requests_symlinks(
let parsed = Document::from_read(body)?;
for &entry in &[file, dir] {
- let status = reqwest::blocking::get(server.url().join(&entry)?)?.status();
+ let status = reqwest::blocking::get(server.url().join(entry)?)?.status();
// We expect a 404 here for when `no_symlinks` is `true`.
if no_symlinks {
assert_eq!(status, StatusCode::NOT_FOUND);
@@ -175,8 +175,8 @@ fn serves_requests_symlinks(
}
let node = node.unwrap();
- assert_eq!(node.attr("href").unwrap().strip_prefix("/").unwrap(), entry);
- if entry.ends_with("/") {
+ assert_eq!(node.attr("href").unwrap().strip_prefix('/').unwrap(), entry);
+ if entry.ends_with('/') {
let node = parsed
.find(|x: &Node| x.name().unwrap_or_default() == "a" && x.text() == DIRECTORIES[0])
.next();
@@ -198,7 +198,7 @@ fn serves_requests_with_randomly_assigned_port(tmpdir: TempDir) -> Result<(), Er
let mut child = Command::cargo_bin("miniserve")?
.arg(tmpdir.path())
.arg("-p")
- .arg("0".to_string())
+ .arg("0")
.stdout(Stdio::piped())
.spawn()?;
diff --git a/tests/tls.rs b/tests/tls.rs
index 6aa9460..a1c819a 100644
--- a/tests/tls.rs
+++ b/tests/tls.rs
@@ -34,7 +34,7 @@ fn tls_works(#[case] server: TestServer) -> Result<(), Error> {
#[rstest]
fn wrong_path_cert() -> Result<(), Error> {
Command::cargo_bin("miniserve")?
- .args(&["--tls-cert", "wrong", "--tls-key", "tests/data/key.pem"])
+ .args(["--tls-cert", "wrong", "--tls-key", "tests/data/key.pem"])
.assert()
.failure()
.stderr(contains("Error: Couldn't access TLS certificate \"wrong\""));
@@ -46,7 +46,7 @@ fn wrong_path_cert() -> Result<(), Error> {
#[rstest]
fn wrong_path_key() -> Result<(), Error> {
Command::cargo_bin("miniserve")?
- .args(&["--tls-cert", "tests/data/cert.pem", "--tls-key", "wrong"])
+ .args(["--tls-cert", "tests/data/cert.pem", "--tls-key", "wrong"])
.assert()
.failure()
.stderr(contains("Error: Couldn't access TLS key \"wrong\""));
diff --git a/tests/upload_files.rs b/tests/upload_files.rs
index 196f3cd..e77e2fa 100644
--- a/tests/upload_files.rs
+++ b/tests/upload_files.rs
@@ -189,7 +189,7 @@ fn prevent_path_traversal_attacks(
create_dir_all(server.path().join("foo")).unwrap();
if !cfg!(windows) {
for dir in &["C:/foo/C:", r"C:\foo", r"\foo"] {
- create_dir_all(server.path().join(dir)).expect(&format!("failed to create: {:?}", dir));
+ create_dir_all(server.path().join(dir)).unwrap_or_else(|_| panic!("failed to create: {dir:?}"));
}
}
@@ -203,7 +203,7 @@ fn prevent_path_traversal_attacks(
let form = multipart::Form::new().part("file_to_upload", part);
Client::new()
- .post(server.url().join(&format!("/upload?path={}", path))?)
+ .post(server.url().join(&format!("/upload?path={path}"))?)
.multipart(form)
.send()?
.error_for_status()?;
@@ -243,7 +243,7 @@ fn upload_to_symlink_directory(
let form = multipart::Form::new().part("file_to_upload", part);
let status = Client::new()
- .post(server.url().join(&format!("/upload?path={}", dir))?)
+ .post(server.url().join(&format!("/upload?path={dir}"))?)
.multipart(form)
.send()?
.error_for_status();