From 8440d59dd69594d8f09e640a02f0494544385d61 Mon Sep 17 00:00:00 2001 From: boastful-squirrel Date: Fri, 26 Apr 2019 19:05:59 +0200 Subject: Cargo fmt --- src/args.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index 4077f35..b769a9b 100644 --- a/src/args.rs +++ b/src/args.rs @@ -80,9 +80,7 @@ fn parse_interface(src: &str) -> Result { /// Checks wether the auth string is valid, i.e. it follows the syntax username:password fn parse_auth(src: &str) -> Result { let mut split = src.splitn(3, ':'); - let invalid_auth_format = Err( - ContextualError::new(ContextualErrorKind::InvalidAuthFormat) - ); + let invalid_auth_format = Err(ContextualError::new(ContextualErrorKind::InvalidAuthFormat)); let username = match split.next() { Some(username) => username, @@ -100,7 +98,9 @@ fn parse_auth(src: &str) -> Result { let hash_bin = if let Ok(hash_bin) = hex::decode(hash_hex) { hash_bin } else { - return Err(ContextualError::new(ContextualErrorKind::InvalidPasswordHash)) + return Err(ContextualError::new( + ContextualErrorKind::InvalidPasswordHash, + )); }; match second_part { @@ -108,16 +108,18 @@ fn parse_auth(src: &str) -> Result { "sha512" => auth::RequiredAuthPassword::Sha512(hash_bin.to_owned()), _ => { return Err(ContextualError::new( - ContextualErrorKind::InvalidHashMethod(second_part.to_owned()) + ContextualErrorKind::InvalidHashMethod(second_part.to_owned()), )) - }, + } } } else { // To make it Windows-compatible, the password needs to be shorter than 255 characters. // After 255 characters, Windows will truncate the value. // As for the username, the spec does not mention a limit in length if second_part.len() > 255 { - return Err(ContextualError::new(ContextualErrorKind::PasswordTooLongError)); + return Err(ContextualError::new( + ContextualErrorKind::PasswordTooLongError, + )); } auth::RequiredAuthPassword::Plain(second_part.to_owned()) @@ -189,7 +191,10 @@ mod tests { } #[rstest_parametrize( - auth_string, username, password, encrypt, + auth_string, + username, + password, + encrypt, case("username:password", "username", "password", "plain"), case("username:sha256:abcd", "username", "abcd", "sha256"), case("username:sha512:abcd", "username", "abcd", "sha512") -- cgit v1.2.3 From c2ce5295eb27610734ed539d47979c7bc0f0953b Mon Sep 17 00:00:00 2001 From: boastful-squirrel Date: Sat, 27 Apr 2019 12:31:14 +0200 Subject: Fixed test + fixed clippy warning --- src/args.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index b769a9b..9ccb7a6 100644 --- a/src/args.rs +++ b/src/args.rs @@ -214,7 +214,7 @@ mod tests { ), case( "username:blahblah:abcd", - "blahblah is not a valid hashing method. Expected sha256 or sha512" + "Invalid hashing method blahblah. Expected sha256 or sha512" ), case( "username:sha256:invalid", -- cgit v1.2.3 From 2011cdc6f140122735d2ec0b67cf70776588067c Mon Sep 17 00:00:00 2001 From: boastful-squirrel Date: Thu, 2 May 2019 07:23:18 +0200 Subject: Added rustfmt_skip directive on tests --- src/args.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index d37e429..5671425 100644 --- a/src/args.rs +++ b/src/args.rs @@ -161,6 +161,7 @@ pub fn parse_args() -> crate::MiniserveConfig { } } +#[cfg_attr(rustfmt, rustfmt_skip)] #[cfg(test)] mod tests { use super::*; @@ -183,10 +184,7 @@ mod tests { } #[rstest_parametrize( - auth_string, - username, - password, - encrypt, + auth_string, username, password, encrypt, case("username:password", "username", "password", "plain"), case("username:sha256:abcd", "username", "abcd", "sha256"), case("username:sha512:abcd", "username", "abcd", "sha512") -- cgit v1.2.3 From a73a74283f64986ff6a0b6da4c234a828bc52522 Mon Sep 17 00:00:00 2001 From: boastful-squirrel Date: Fri, 3 May 2019 19:32:51 +0200 Subject: Return QueryParameters struct instead of tuple --- src/args.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index 5671425..6a9bf83 100644 --- a/src/args.rs +++ b/src/args.rs @@ -161,7 +161,7 @@ pub fn parse_args() -> crate::MiniserveConfig { } } -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] #[cfg(test)] mod tests { use super::*; -- cgit v1.2.3 From 5b43a629a8592c1a3f49a3e42d62713a96dee0c8 Mon Sep 17 00:00:00 2001 From: boastful-squirrel Date: Mon, 6 May 2019 18:54:14 +0200 Subject: Undo changes on InvalidHashMethod error --- src/args.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index bbf6ad1..ea0a4ac 100644 --- a/src/args.rs +++ b/src/args.rs @@ -205,7 +205,7 @@ mod tests { ), case( "username:blahblah:abcd", - "Invalid hashing method blahblah. Expected sha256 or sha512" + "blahblah is not a valid hashing method. Expected sha256 or sha512" ), case( "username:sha256:invalid", -- cgit v1.2.3 From 26ae6d973468eb80a71199d80c0db210e6883968 Mon Sep 17 00:00:00 2001 From: boastful-squirrel Date: Mon, 6 May 2019 18:56:32 +0200 Subject: Undo changes on args.rs --- src/args.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index ea0a4ac..d291bb9 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 @@ -99,13 +99,15 @@ fn parse_auth(src: &str) -> Result { 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. -- cgit v1.2.3