feat: activity log backend foundation

This commit is contained in:
fsylvain committed 2026-10-06 20:35:03 +02:00
1 parent 8907bb49fe
commit 50b1649965
74 files changed
+5949 -239

No files matched your search

+8 -8
View File
@@ -85,9 +85,9 @@ func TestAuthenticateUserUseCase(t *testing.T) {
t.Run("correct password returns the user with no error", func(t *testing.T) {
repo := newRepo()
uc := useCases.NewAuthenticateUserUseCase(repo, &stubHasher{})
uc := useCases.NewAuthenticateUserUseCase(repo, &stubHasher{}, discardRecorder)
result, err := uc.Authenticate("alice", "hunter2example")
result, err := uc.Authenticate(testCtx, "alice", "hunter2example")
if err != nil {
t.Fatalf("expected no error, got %v", err)
}
@@ -98,9 +98,9 @@ func TestAuthenticateUserUseCase(t *testing.T) {
t.Run("wrong password returns user.ErrInvalidCredentials", func(t *testing.T) {
repo := newRepo()
uc := useCases.NewAuthenticateUserUseCase(repo, &stubHasher{})
uc := useCases.NewAuthenticateUserUseCase(repo, &stubHasher{}, discardRecorder)
_, err := uc.Authenticate("alice", "wrongpassword12")
_, err := uc.Authenticate(testCtx, "alice", "wrongpassword12")
if !errors.Is(err, user.ErrInvalidCredentials) {
t.Errorf("expected user.ErrInvalidCredentials, got %v", err)
}
@@ -109,9 +109,9 @@ func TestAuthenticateUserUseCase(t *testing.T) {
t.Run("unknown username never calls the hasher", func(t *testing.T) {
repo := newMockUserRepo()
hasher := &spyHasher{}
uc := useCases.NewAuthenticateUserUseCase(repo, hasher)
uc := useCases.NewAuthenticateUserUseCase(repo, hasher, discardRecorder)
_, err := uc.Authenticate("bob", "hunter2example")
_, err := uc.Authenticate(testCtx, "bob", "hunter2example")
if !errors.Is(err, user.ErrUserNotFound) {
t.Errorf("expected user.ErrUserNotFound, got %v", err)
}
@@ -157,7 +157,7 @@ func newHasherRouter(userRepo *mockUserRepo, hasher *stubHasher) *chi.Mux {
loginHandler := auth.NewLoginHandler(
token,
useCases.NewCreateUserUseCase(userRepo, hasher, newMockMailRepo(), "https://cms.example.com"),
useCases.NewAuthenticateUserUseCase(userRepo, hasher),
useCases.NewAuthenticateUserUseCase(userRepo, hasher, discardRecorder),
true,
)
@@ -175,7 +175,7 @@ func newRealHasherRouter(userRepo *mockUserRepo) *chi.Mux {
loginHandler := auth.NewLoginHandler(
token,
useCases.NewCreateUserUseCase(userRepo, hasher, newMockMailRepo(), "https://cms.example.com"),
useCases.NewAuthenticateUserUseCase(userRepo, hasher),
useCases.NewAuthenticateUserUseCase(userRepo, hasher, discardRecorder),
true,
)