refactor: propfind with auth no need to list all (#344)
This commit is contained in:
parent
81d2c49e3f
commit
de0614816a
2 changed files with 21 additions and 7 deletions
|
@ -374,12 +374,13 @@ impl Server {
|
||||||
method => match method.as_str() {
|
method => match method.as_str() {
|
||||||
"PROPFIND" => {
|
"PROPFIND" => {
|
||||||
if is_dir {
|
if is_dir {
|
||||||
let access_paths = if access_paths.perm().inherit() {
|
let access_paths =
|
||||||
// see https://github.com/sigoden/dufs/issues/229
|
if access_paths.perm().inherit() && authorization.is_none() {
|
||||||
AccessPaths::new(AccessPerm::ReadOnly)
|
// see https://github.com/sigoden/dufs/issues/229
|
||||||
} else {
|
AccessPaths::new(AccessPerm::ReadOnly)
|
||||||
access_paths
|
} else {
|
||||||
};
|
access_paths
|
||||||
|
};
|
||||||
self.handle_propfind_dir(path, headers, access_paths, &mut res)
|
self.handle_propfind_dir(path, headers, access_paths, &mut res)
|
||||||
.await?;
|
.await?;
|
||||||
} else if is_file {
|
} else if is_file {
|
||||||
|
|
|
@ -271,7 +271,7 @@ fn auth_partial_index(
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn no_auth_propfind_dir(
|
fn no_auth_propfind_dir(
|
||||||
#[with(&["--auth", "user:pass@/:rw", "--auth", "@/dir-assets", "-A"])] server: TestServer,
|
#[with(&["--auth", "admin:admin@/:rw", "--auth", "@/dir-assets", "-A"])] server: TestServer,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let resp = fetch!(b"PROPFIND", server.url()).send()?;
|
let resp = fetch!(b"PROPFIND", server.url()).send()?;
|
||||||
assert_eq!(resp.status(), 207);
|
assert_eq!(resp.status(), 207);
|
||||||
|
@ -281,6 +281,19 @@ fn no_auth_propfind_dir(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rstest]
|
||||||
|
fn auth_propfind_dir(
|
||||||
|
#[with(&["--auth", "admin:admin@/:rw", "--auth", "user:pass@/dir-assets", "-A"])]
|
||||||
|
server: TestServer,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let resp = fetch!(b"PROPFIND", server.url()).send_with_digest_auth("user", "pass")?;
|
||||||
|
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(())
|
||||||
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn auth_data(
|
fn auth_data(
|
||||||
#[with(&["-a", "user:pass@/:rw", "-a", "@/", "-A"])] server: TestServer,
|
#[with(&["-a", "user:pass@/:rw", "-a", "@/", "-A"])] server: TestServer,
|
||||||
|
|
Loading…
Reference in a new issue