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:
@@ -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();
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user