mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 00:59:02 +03:00
refactor: digest_auth related tests (#372)
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
mod digest_auth_util;
|
||||
mod fixtures;
|
||||
mod utils;
|
||||
|
||||
use assert_cmd::prelude::*;
|
||||
use assert_fs::TempDir;
|
||||
use diqwest::blocking::WithDigestAuth;
|
||||
use digest_auth_util::send_with_digest_auth;
|
||||
use fixtures::{port, tmpdir, wait_for_port, Error};
|
||||
use rstest::rstest;
|
||||
use std::path::PathBuf;
|
||||
@@ -27,20 +28,18 @@ fn use_config_file(tmpdir: TempDir, port: u16) -> Result<(), Error> {
|
||||
assert_eq!(resp.status(), 401);
|
||||
|
||||
let url = format!("http://localhost:{port}/dufs/index.html");
|
||||
let resp = fetch!(b"GET", &url).send_with_digest_auth("user", "pass")?;
|
||||
let resp = send_with_digest_auth(fetch!(b"GET", &url), "user", "pass")?;
|
||||
assert_eq!(resp.text()?, "This is index.html");
|
||||
|
||||
let url = format!("http://localhost:{port}/dufs?simple");
|
||||
let resp = fetch!(b"GET", &url).send_with_digest_auth("user", "pass")?;
|
||||
let resp = send_with_digest_auth(fetch!(b"GET", &url), "user", "pass")?;
|
||||
let text: String = resp.text().unwrap();
|
||||
assert!(text.split('\n').any(|c| c == "dir1/"));
|
||||
assert!(!text.split('\n').any(|c| c == "dir3/"));
|
||||
assert!(!text.split('\n').any(|c| c == "test.txt"));
|
||||
|
||||
let url = format!("http://localhost:{port}/dufs/dir1/upload.txt");
|
||||
let resp = fetch!(b"PUT", &url)
|
||||
.body("Hello")
|
||||
.send_with_digest_auth("user", "pass")?;
|
||||
let resp = send_with_digest_auth(fetch!(b"PUT", &url).body("Hello"), "user", "pass")?;
|
||||
assert_eq!(resp.status(), 201);
|
||||
|
||||
child.kill()?;
|
||||
|
||||
Reference in New Issue
Block a user