login_endpoint-bug_fix #22
@@ -81,4 +81,30 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_wrong_password() {
|
||||
let some_password = String::from("somethingrandom");
|
||||
let salt = generate_salt().unwrap();
|
||||
match hash_password(&some_password, &salt) {
|
||||
Ok(p) => {
|
||||
match verify_password(&some_password, p.clone()) {
|
||||
Ok(res) => {
|
||||
assert_eq!(res, true, "Passwords are not verified");
|
||||
let wrong_password = String::from("Differentanotherlevel");
|
||||
// wrong_password = some_password;
|
||||
// let hashed_wrong_password = hash_password(&wrong_password, &salt).unwrap();
|
||||
let result = verify_password(&wrong_password, p.clone()).unwrap();
|
||||
assert_eq!(false, result, "Passwords should not match");
|
||||
}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {:?}", err.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {:?}", err.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user