From 7358555d56d7b851a06a501af2b26195cf13df46 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:10:25 +0200 Subject: [PATCH] test(outbound): add @AfterEach cleanup to avoid leaking user/connection rows Shared Spring test context meant seeded test-admin/test-operator/test-viewer/test-alice users persisted across IT classes, breaking FlywayMigrationIT's "users is empty" assertion. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../controller/OutboundConnectionAdminControllerIT.java | 6 ++++++ .../storage/PostgresOutboundConnectionRepositoryIT.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/cameleer-server-app/src/test/java/com/cameleer/server/app/outbound/controller/OutboundConnectionAdminControllerIT.java b/cameleer-server-app/src/test/java/com/cameleer/server/app/outbound/controller/OutboundConnectionAdminControllerIT.java index 62509b35..af8d2346 100644 --- a/cameleer-server-app/src/test/java/com/cameleer/server/app/outbound/controller/OutboundConnectionAdminControllerIT.java +++ b/cameleer-server-app/src/test/java/com/cameleer/server/app/outbound/controller/OutboundConnectionAdminControllerIT.java @@ -31,6 +31,12 @@ class OutboundConnectionAdminControllerIT extends AbstractPostgresIT { if (wireMock != null) wireMock.stop(); } + @org.junit.jupiter.api.AfterEach + void cleanupRows() { + jdbcTemplate.update("DELETE FROM outbound_connections WHERE tenant_id = 'default'"); + jdbcTemplate.update("DELETE FROM users WHERE user_id IN ('test-admin','test-operator','test-viewer')"); + } + @BeforeEach void setUp() { adminJwt = securityHelper.adminToken(); diff --git a/cameleer-server-app/src/test/java/com/cameleer/server/app/outbound/storage/PostgresOutboundConnectionRepositoryIT.java b/cameleer-server-app/src/test/java/com/cameleer/server/app/outbound/storage/PostgresOutboundConnectionRepositoryIT.java index ce762734..1f242685 100644 --- a/cameleer-server-app/src/test/java/com/cameleer/server/app/outbound/storage/PostgresOutboundConnectionRepositoryIT.java +++ b/cameleer-server-app/src/test/java/com/cameleer/server/app/outbound/storage/PostgresOutboundConnectionRepositoryIT.java @@ -6,6 +6,7 @@ import com.cameleer.server.core.outbound.OutboundAuth; import com.cameleer.server.core.outbound.OutboundConnection; import com.cameleer.server.core.outbound.OutboundConnectionRepository; import com.cameleer.server.core.outbound.OutboundMethod; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -34,6 +35,12 @@ class PostgresOutboundConnectionRepositoryIT extends AbstractPostgresIT { jdbcTemplate.update("DELETE FROM outbound_connections WHERE tenant_id = ?", TENANT); } + @AfterEach + void cleanup() { + jdbcTemplate.update("DELETE FROM outbound_connections WHERE created_by = ? OR updated_by = ?", USER, USER); + jdbcTemplate.update("DELETE FROM users WHERE user_id = ?", USER); + } + private OutboundConnection draft(String name) { return new OutboundConnection( UUID.randomUUID(), TENANT, name, "desc",