aboutsummaryrefslogtreecommitdiffstats
path: root/tests/create_directories.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2025-02-06 03:12:21 +0000
committerSven-Hendrik Haase <svenstaro@gmail.com>2025-02-06 03:12:21 +0000
commita4144c9fb39c7a3cc1c15a8caec68b32de938ce7 (patch)
treea5631e5679d0210c565d302dda11f6f388fa616d /tests/create_directories.rs
parentAdd CHANGELOG entry for #1415 (diff)
downloadminiserve-a4144c9fb39c7a3cc1c15a8caec68b32de938ce7.tar.gz
miniserve-a4144c9fb39c7a3cc1c15a8caec68b32de938ce7.zip
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.
Diffstat (limited to '')
-rw-r--r--tests/create_directories.rs19
1 files changed, 4 insertions, 15 deletions
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()?