2024-04-08 01:56:51 +03:00
|
|
|
mod digest_auth_util;
|
2022-06-12 03:43:50 +03:00
|
|
|
mod fixtures;
|
|
|
|
mod utils;
|
|
|
|
|
2024-04-08 01:56:51 +03:00
|
|
|
use digest_auth_util::send_with_digest_auth;
|
2022-06-12 03:43:50 +03:00
|
|
|
use fixtures::{server, Error, TestServer};
|
2023-06-01 13:52:05 +03:00
|
|
|
use indexmap::IndexSet;
|
2022-06-12 03:43:50 +03:00
|
|
|
use rstest::rstest;
|
|
|
|
|
|
|
|
#[rstest]
|
2023-06-01 13:52:05 +03:00
|
|
|
fn no_auth(#[with(&["--auth", "user:pass@/:rw", "-A"])] server: TestServer) -> Result<(), Error> {
|
2022-06-12 03:43:50 +03:00
|
|
|
let resp = reqwest::blocking::get(server.url())?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
2023-12-07 10:04:14 +03:00
|
|
|
let values: Vec<&str> = resp
|
|
|
|
.headers()
|
|
|
|
.get_all("www-authenticate")
|
|
|
|
.iter()
|
|
|
|
.map(|v| v.to_str().unwrap())
|
|
|
|
.collect();
|
|
|
|
assert!(values[0].starts_with("Digest"));
|
|
|
|
assert!(values[1].starts_with("Basic"));
|
|
|
|
|
2022-06-12 03:43:50 +03:00
|
|
|
let url = format!("{}file1", server.url());
|
|
|
|
let resp = fetch!(b"PUT", &url).body(b"abc".to_vec()).send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rstest]
|
2023-11-26 15:47:57 +03:00
|
|
|
#[case(server(&["--auth", "user:pass@/:rw", "-A"]), "user", "pass")]
|
|
|
|
#[case(server(&["--auth", "user:pa:ss@1@/:rw", "-A"]), "user", "pa:ss@1")]
|
|
|
|
fn auth(#[case] server: TestServer, #[case] user: &str, #[case] pass: &str) -> Result<(), Error> {
|
2022-06-12 03:43:50 +03:00
|
|
|
let url = format!("{}file1", server.url());
|
|
|
|
let resp = fetch!(b"PUT", &url).body(b"abc".to_vec()).send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"PUT", &url).body(b"abc".to_vec()), user, pass)?;
|
2022-06-12 03:43:50 +03:00
|
|
|
assert_eq!(resp.status(), 201);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2024-01-19 05:25:11 +03:00
|
|
|
#[rstest]
|
|
|
|
fn invalid_auth(
|
|
|
|
#[with(&["-a", "user:pass@/:rw", "-a", "@/", "-A"])] server: TestServer,
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
let resp = fetch!(b"GET", server.url())
|
|
|
|
.basic_auth("user", Some("-"))
|
|
|
|
.send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
|
|
|
let resp = fetch!(b"GET", server.url())
|
|
|
|
.basic_auth("-", Some("pass"))
|
|
|
|
.send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
|
|
|
let resp = fetch!(b"GET", server.url())
|
|
|
|
.header("Authorization", "Basic Og==")
|
|
|
|
.send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-11-04 13:12:58 +03:00
|
|
|
#[rstest]
|
2024-09-06 16:22:28 +03:00
|
|
|
#[case(server(&["--auth", "user:$6$gQxZwKyWn/ZmWEA2$4uV7KKMnSUnET2BtWTj/9T5.Jq3h/MdkOlnIl5hdlTxDZ4MZKmJ.kl6C.NL9xnNPqC4lVHC1vuI0E5cLpTJX81@/:rw", "-A"]), "user", "pass")]
|
|
|
|
#[case(server(&["--auth", "user:$6$YV1J6OHZAAgbzCbS$V55ZEgvJ6JFdz1nLO4AD696PRHAJYhfQf.Gy2HafrCz5itnbgNTtTgfUSqZrt4BJ7FcpRfSt/QZzAan68pido0@/:rw", "-A"]), "user", "pa:ss@1")]
|
2023-11-04 13:12:58 +03:00
|
|
|
fn auth_hashed_password(
|
2024-09-06 16:22:28 +03:00
|
|
|
#[case] server: TestServer,
|
|
|
|
#[case] user: &str,
|
|
|
|
#[case] pass: &str,
|
2023-11-04 13:12:58 +03:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let url = format!("{}file1", server.url());
|
|
|
|
let resp = fetch!(b"PUT", &url).body(b"abc".to_vec()).send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
2024-09-06 16:22:28 +03:00
|
|
|
if let Err(err) = send_with_digest_auth(fetch!(b"PUT", &url).body(b"abc".to_vec()), user, pass)
|
2023-11-04 13:12:58 +03:00
|
|
|
{
|
|
|
|
assert_eq!(
|
2024-04-08 01:56:51 +03:00
|
|
|
err.to_string(),
|
|
|
|
r#"Missing "realm" in header: Basic realm="DUFS""#
|
2023-11-04 13:12:58 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
let resp = fetch!(b"PUT", &url)
|
|
|
|
.body(b"abc".to_vec())
|
2024-09-06 16:22:28 +03:00
|
|
|
.basic_auth(user, Some(pass))
|
2023-11-04 13:12:58 +03:00
|
|
|
.send()?;
|
|
|
|
assert_eq!(resp.status(), 201);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-06-02 13:38:59 +03:00
|
|
|
#[rstest]
|
|
|
|
fn auth_and_public(
|
2023-11-26 15:47:57 +03:00
|
|
|
#[with(&["-a", "user:pass@/:rw", "-a", "@/", "-A"])] server: TestServer,
|
2023-06-02 13:38:59 +03:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let url = format!("{}file1", server.url());
|
|
|
|
let resp = fetch!(b"PUT", &url).body(b"abc".to_vec()).send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"PUT", &url).body(b"abc".to_vec()), "user", "pass")?;
|
2023-06-02 13:38:59 +03:00
|
|
|
assert_eq!(resp.status(), 201);
|
|
|
|
let resp = fetch!(b"GET", &url).send()?;
|
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
assert_eq!(resp.text()?, "abc");
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-06-12 03:43:50 +03:00
|
|
|
#[rstest]
|
2023-06-01 13:52:05 +03:00
|
|
|
fn auth_skip(#[with(&["--auth", "@/"])] server: TestServer) -> Result<(), Error> {
|
2022-06-12 03:43:50 +03:00
|
|
|
let resp = reqwest::blocking::get(server.url())?;
|
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
Ok(())
|
|
|
|
}
|
2022-06-19 06:26:03 +03:00
|
|
|
|
2023-02-19 07:30:14 +03:00
|
|
|
#[rstest]
|
|
|
|
fn auth_skip_on_options_method(
|
2023-06-01 13:52:05 +03:00
|
|
|
#[with(&["--auth", "user:pass@/:rw"])] server: TestServer,
|
2023-02-19 07:30:14 +03:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let url = format!("{}index.html", server.url());
|
|
|
|
let resp = fetch!(b"OPTIONS", &url).send()?;
|
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2024-12-11 03:57:30 +03:00
|
|
|
#[rstest]
|
|
|
|
fn auth_skip_if_no_auth_user(server: TestServer) -> Result<(), Error> {
|
|
|
|
let url = format!("{}index.html", server.url());
|
|
|
|
let resp = fetch!(b"GET", &url)
|
|
|
|
.basic_auth("user", Some("pass"))
|
|
|
|
.send()?;
|
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-02-21 07:42:40 +03:00
|
|
|
#[rstest]
|
|
|
|
fn auth_check(
|
2023-11-26 15:47:57 +03:00
|
|
|
#[with(&["--auth", "user:pass@/:rw", "--auth", "user2:pass2@/", "-A"])] server: TestServer,
|
2023-02-21 07:42:40 +03:00
|
|
|
) -> Result<(), Error> {
|
2023-02-21 11:10:51 +03:00
|
|
|
let url = format!("{}index.html", server.url());
|
2024-08-27 11:07:17 +03:00
|
|
|
let resp = fetch!(b"CHECKAUTH", &url).send()?;
|
2023-02-21 07:42:40 +03:00
|
|
|
assert_eq!(resp.status(), 401);
|
2024-08-27 11:07:17 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"CHECKAUTH", &url), "user", "pass")?;
|
2024-08-22 03:52:50 +03:00
|
|
|
assert_eq!(resp.status(), 200);
|
2024-08-27 11:07:17 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"CHECKAUTH", &url), "user2", "pass2")?;
|
2023-02-21 07:42:40 +03:00
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-11-26 17:15:49 +03:00
|
|
|
#[rstest]
|
2024-08-27 11:07:17 +03:00
|
|
|
fn auth_check2(
|
2023-11-26 17:15:49 +03:00
|
|
|
#[with(&["--auth", "user:pass@/:rw|user2:pass2@/", "-A"])] server: TestServer,
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
let url = format!("{}index.html", server.url());
|
2024-08-27 11:07:17 +03:00
|
|
|
let resp = fetch!(b"CHECKAUTH", &url).send()?;
|
2023-11-26 17:15:49 +03:00
|
|
|
assert_eq!(resp.status(), 401);
|
2024-08-27 11:07:17 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"CHECKAUTH", &url), "user", "pass")?;
|
2024-08-22 03:52:50 +03:00
|
|
|
assert_eq!(resp.status(), 200);
|
2024-08-27 11:07:17 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"CHECKAUTH", &url), "user2", "pass2")?;
|
2023-11-26 17:15:49 +03:00
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2024-08-27 11:07:17 +03:00
|
|
|
#[rstest]
|
|
|
|
fn auth_logout(
|
|
|
|
#[with(&["--auth", "user:pass@/:rw", "-A"])] server: TestServer,
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
let url = format!("{}index.html", server.url());
|
|
|
|
let resp = fetch!(b"LOGOUT", &url).send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
|
|
|
let resp = send_with_digest_auth(fetch!(b"LOGOUT", &url), "user", "pass")?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-06-19 06:26:03 +03:00
|
|
|
#[rstest]
|
|
|
|
fn auth_readonly(
|
2023-11-26 15:47:57 +03:00
|
|
|
#[with(&["--auth", "user:pass@/:rw", "--auth", "user2:pass2@/", "-A"])] server: TestServer,
|
2022-06-19 06:26:03 +03:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let url = format!("{}index.html", server.url());
|
|
|
|
let resp = fetch!(b"GET", &url).send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"GET", &url), "user2", "pass2")?;
|
2022-06-19 06:26:03 +03:00
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
let url = format!("{}file1", server.url());
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"PUT", &url).body(b"abc".to_vec()), "user2", "pass2")?;
|
2023-06-01 13:52:05 +03:00
|
|
|
assert_eq!(resp.status(), 403);
|
2022-06-19 06:26:03 +03:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
fn auth_nest(
|
2023-11-26 15:47:57 +03:00
|
|
|
#[with(&["--auth", "user:pass@/:rw", "--auth", "user2:pass2@/", "--auth", "user3:pass3@/dir1:rw", "-A"])]
|
2022-06-19 06:26:03 +03:00
|
|
|
server: TestServer,
|
|
|
|
) -> Result<(), Error> {
|
2022-12-11 10:18:44 +03:00
|
|
|
let url = format!("{}dir1/file1", server.url());
|
2022-06-19 06:26:03 +03:00
|
|
|
let resp = fetch!(b"PUT", &url).body(b"abc".to_vec()).send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"PUT", &url).body(b"abc".to_vec()), "user3", "pass3")?;
|
2022-06-19 06:26:03 +03:00
|
|
|
assert_eq!(resp.status(), 201);
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"PUT", &url).body(b"abc".to_vec()), "user", "pass")?;
|
2022-06-19 06:26:03 +03:00
|
|
|
assert_eq!(resp.status(), 201);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
fn auth_nest_share(
|
2023-06-01 13:52:05 +03:00
|
|
|
#[with(&["--auth", "@/", "--auth", "user:pass@/:rw", "--auth", "user3:pass3@/dir1:rw", "-A"])]
|
|
|
|
server: TestServer,
|
2022-06-19 06:26:03 +03:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let url = format!("{}index.html", server.url());
|
|
|
|
let resp = fetch!(b"GET", &url).send()?;
|
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
Ok(())
|
|
|
|
}
|
2022-06-20 06:25:09 +03:00
|
|
|
|
|
|
|
#[rstest]
|
2023-11-03 15:36:23 +03:00
|
|
|
#[case(server(&["--auth", "user:pass@/:rw", "-A"]), "user", "pass")]
|
|
|
|
#[case(server(&["--auth", "u1:p1@/:rw", "-A"]), "u1", "p1")]
|
2022-06-20 06:25:09 +03:00
|
|
|
fn auth_basic(
|
2023-03-12 07:58:36 +03:00
|
|
|
#[case] server: TestServer,
|
|
|
|
#[case] user: &str,
|
|
|
|
#[case] pass: &str,
|
2022-06-20 06:25:09 +03:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let url = format!("{}file1", server.url());
|
|
|
|
let resp = fetch!(b"PUT", &url).body(b"abc".to_vec()).send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
|
|
|
let resp = fetch!(b"PUT", &url)
|
|
|
|
.body(b"abc".to_vec())
|
2023-03-12 07:58:36 +03:00
|
|
|
.basic_auth(user, Some(pass))
|
2022-06-20 06:25:09 +03:00
|
|
|
.send()?;
|
|
|
|
assert_eq!(resp.status(), 201);
|
|
|
|
Ok(())
|
|
|
|
}
|
2022-07-04 18:25:05 +03:00
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
fn auth_webdav_move(
|
2023-06-01 13:52:05 +03:00
|
|
|
#[with(&["--auth", "user:pass@/:rw", "--auth", "user3:pass3@/dir1:rw", "-A"])]
|
|
|
|
server: TestServer,
|
2022-07-04 18:25:05 +03:00
|
|
|
) -> Result<(), Error> {
|
2022-12-11 10:18:44 +03:00
|
|
|
let origin_url = format!("{}dir1/test.html", server.url());
|
2022-07-04 18:25:05 +03:00
|
|
|
let new_url = format!("{}test2.html", server.url());
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(
|
|
|
|
fetch!(b"MOVE", &origin_url).header("Destination", &new_url),
|
|
|
|
"user3",
|
|
|
|
"pass3",
|
|
|
|
)?;
|
2022-07-04 18:25:05 +03:00
|
|
|
assert_eq!(resp.status(), 403);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
fn auth_webdav_copy(
|
2023-06-01 13:52:05 +03:00
|
|
|
#[with(&["--auth", "user:pass@/:rw", "--auth", "user3:pass3@/dir1:rw", "-A"])]
|
|
|
|
server: TestServer,
|
2022-07-04 18:25:05 +03:00
|
|
|
) -> Result<(), Error> {
|
2022-12-11 10:18:44 +03:00
|
|
|
let origin_url = format!("{}dir1/test.html", server.url());
|
2022-07-04 18:25:05 +03:00
|
|
|
let new_url = format!("{}test2.html", server.url());
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(
|
|
|
|
fetch!(b"COPY", &origin_url).header("Destination", &new_url),
|
|
|
|
"user3",
|
|
|
|
"pass3",
|
|
|
|
)?;
|
2022-07-04 18:25:05 +03:00
|
|
|
assert_eq!(resp.status(), 403);
|
|
|
|
Ok(())
|
|
|
|
}
|
2022-10-08 04:14:42 +03:00
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
fn auth_path_prefix(
|
2023-06-01 13:52:05 +03:00
|
|
|
#[with(&["--auth", "user:pass@/:rw", "--path-prefix", "xyz", "-A"])] server: TestServer,
|
2022-10-08 04:14:42 +03:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let url = format!("{}xyz/index.html", server.url());
|
|
|
|
let resp = fetch!(b"GET", &url).send()?;
|
|
|
|
assert_eq!(resp.status(), 401);
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"GET", &url), "user", "pass")?;
|
2022-10-08 04:14:42 +03:00
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
Ok(())
|
|
|
|
}
|
2023-06-01 13:52:05 +03:00
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
fn auth_partial_index(
|
|
|
|
#[with(&["--auth", "user:pass@/dir1:rw,/dir2:rw", "-A"])] server: TestServer,
|
|
|
|
) -> Result<(), Error> {
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"GET", server.url()), "user", "pass")?;
|
2023-06-01 13:52:05 +03:00
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
let paths = utils::retrieve_index_paths(&resp.text()?);
|
|
|
|
assert_eq!(paths, IndexSet::from(["dir1/".into(), "dir2/".into()]));
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(
|
|
|
|
fetch!(b"GET", format!("{}?q={}", server.url(), "test.html")),
|
|
|
|
"user",
|
|
|
|
"pass",
|
|
|
|
)?;
|
2023-06-01 13:52:05 +03:00
|
|
|
assert_eq!(resp.status(), 200);
|
|
|
|
let paths = utils::retrieve_index_paths(&resp.text()?);
|
|
|
|
assert_eq!(
|
|
|
|
paths,
|
|
|
|
IndexSet::from(["dir1/test.html".into(), "dir2/test.html".into()])
|
|
|
|
);
|
|
|
|
Ok(())
|
|
|
|
}
|
2023-06-05 06:40:31 +03:00
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
fn no_auth_propfind_dir(
|
2024-01-11 11:10:10 +03:00
|
|
|
#[with(&["--auth", "admin:admin@/:rw", "--auth", "@/dir-assets", "-A"])] server: TestServer,
|
2023-06-05 06:40:31 +03:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let resp = fetch!(b"PROPFIND", server.url()).send()?;
|
|
|
|
assert_eq!(resp.status(), 207);
|
|
|
|
let body = resp.text()?;
|
|
|
|
assert!(body.contains("<D:href>/dir-assets/</D:href>"));
|
|
|
|
assert!(body.contains("<D:href>/dir1/</D:href>"));
|
|
|
|
Ok(())
|
|
|
|
}
|
2023-08-24 13:32:34 +03:00
|
|
|
|
2024-01-11 11:10:10 +03:00
|
|
|
#[rstest]
|
|
|
|
fn auth_propfind_dir(
|
|
|
|
#[with(&["--auth", "admin:admin@/:rw", "--auth", "user:pass@/dir-assets", "-A"])]
|
|
|
|
server: TestServer,
|
|
|
|
) -> Result<(), Error> {
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"PROPFIND", server.url()), "user", "pass")?;
|
2024-01-11 11:10:10 +03:00
|
|
|
assert_eq!(resp.status(), 207);
|
|
|
|
let body = resp.text()?;
|
|
|
|
assert!(body.contains("<D:href>/dir-assets/</D:href>"));
|
|
|
|
assert!(!body.contains("<D:href>/dir1/</D:href>"));
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-08-24 13:32:34 +03:00
|
|
|
#[rstest]
|
|
|
|
fn auth_data(
|
2023-11-26 15:47:57 +03:00
|
|
|
#[with(&["-a", "user:pass@/:rw", "-a", "@/", "-A"])] server: TestServer,
|
2023-08-24 13:32:34 +03:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let resp = reqwest::blocking::get(server.url())?;
|
|
|
|
let content = resp.text()?;
|
2024-05-05 01:23:18 +03:00
|
|
|
let json = utils::retrieve_json(&content).unwrap();
|
2023-08-24 13:32:34 +03:00
|
|
|
assert_eq!(json["allow_delete"], serde_json::Value::Bool(false));
|
|
|
|
assert_eq!(json["allow_upload"], serde_json::Value::Bool(false));
|
|
|
|
let resp = fetch!(b"GET", server.url())
|
|
|
|
.basic_auth("user", Some("pass"))
|
|
|
|
.send()?;
|
|
|
|
let content = resp.text()?;
|
2024-05-05 01:23:18 +03:00
|
|
|
let json = utils::retrieve_json(&content).unwrap();
|
2023-08-24 13:32:34 +03:00
|
|
|
assert_eq!(json["allow_delete"], serde_json::Value::Bool(true));
|
|
|
|
assert_eq!(json["allow_upload"], serde_json::Value::Bool(true));
|
|
|
|
Ok(())
|
|
|
|
}
|
2023-12-21 12:28:13 +03:00
|
|
|
|
|
|
|
#[rstest]
|
|
|
|
fn auth_precedence(
|
|
|
|
#[with(&["--auth", "user:pass@/dir1:rw,/dir1/test.txt", "-A"])] server: TestServer,
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
let url = format!("{}dir1/test.txt", server.url());
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"PUT", &url).body(b"abc".to_vec()), "user", "pass")?;
|
2023-12-21 12:28:13 +03:00
|
|
|
assert_eq!(resp.status(), 403);
|
|
|
|
|
|
|
|
let url = format!("{}dir1/file1", server.url());
|
2024-04-08 01:56:51 +03:00
|
|
|
let resp = send_with_digest_auth(fetch!(b"PUT", &url).body(b"abc".to_vec()), "user", "pass")?;
|
2023-12-21 12:28:13 +03:00
|
|
|
assert_eq!(resp.status(), 201);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|