mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 00:59:02 +03:00
feat: support downloading via token auth (#603)
This commit is contained in:
@@ -348,3 +348,19 @@ fn auth_shadow(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
fn token_auth(#[with(&["-a", "user:pass@/"])] server: TestServer) -> Result<(), Error> {
|
||||
let url = format!("{}index.html", server.url());
|
||||
let resp = fetch!(b"GET", &url).send()?;
|
||||
assert_eq!(resp.status(), 401);
|
||||
let url = format!("{}index.html?tokengen", server.url());
|
||||
let resp = fetch!(b"GET", &url)
|
||||
.basic_auth("user", Some("pass"))
|
||||
.send()?;
|
||||
let token = resp.text()?;
|
||||
let url = format!("{}index.html?token={token}", server.url());
|
||||
let resp = fetch!(b"GET", &url).send()?;
|
||||
assert_eq!(resp.status(), 200);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user