2022-06-25 03:15:16 +03:00
|
|
|
mod fixtures;
|
|
|
|
mod utils;
|
|
|
|
|
|
|
|
use fixtures::{server, Error, TestServer};
|
|
|
|
use rstest::rstest;
|
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
#[case(server(&[] as &[&str]), true)]
|
|
|
|
#[case(server(&["--hidden", ".git,index.html"]), false)]
|
|
|
|
fn hidden_get_dir(#[case] server: TestServer, #[case] exist: bool) -> Result<(), Error> {
|
|
|
|
let resp = reqwest::blocking::get(server.url())?;
|
|
|
|
assert_eq!(resp.status(), 200);
|
2022-08-03 03:51:12 +03:00
|
|
|
let paths = utils::retrieve_index_paths(&resp.text()?);
|
2022-12-11 10:18:44 +03:00
|
|
|
assert!(paths.contains("dir1/"));
|
2022-06-25 03:15:16 +03:00
|
|
|
assert_eq!(paths.contains(".git/"), exist);
|
|
|
|
assert_eq!(paths.contains("index.html"), exist);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-08-06 02:48:34 +03:00
|
|
|
#[rstest]
|
|
|
|
#[case(server(&[] as &[&str]), true)]
|
|
|
|
#[case(server(&["--hidden", "*.html"]), false)]
|
|
|
|
fn hidden_get_dir2(#[case] server: TestServer, #[case] exist: bool) -> Result<(), Error> {
|
|
|
|
let resp = reqwest::blocking::get(server.url())?;
|
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
let paths = utils::retrieve_index_paths(&resp.text()?);
|
2022-12-11 10:18:44 +03:00
|
|
|
assert!(paths.contains("dir1/"));
|
2022-08-06 02:48:34 +03:00
|
|
|
assert_eq!(paths.contains("index.html"), exist);
|
|
|
|
assert_eq!(paths.contains("test.html"), exist);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-06-25 03:15:16 +03:00
|
|
|
#[rstest]
|
|
|
|
#[case(server(&[] as &[&str]), true)]
|
|
|
|
#[case(server(&["--hidden", ".git,index.html"]), false)]
|
|
|
|
fn hidden_propfind_dir(#[case] server: TestServer, #[case] exist: bool) -> Result<(), Error> {
|
|
|
|
let resp = fetch!(b"PROPFIND", server.url()).send()?;
|
|
|
|
assert_eq!(resp.status(), 207);
|
|
|
|
let body = resp.text()?;
|
2022-12-11 10:18:44 +03:00
|
|
|
assert!(body.contains("<D:href>/dir1/</D:href>"));
|
2022-06-25 03:15:16 +03:00
|
|
|
assert_eq!(body.contains("<D:href>/.git/</D:href>"), exist);
|
|
|
|
assert_eq!(body.contains("<D:href>/index.html</D:href>"), exist);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
#[case(server(&["--allow-search"] as &[&str]), true)]
|
|
|
|
#[case(server(&["--allow-search", "--hidden", ".git,test.html"]), false)]
|
|
|
|
fn hidden_search_dir(#[case] server: TestServer, #[case] exist: bool) -> Result<(), Error> {
|
|
|
|
let resp = reqwest::blocking::get(format!("{}?q={}", server.url(), "test.html"))?;
|
|
|
|
assert_eq!(resp.status(), 200);
|
2022-08-03 03:51:12 +03:00
|
|
|
let paths = utils::retrieve_index_paths(&resp.text()?);
|
2022-06-25 03:15:16 +03:00
|
|
|
for p in paths {
|
|
|
|
assert_eq!(p.contains("test.html"), exist);
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
2023-02-19 17:03:59 +03:00
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
#[case(server(&["--hidden", "hidden/"]), "dir4/", 1)]
|
|
|
|
#[case(server(&["--hidden", "hidden"]), "dir4/", 0)]
|
|
|
|
fn hidden_dir_noly(
|
|
|
|
#[case] server: TestServer,
|
|
|
|
#[case] dir: &str,
|
|
|
|
#[case] count: usize,
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
let resp = reqwest::blocking::get(format!("{}{}", server.url(), dir))?;
|
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
let paths = utils::retrieve_index_paths(&resp.text()?);
|
|
|
|
assert_eq!(paths.len(), count);
|
|
|
|
Ok(())
|
|
|
|
}
|