Tests pass.

This commit is contained in:
Luca Palmieri 2021-08-29 22:32:52 +02:00
parent 7d515138d5
commit e106c5c69a
2 changed files with 8 additions and 4 deletions

View file

@ -31,7 +31,7 @@ thiserror = "1.0.24"
serde-aux = "1.0.1"
unicode-segmentation = "1.7.1"
validator = "0.12.0"
rand = { version = "0.8", features=["std_rng"] }
rand = { version = "0.8", features= ["std_rng"] }
tracing-actix-web = "0.4.0-beta.8"
anyhow = "1.0.40"
base64 = "0.13.0"

View file

@ -1,5 +1,6 @@
use argon2::password_hash::SaltString;
use argon2::{Argon2, PasswordHasher};
use once_cell::sync::Lazy;
use sha3::Digest;
use sqlx::{Connection, Executor, PgConnection, PgPool};
use uuid::Uuid;
use wiremock::MockServer;
@ -161,8 +162,11 @@ impl TestUser {
}
async fn store(&self, pool: &PgPool) {
let password_hash = sha3::Sha3_256::digest(self.password.as_bytes());
let password_hash = format!("{:x}", password_hash);
let salt = SaltString::generate(&mut rand::thread_rng());
let password_hash = Argon2::default()
.hash_password(self.password.as_bytes(), &salt)
.unwrap()
.to_string();
sqlx::query!(
"INSERT INTO users (user_id, username, password_hash)
VALUES ($1, $2, $3)",