fix: security tests with mock email sender and rate limit isolation

- Add EmailSender interface to allow mocking in tests
- Add IsInitialized() method to template.Manager for nil-safe checks
- Update contact handler to use interface and safe initialization checks
- Add mockEmailSender in security tests to avoid SMTP connection attempts
- Use unique IPs per test case to avoid rate limiting interference
This commit is contained in:
juanatsap
2025-12-02 13:49:54 +00:00
parent 41dbd77c2f
commit 3edeb5274d
3 changed files with 75 additions and 33 deletions
+6
View File
@@ -17,6 +17,12 @@ type Manager struct {
mu sync.RWMutex
}
// IsInitialized returns true if the template manager has been properly initialized
// with a config. Empty Manager structs (e.g., in tests) will return false.
func (m *Manager) IsInitialized() bool {
return m != nil && m.config != nil
}
// NewManager creates a new template manager
func NewManager(cfg *config.TemplateConfig) (*Manager, error) {
m := &Manager{