use easy_auth::core::password::services::password_service::PasswordService; use easy_auth::prelude::password::services::password_service_impl::PasswordServiceImpl; #[test] fn password_hashed_should_be_same_than_expected() { // given let salt = "salt_test"; let password_service = PasswordServiceImpl::new(salt.to_string()); let password = "mon_mot_de_passe"; let expected = "$2y$12$a0DqbD7yXVLyKB.uKB.uK.OacqAixOlKJF6yowQChMdIuJ9EHTc4K"; // when let result = password_service.create_hash_password(password.to_string()); // then assert_eq!(result, expected.to_string()) } #[test] fn password_should_be_verfied_when_compared_with_hashed_and_salt() { // given let salt = "salt_test"; let password_service = PasswordServiceImpl::new(salt.to_string()); let password = "mon_mot_de_passe"; let password_hashed_salt = "$2y$12$a0DqbD7yXVLyKB.uKB.uK.OacqAixOlKJF6yowQChMdIuJ9EHTc4K"; let expected = true; // when let result = password_service.verifie(password.to_string(), password_hashed_salt.to_string()); // then assert_eq!(result, expected) }