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 {
pub fn new(_username: String, supplied_password: String, actual_password_hash: &str) -> IdentityCommandResult<Self> {
let success =
argon2_creds::Config::verify(actual_password_hash, &supplied_password)?;
pub fn new(
_username: String,
supplied_password: String,
actual_password_hash: &str,
) -> IdentityCommandResult<Self> {
let success = argon2_creds::Config::verify(actual_password_hash, &supplied_password)?;
Ok(Self { success })
}
}
@ -30,10 +33,14 @@ mod tests {
let password = "adsfasdfasd";
let hashed_password = config.password(password).unwrap();
assert!(
LoginCommand::new("realaravinth".into(), password.into(), &hashed_password,).unwrap().success
LoginCommand::new("realaravinth".into(), password.into(), &hashed_password,)
.unwrap()
.success
);
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 =
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;
assert_eq!(res.success(), cmd.success());
}
@ -40,7 +41,8 @@ mod tests {
{
// success=false:
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;
assert_eq!(res.success(), cmd.success());
}