chore: lints

This commit is contained in:
Aravinth Manivannan 2024-05-18 00:10:22 +05:30
parent 5d49ecee5c
commit 458afd3577
Signed by: realaravinth
GPG key ID: F8F50389936984FF
2 changed files with 17 additions and 8 deletions

View file

@ -13,9 +13,12 @@ pub struct LoginCommand {
} }
impl LoginCommand { impl LoginCommand {
pub fn new(_username: String, supplied_password: String, actual_password_hash: &str) -> IdentityCommandResult<Self> { pub fn new(
let success = _username: String,
argon2_creds::Config::verify(actual_password_hash, &supplied_password)?; supplied_password: String,
actual_password_hash: &str,
) -> IdentityCommandResult<Self> {
let success = argon2_creds::Config::verify(actual_password_hash, &supplied_password)?;
Ok(Self { success }) Ok(Self { success })
} }
} }
@ -30,10 +33,14 @@ mod tests {
let password = "adsfasdfasd"; let password = "adsfasdfasd";
let hashed_password = config.password(password).unwrap(); let hashed_password = config.password(password).unwrap();
assert!( assert!(
LoginCommand::new("realaravinth".into(), password.into(), &hashed_password,).unwrap().success LoginCommand::new("realaravinth".into(), password.into(), &hashed_password,)
.unwrap()
.success
); );
assert!( assert!(
!LoginCommand::new("realaravinth".into(), "password".into(), &hashed_password,).unwrap().success !LoginCommand::new("realaravinth".into(), "password".into(), &hashed_password,)
.unwrap()
.success
); );
} }
} }

View file

@ -32,7 +32,8 @@ mod tests {
{ {
let cmd = let cmd =
command::LoginCommand::new(username.into(), password.into(), &hashed_password).unwrap(); command::LoginCommand::new(username.into(), password.into(), &hashed_password)
.unwrap();
let res = s.login(cmd.clone()).await; let res = s.login(cmd.clone()).await;
assert_eq!(res.success(), cmd.success()); assert_eq!(res.success(), cmd.success());
} }
@ -40,7 +41,8 @@ mod tests {
{ {
// success=false: // success=false:
let cmd = let cmd =
command::LoginCommand::new(username.into(), "asdfasdf".into(), &hashed_password).unwrap(); command::LoginCommand::new(username.into(), "asdfasdf".into(), &hashed_password)
.unwrap();
let res = s.login(cmd.clone()).await; let res = s.login(cmd.clone()).await;
assert_eq!(res.success(), cmd.success()); assert_eq!(res.success(), cmd.success());
} }