diff options
author | khai96_ <hvksmr1996@gmail.com> | 2019-04-26 10:08:23 +0000 |
---|---|---|
committer | khai96_ <hvksmr1996@gmail.com> | 2019-04-26 10:08:23 +0000 |
commit | aac70e6607d3e8172f15df91bc16dc3244473ea9 (patch) | |
tree | ebed28e4e6913f617bfc27dc8d0656955e55689d /src/args.rs | |
parent | Merge remote-tracking branch 'mainrepo/master' into pullrequest.hashed-password (diff) | |
download | miniserve-aac70e6607d3e8172f15df91bc16dc3244473ea9.tar.gz miniserve-aac70e6607d3e8172f15df91bc16dc3244473ea9.zip |
Comply to change requests
- Added doc comments
- Added an additional test case
Diffstat (limited to '')
-rw-r--r-- | src/args.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/args.rs b/src/args.rs index 8f15ea4..97b391f 100644 --- a/src/args.rs +++ b/src/args.rs @@ -38,7 +38,8 @@ struct CLIArgs { )] interfaces: Vec<IpAddr>, - /// Set authentication (username:password, username:sha256:hash, or username:sha512:hash) + /// Set authentication. Currently supported formats: + /// username:password, username:sha256:hash, username:sha512:hash #[structopt(short = "a", long = "auth", parse(try_from_str = "parse_auth"))] auth: Option<auth::RequiredAuth>, @@ -88,6 +89,7 @@ fn parse_auth(src: &str) -> Result<auth::RequiredAuth, ContextualError> { None => return invalid_auth_format, }; + // second_part is either password in username:password or method in username:method:hash let second_part = match split.next() { // This allows empty passwords, as the spec does not forbid it Some(password) => password, @@ -169,6 +171,7 @@ mod tests { use super::*; use rstest::rstest_parametrize; + /// Helper function that creates a `RequiredAuth` structure fn create_required_auth(username: &str, password: &str, encrypt: &str) -> auth::RequiredAuth { use auth::*; use RequiredAuthPassword::*; @@ -211,6 +214,10 @@ mod tests { "username:sha256:invalid", "Invalid format for password hash. Expected hex code" ), + case( + "username:sha512:invalid", + "Invalid format for password hash. Expected hex code" + ), )] fn parse_auth_invalid(auth_string: &str, err_msg: &str) { let err = parse_auth(auth_string).unwrap_err(); |