Browse Source

test basic auth

pull/60/head
Joe Koop 3 years ago
parent
commit
1785779720
No known key found for this signature in database
GPG Key ID: B2D0C6242D5AC1FF
  1. 2
      src/args.rs
  2. 15
      tests/auth.rs

2
src/args.rs

@ -175,7 +175,7 @@ impl Args { @@ -175,7 +175,7 @@ impl Args {
let auth_method = match matches.value_of("auth-method").unwrap() {
"basic" => AuthMethod::Basic,
"digest" => AuthMethod::Digest,
_ => todo!(),
_ => AuthMethod::Digest,
};
let auth = AccessControl::new(&auth, &uri_prefix)?;
let allow_upload = matches.is_present("allow-all") || matches.is_present("allow-upload");

15
tests/auth.rs

@ -80,3 +80,18 @@ fn auth_nest_share( @@ -80,3 +80,18 @@ fn auth_nest_share(
assert_eq!(resp.status(), 200);
Ok(())
}
#[rstest]
fn auth_basic(
#[with(&["--auth", "/@user:pass", "--auth-method", "basic", "-A"])] server: TestServer,
) -> 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())
.basic_auth("user", Some("pass"))
.send()?;
assert_eq!(resp.status(), 201);
Ok(())
}

Loading…
Cancel
Save