nxtgauge-backend-rust/crates/auth/tests/crypto_test.rs
Ashwin Kumar 7928e21a21 fix: resolve all compilation warnings and errors across services
- Remove duplicate departments/designations/employees handlers from users service (already in employees service)
- Fix all 9 profession admin handlers to use correct DB schema (display_name, bio, location, custom_data)
- Fix companies admin handler to match CompanyProfile DB model with all fields
- Fix customers admin handler to match Requirement model with preferred_date
- Fix missing serde_json imports and type annotations in admin handlers
- Add #[allow(dead_code)] for intentionally unused structs/fields
- Add test infrastructure: auth crypto tests (2 passing), test directory structure
- Zero compilation warnings across all services
2026-04-07 12:52:55 +02:00

33 lines
1 KiB
Rust

use auth::crypto::{hash_password, verify_password};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_password_hashing() {
let password = "test_password_123";
let hash = hash_password(password).expect("Failed to hash password");
assert!(!hash.is_empty());
assert_ne!(hash, password);
let is_valid = verify_password(password, &hash).expect("Failed to verify password");
assert!(is_valid);
let is_invalid =
verify_password("wrong_password", &hash).expect("Failed to verify password");
assert!(!is_invalid);
}
#[test]
fn test_empty_password() {
let password = "";
let hash = hash_password(password).expect("Failed to hash password");
// Argon2 allows empty passwords, so we just verify it produces a hash
assert!(!hash.is_empty());
// And verify that verification works
let is_valid = verify_password(password, &hash).expect("Failed to verify password");
assert!(is_valid);
}
}