diff options
author | khai96_ <hvksmr1996@gmail.com> | 2019-05-17 07:11:38 +0000 |
---|---|---|
committer | khai96_ <hvksmr1996@gmail.com> | 2019-05-17 07:11:38 +0000 |
commit | a77c71dde6a480c8c6a096b7cacd03de63a5ee6b (patch) | |
tree | 41709cb3662e07031cf318cb64404ea2d645bf92 /src/args.rs | |
parent | Update unit tests (diff) | |
parent | Merge pull request #116 from svenstaro/dependabot/cargo/reqwest-0.9.17 (diff) | |
download | miniserve-a77c71dde6a480c8c6a096b7cacd03de63a5ee6b.tar.gz miniserve-a77c71dde6a480c8c6a096b7cacd03de63a5ee6b.zip |
Merge remote-tracking branch 'mainrepo/master' into multiple-auths-alt
Diffstat (limited to 'src/args.rs')
-rw-r--r-- | src/args.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/args.rs b/src/args.rs index 39efe7e..11357c2 100644 --- a/src/args.rs +++ b/src/args.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use structopt::StructOpt; use crate::auth; -use crate::errors::{ContextualError}; +use crate::errors::ContextualError; use crate::themes; /// Possible characters for random routes @@ -40,6 +40,7 @@ struct CLIArgs { /// Set authentication. Currently supported formats: /// username:password, username:sha256:hash, username:sha512:hash + /// (e.g. joe:123, joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3) #[structopt(short = "a", long = "auth", parse(try_from_str = "parse_auth"))] auth: Vec<auth::RequiredAuth>, @@ -98,15 +99,13 @@ fn parse_auth(src: &str) -> Result<auth::RequiredAuth, ContextualError> { let hash_bin = if let Ok(hash_bin) = hex::decode(hash_hex) { hash_bin } else { - return Err(ContextualError::InvalidPasswordHash) + return Err(ContextualError::InvalidPasswordHash); }; match second_part { "sha256" => auth::RequiredAuthPassword::Sha256(hash_bin.to_owned()), "sha512" => auth::RequiredAuthPassword::Sha512(hash_bin.to_owned()), - _ => { - return Err(ContextualError::InvalidHashMethod(second_part.to_owned())) - }, + _ => return Err(ContextualError::InvalidHashMethod(second_part.to_owned())), } } else { // To make it Windows-compatible, the password needs to be shorter than 255 characters. @@ -163,6 +162,7 @@ pub fn parse_args() -> crate::MiniserveConfig { } } +#[rustfmt::skip] #[cfg(test)] mod tests { use super::*; |