From a4144c9fb39c7a3cc1c15a8caec68b32de938ce7 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Thu, 6 Feb 2025 04:12:21 +0100 Subject: Make symlinks into global fixtures So far, tests had to create their own symlinks which made them less concise. Also, now that we always have symlinks in all tests, side effects of having them won't go undetected. --- tests/create_directories.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'tests/create_directories.rs') diff --git a/tests/create_directories.rs b/tests/create_directories.rs index c15b40f..bd9259f 100644 --- a/tests/create_directories.rs +++ b/tests/create_directories.rs @@ -1,8 +1,3 @@ -#[cfg(unix)] -use std::os::unix::fs::symlink as symlink_dir; -#[cfg(windows)] -use std::os::windows::fs::symlink_dir; - use reqwest::blocking::{multipart, Client}; use rstest::rstest; use select::{ @@ -12,7 +7,7 @@ use select::{ mod fixtures; -use crate::fixtures::{server, Error, TestServer, DIRECTORIES}; +use crate::fixtures::{server, Error, TestServer, DIRECTORY_SYMLINK}; /// This should work because the flags for uploading files and creating directories /// are set, and the directory name and path are valid. @@ -100,20 +95,14 @@ fn creating_directories_is_prevented(server: TestServer) -> Result<(), Error> { fn creating_directories_through_symlinks_is_prevented( #[with(&["--upload-files", "--mkdir", "--no-symlinks"])] server: TestServer, ) -> Result<(), Error> { - // Make symlinks - let symlink_directory_str = "symlink"; - let symlink_directory = server.path().join(symlink_directory_str); - let symlinked_direcotry = server.path().join(DIRECTORIES[0]); - symlink_dir(symlinked_direcotry, symlink_directory).unwrap(); - // Before attempting to create, ensure the symlink does not exist. let body = reqwest::blocking::get(server.url())?.error_for_status()?; let parsed = Document::from_read(body)?; - assert!(parsed.find(Text).all(|x| x.text() != symlink_directory_str)); + assert!(parsed.find(Text).all(|x| x.text() != DIRECTORY_SYMLINK)); // Attempt to perform directory creation. let form = multipart::Form::new(); - let part = multipart::Part::text(symlink_directory_str); + let part = multipart::Part::text(DIRECTORY_SYMLINK); let form = form.part("mkdir", part); // This should fail @@ -121,7 +110,7 @@ fn creating_directories_through_symlinks_is_prevented( .post( server .url() - .join(format!("/upload?path=/{symlink_directory_str}").as_str())? + .join(format!("/upload?path=/{DIRECTORY_SYMLINK}").as_str())? ) .multipart(form) .send()? -- cgit v1.2.3