- webhook_service_test.go: isPrivateIP, isSafeURL, computeHMAC - request_metadata_test.go: context functions - classified_error_test.go: error types - config_defaults_test.go: password reset/SMS defaults - email_config_test.go: email code defaults - auth_runtime_test.go: isUserNotFoundError Service coverage: 11.2% -> 14.7%
64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// =============================================================================
|
|
// Password Reset Configuration Tests
|
|
// =============================================================================
|
|
|
|
func TestDefaultPasswordResetConfig(t *testing.T) {
|
|
cfg := DefaultPasswordResetConfig()
|
|
|
|
if cfg.TokenTTL != 15*time.Minute {
|
|
t.Errorf("TokenTTL = %v, want %v", cfg.TokenTTL, 15*time.Minute)
|
|
}
|
|
if cfg.SMTPHost != "" {
|
|
t.Errorf("SMTPHost = %q, want empty", cfg.SMTPHost)
|
|
}
|
|
if cfg.SMTPPort != 587 {
|
|
t.Errorf("SMTPPort = %d, want 587", cfg.SMTPPort)
|
|
}
|
|
if cfg.SMTPUser != "" {
|
|
t.Errorf("SMTPUser = %q, want empty", cfg.SMTPUser)
|
|
}
|
|
if cfg.SMTPPass != "" {
|
|
t.Errorf("SMTPPass = %q, want empty", cfg.SMTPPass)
|
|
}
|
|
if cfg.FromEmail != "noreply@example.com" {
|
|
t.Errorf("FromEmail = %q, want %q", cfg.FromEmail, "noreply@example.com")
|
|
}
|
|
if cfg.SiteURL != "http://localhost:8080" {
|
|
t.Errorf("SiteURL = %q, want %q", cfg.SiteURL, "http://localhost:8080")
|
|
}
|
|
if cfg.PasswordMinLen != 8 {
|
|
t.Errorf("PasswordMinLen = %d, want 8", cfg.PasswordMinLen)
|
|
}
|
|
if cfg.PasswordRequireSpecial != false {
|
|
t.Error("PasswordRequireSpecial = true, want false")
|
|
}
|
|
if cfg.PasswordRequireNumber != false {
|
|
t.Error("PasswordRequireNumber = true, want false")
|
|
}
|
|
}
|
|
|
|
// =============================================================================
|
|
// SMS Configuration Tests
|
|
// =============================================================================
|
|
|
|
func TestDefaultSMSCodeConfig(t *testing.T) {
|
|
cfg := DefaultSMSCodeConfig()
|
|
|
|
if cfg.CodeTTL != 5*time.Minute {
|
|
t.Errorf("CodeTTL = %v, want %v", cfg.CodeTTL, 5*time.Minute)
|
|
}
|
|
if cfg.ResendCooldown != time.Minute {
|
|
t.Errorf("ResendCooldown = %v, want %v", cfg.ResendCooldown, time.Minute)
|
|
}
|
|
if cfg.MaxDailyLimit != 10 {
|
|
t.Errorf("MaxDailyLimit = %d, want 10", cfg.MaxDailyLimit)
|
|
}
|
|
}
|