mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 00:59:02 +03:00
fix: ui readonly if no write perm (#258)
This commit is contained in:
@@ -213,3 +213,22 @@ fn no_auth_propfind_dir(
|
||||
assert!(body.contains("<D:href>/dir1/</D:href>"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn auth_data(
|
||||
#[with(&["--auth", "user:pass@/:rw|@/", "-A", "--auth-method", "basic"])] server: TestServer,
|
||||
) -> Result<(), Error> {
|
||||
let resp = reqwest::blocking::get(server.url())?;
|
||||
let content = resp.text()?;
|
||||
let json = utils::retrive_json(&content).unwrap();
|
||||
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()?;
|
||||
let json = utils::retrive_json(&content).unwrap();
|
||||
assert_eq!(json["allow_delete"], serde_json::Value::Bool(true));
|
||||
assert_eq!(json["allow_upload"], serde_json::Value::Bool(true));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ pub fn encode_uri(v: &str) -> String {
|
||||
parts.join("/")
|
||||
}
|
||||
|
||||
fn retrive_json(content: &str) -> Option<Value> {
|
||||
#[allow(dead_code)]
|
||||
pub fn retrive_json(content: &str) -> Option<Value> {
|
||||
let lines: Vec<&str> = content.lines().collect();
|
||||
let line = lines.iter().find(|v| v.contains("DATA ="))?;
|
||||
let line_col = line.find("DATA =").unwrap() + 6;
|
||||
|
||||
Reference in New Issue
Block a user