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) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-19 17:10:25 +02:00
parent 609a86dd03
commit 7358555d56
2 changed files with 13 additions and 0 deletions

View File

@@ -31,6 +31,12 @@ class OutboundConnectionAdminControllerIT extends AbstractPostgresIT {
if (wireMock != null) wireMock.stop(); 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 @BeforeEach
void setUp() { void setUp() {
adminJwt = securityHelper.adminToken(); adminJwt = securityHelper.adminToken();

View File

@@ -6,6 +6,7 @@ import com.cameleer.server.core.outbound.OutboundAuth;
import com.cameleer.server.core.outbound.OutboundConnection; import com.cameleer.server.core.outbound.OutboundConnection;
import com.cameleer.server.core.outbound.OutboundConnectionRepository; import com.cameleer.server.core.outbound.OutboundConnectionRepository;
import com.cameleer.server.core.outbound.OutboundMethod; import com.cameleer.server.core.outbound.OutboundMethod;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; 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); 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) { private OutboundConnection draft(String name) {
return new OutboundConnection( return new OutboundConnection(
UUID.randomUUID(), TENANT, name, "desc", UUID.randomUUID(), TENANT, name, "desc",