Documentation: - Add detailed README files for all services (auth, character, database, launcher, packet, utils, world) - Create API documentation for the database service with detailed endpoint specifications - Document database schema and relationships - Add service architecture overviews and configuration instructions Unit Tests: - Implement comprehensive test suite for database repositories (user, character, session) - Add gRPC service tests for database interactions - Create tests for packet service components (bufferpool, connection, packets) - Add utility service tests (health check, logging, load balancer, redis cache, service discovery) - Implement auth service user tests - Add character service tests Code Structure: - Reorganize test files into a more consistent structure - Create a dedicated tests crate for integration testing - Add test helpers and mock implementations for easier testing
71 lines
2.0 KiB
Rust
71 lines
2.0 KiB
Rust
use auth_service::users::{hash_password, verify_password};
|
||
|
||
#[test]
|
||
fn test_password_hashing_and_verification() {
|
||
// Test with a simple password
|
||
let password = "test_password";
|
||
let hashed = hash_password(password);
|
||
|
||
// Verify the hash is not the same as the original password
|
||
assert_ne!(password, hashed);
|
||
|
||
// Verify the password against the hash
|
||
assert!(verify_password(password, &hashed));
|
||
|
||
// Verify an incorrect password fails
|
||
assert!(!verify_password("wrong_password", &hashed));
|
||
}
|
||
|
||
#[test]
|
||
fn test_password_hashing_with_special_characters() {
|
||
// Test with special characters
|
||
let password = "P@$$w0rd!#%^&*()";
|
||
let hashed = hash_password(password);
|
||
|
||
// Verify the hash is not the same as the original password
|
||
assert_ne!(password, hashed);
|
||
|
||
// Verify the password against the hash
|
||
assert!(verify_password(password, &hashed));
|
||
}
|
||
|
||
#[test]
|
||
fn test_password_hashing_with_unicode() {
|
||
// Test with Unicode characters
|
||
let password = "пароль123你好世界";
|
||
let hashed = hash_password(password);
|
||
|
||
// Verify the hash is not the same as the original password
|
||
assert_ne!(password, hashed);
|
||
|
||
// Verify the password against the hash
|
||
assert!(verify_password(password, &hashed));
|
||
}
|
||
|
||
#[test]
|
||
fn test_different_passwords_produce_different_hashes() {
|
||
let password1 = "password1";
|
||
let password2 = "password2";
|
||
|
||
let hash1 = hash_password(password1);
|
||
let hash2 = hash_password(password2);
|
||
|
||
// Different passwords should produce different hashes
|
||
assert_ne!(hash1, hash2);
|
||
}
|
||
|
||
#[test]
|
||
fn test_same_password_produces_different_hashes() {
|
||
let password = "same_password";
|
||
|
||
let hash1 = hash_password(password);
|
||
let hash2 = hash_password(password);
|
||
|
||
// Same password should produce different hashes due to salt
|
||
assert_ne!(hash1, hash2);
|
||
|
||
// But both hashes should verify against the original password
|
||
assert!(verify_password(password, &hash1));
|
||
assert!(verify_password(password, &hash2));
|
||
}
|