Add robust input validation system and fix test suite

- Add comprehensive validation package with email (RFC 5322), password strength, and IANA timezone validation
- Implement strict password requirements: min 8 chars, uppercase, lowercase, digit, special character
- Integrate validation into RegisterUserHandler with complete test coverage (59 validation tests + 25 handler tests)
- Fix pre-existing test failures:
  - Remove tests for non-existent HabitEntry.DeletedAt and Delete() methods
  - Replace deprecated HabitTypeQuantity with HabitTypeValue
  - Add missing FindByHabitIDAndDateRange mock implementation
- Remove hardcoded localhost:8080 from Swagger config for self-hosted flexibility
This commit is contained in:
2025-11-27 00:17:18 +01:00
parent 95088a8162
commit 7768037724
9 changed files with 673 additions and 39 deletions
@@ -31,10 +31,6 @@ func TestNewHabitEntry(t *testing.T) {
if entry.CompletedAt.IsZero() {
t.Error("CompletedAt should not be zero")
}
if entry.DeletedAt != nil {
t.Error("DeletedAt should be nil for new entry")
}
}
func TestNewHabitEntry_BooleanHabit(t *testing.T) {
@@ -48,20 +44,3 @@ func TestNewHabitEntry_BooleanHabit(t *testing.T) {
}
}
func TestHabitEntry_SoftDelete(t *testing.T) {
entry := NewHabitEntry("habit-123", time.Now(), nil)
if entry.DeletedAt != nil {
t.Error("New entry should not be deleted")
}
entry.Delete()
if entry.DeletedAt == nil {
t.Error("Entry should be deleted after calling SoftDelete()")
}
if entry.DeletedAt.After(time.Now()) {
t.Error("DeletedAt should not be in the future")
}
}