- update: database client to implement a database trait so we can mock it out

- update unit tests
- add: database client mock
This commit is contained in:
2024-11-25 22:20:15 -05:00
parent 3ff22c9a5b
commit 3fc6c6252c
15 changed files with 181 additions and 103 deletions

View File

@@ -1,4 +1,4 @@
use crate::database_client::DatabaseClient;
use crate::database_client::{DatabaseClient, DatabaseClientTrait};
use argon2::{
password_hash::{
@@ -19,7 +19,7 @@ pub fn verify_password(password: &str, hash: &str) -> bool {
Argon2::default().verify_password(password.as_bytes(), &parsed_hash).is_ok()
}
pub async fn verify_user(mut db_client: DatabaseClient,
pub async fn verify_user<T: DatabaseClientTrait>(mut db_client: T,
username: &str, password: &str) -> Option<String> {
// Placeholder: Replace with a gRPC call to the Database Service
let user = db_client.get_user_by_username(username).await.ok()?;