diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2025-02-06 04:18:20 +0000 |
---|---|---|
committer | Sven-Hendrik Haase <svenstaro@gmail.com> | 2025-02-06 04:18:20 +0000 |
commit | 57f02a1587555176f1b43b001e7846ac9eb2e949 (patch) | |
tree | 6585f2d404ae55506f4e25985ce663cea7092788 /tests/auth_file.rs | |
parent | Get rid of server_no_stderr (diff) | |
download | miniserve-57f02a1587555176f1b43b001e7846ac9eb2e949.tar.gz miniserve-57f02a1587555176f1b43b001e7846ac9eb2e949.zip |
Clean up and modernize rstest usage
We still had some old-style syntax in there.
Diffstat (limited to '')
-rw-r--r-- | tests/auth_file.rs | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/tests/auth_file.rs b/tests/auth_file.rs index eb40d2c..5632d46 100644 --- a/tests/auth_file.rs +++ b/tests/auth_file.rs @@ -4,22 +4,17 @@ use select::{document::Document, predicate::Text}; mod fixtures; -use crate::fixtures::{server, Error, FILES}; +use crate::fixtures::{server, Error, TestServer, FILES}; -#[rstest( - cli_auth_file_arg, - client_username, - client_password, - case("tests/data/auth1.txt", "joe", "123"), - case("tests/data/auth1.txt", "bob", "123"), - case("tests/data/auth1.txt", "bill", "") -)] +#[rstest] +#[case("joe", "123")] +#[case("bob", "123")] +#[case("bill", "")] fn auth_file_accepts( - cli_auth_file_arg: &str, - client_username: &str, - client_password: &str, + #[with(&["--auth-file", "tests/data/auth1.txt"])] server: TestServer, + #[case] client_username: &str, + #[case] client_password: &str, ) -> Result<(), Error> { - let server = server(&["--auth-file", cli_auth_file_arg]); let client = Client::new(); let response = client .get(server.url()) @@ -38,20 +33,15 @@ fn auth_file_accepts( Ok(()) } -#[rstest( - cli_auth_file_arg, - client_username, - client_password, - case("tests/data/auth1.txt", "joe", "wrongpassword"), - case("tests/data/auth1.txt", "bob", ""), - case("tests/data/auth1.txt", "nonexistentuser", "wrongpassword") -)] +#[rstest] +#[case("joe", "wrongpassword")] +#[case("bob", "")] +#[case("nonexistentuser", "wrongpassword")] fn auth_file_rejects( - cli_auth_file_arg: &str, - client_username: &str, - client_password: &str, + #[with(&["--auth-file", "tests/data/auth1.txt"])] server: TestServer, + #[case] client_username: &str, + #[case] client_password: &str, ) -> Result<(), Error> { - let server = server(&["--auth-file", cli_auth_file_arg]); let client = Client::new(); let status = client .get(server.url()) |