package service_test import ( "testing" "github.com/user-management-system/internal/service" ) // ============================================================================= // Auth Password Tests // ============================================================================= func TestGetPasswordStrength(t *testing.T) { t.Run("Get password strength - strong", func(t *testing.T) { info := service.GetPasswordStrength("StrongP@ss123") if info.Score < 4 { t.Errorf("Expected strength score >= 4, got %d", info.Score) } }) t.Run("Get password strength - weak", func(t *testing.T) { info := service.GetPasswordStrength("123") if info.Score > 2 { t.Errorf("Expected low strength score for weak password, got %d", info.Score) } }) t.Run("Get password strength - empty", func(t *testing.T) { info := service.GetPasswordStrength("") if info.Length != 0 { t.Errorf("Expected length 0 for empty password, got %d", info.Length) } }) t.Run("Get password strength with all character types", func(t *testing.T) { info := service.GetPasswordStrength("Abcd1234!@#") if !info.HasUpper { t.Error("Expected HasUpper to be true") } if !info.HasLower { t.Error("Expected HasLower to be true") } if !info.HasDigit { t.Error("Expected HasDigit to be true") } if !info.HasSpecial { t.Error("Expected HasSpecial to be true") } }) t.Run("Get password strength with only lowercase", func(t *testing.T) { info := service.GetPasswordStrength("abcdefghij") if !info.HasLower { t.Error("Expected HasLower to be true") } if info.HasUpper { t.Error("Expected HasUpper to be false") } if info.HasDigit { t.Error("Expected HasDigit to be false") } if info.HasSpecial { t.Error("Expected HasSpecial to be false") } }) t.Run("Get password strength with only digits", func(t *testing.T) { info := service.GetPasswordStrength("1234567890") if info.HasLower { t.Error("Expected HasLower to be false") } if info.HasUpper { t.Error("Expected HasUpper to be false") } if !info.HasDigit { t.Error("Expected HasDigit to be true") } if info.HasSpecial { t.Error("Expected HasSpecial to be false") } }) }