Repository: OpenAEV-Platform/openaev (java)

Issue:
Improve drone pipelines



Discussion:

Patch:
diff --git a/openbas-api/src/main/java/io/openbas/executors/crowdstrike/service/CrowdStrikeExecutorService.java b/openbas-api/src/main/java/io/openbas/executors/crowdstrike/service/CrowdStrikeExecutorService.java
--- a/openbas-api/src/main/java/io/openbas/executors/crowdstrike/service/CrowdStrikeExecutorService.java
+++ b/openbas-api/src/main/java/io/openbas/executors/crowdstrike/service/CrowdStrikeExecutorService.java
@@ -91,7 +91,9 @@ public CrowdStrikeExecutorService(
                   Endpoint.PLATFORM_TYPE.MacOS.name()
                 });
       } else {
-        executorService.remove(config.getId());
+        if (executor != null) {
+          executorService.remove(config.getId());
+        }
       }
     } catch (Exception e) {
       log.error(String.format("Error creating CrowdStrike executor: %s", e.getMessage()), e);
diff --git a/openbas-api/src/main/java/io/openbas/helper/RabbitMQHelper.java b/openbas-api/src/main/java/io/openbas/helper/RabbitMQHelper.java
--- a/openbas-api/src/main/java/io/openbas/helper/RabbitMQHelper.java
+++ b/openbas-api/src/main/java/io/openbas/helper/RabbitMQHelper.java
@@ -44,7 +44,7 @@ public class RabbitMQHelper {
    */
   public static String getRabbitMQVersion(RabbitmqConfig rabbitmqConfig) {
     // If we already have the version, we don't need to get it again
-    if (rabbitMQVersion == null) {
+    if (rabbitMQVersion == null && rabbitmqConfig.getHostname() != null) {
       // Init the rabbit MQ management api overview url
       String uri =
           "http://"
diff --git a/openbas-model/src/main/java/io/openbas/driver/ElasticDriver.java b/openbas-model/src/main/java/io/openbas/driver/ElasticDriver.java
--- a/openbas-model/src/main/java/io/openbas/driver/ElasticDriver.java
+++ b/openbas-model/src/main/java/io/openbas/driver/ElasticDriver.java
@@ -201,13 +201,17 @@ private void createIndex(
     try {
       client.indices().get(new GetIndexRequest.Builder().index(indexName).build());
     } catch (ElasticsearchException e) {
-      client
-          .indices()
-          .create(
-              new CreateIndexRequest.Builder()
-                  .index(indexName + config.getIndexSuffix())
-                  .aliases(indexName, new Alias.Builder().build())
-                  .build());
+      try {
+        client
+            .indices()
+            .create(
+                new CreateIndexRequest.Builder()
+                    .index(indexName + config.getIndexSuffix())
+                    .aliases(indexName, new Alias.Builder().build())
+                    .build());
+      } catch (ElasticsearchException e2) {
+        log.error("cannot create index", e2);
+      }
     }
   }
 


Test patch:
diff --git a/openbas-api/src/test/java/io/openbas/IntegrationTest.java b/openbas-api/src/test/java/io/openbas/IntegrationTest.java
--- a/openbas-api/src/test/java/io/openbas/IntegrationTest.java
+++ b/openbas-api/src/test/java/io/openbas/IntegrationTest.java
@@ -1,9 +1,14 @@
 package io.openbas;
 
+import io.openbas.utilstest.StartupSnapshotTestListener;
 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
 import org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrint;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestExecutionListeners;
 
 @AutoConfigureMockMvc(print = MockMvcPrint.SYSTEM_ERR)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@TestExecutionListeners(
+    value = {StartupSnapshotTestListener.class},
+    mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS)
 public abstract class IntegrationTest {}
diff --git a/openbas-api/src/test/java/io/openbas/config/OpenCTIConfigTest.java b/openbas-api/src/test/java/io/openbas/config/OpenCTIConfigTest.java
--- a/openbas-api/src/test/java/io/openbas/config/OpenCTIConfigTest.java
+++ b/openbas-api/src/test/java/io/openbas/config/OpenCTIConfigTest.java
@@ -2,6 +2,7 @@
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import io.openbas.IntegrationTest;
 import io.openbas.injectors.opencti.config.OpenCTIConfig;
 import io.openbas.utils.mockConfig.WithMockOpenCTIConfig;
 import org.junit.jupiter.api.DisplayName;
@@ -12,7 +13,8 @@
 
 @SpringBootTest
 @DisplayName("OpenCTIConfig tests")
-public class OpenCTIConfigTest {
+public class OpenCTIConfigTest extends IntegrationTest {
+
   @Nested
   @WithMockOpenCTIConfig(url = "public_url")
   @DisplayName("When setting only the public URL")
diff --git a/openbas-api/src/test/java/io/openbas/database/model/InjectTest.java b/openbas-api/src/test/java/io/openbas/database/model/InjectTest.java
--- a/openbas-api/src/test/java/io/openbas/database/model/InjectTest.java
+++ b/openbas-api/src/test/java/io/openbas/database/model/InjectTest.java
@@ -2,6 +2,7 @@
 
 import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
 
+import io.openbas.IntegrationTest;
 import io.openbas.utils.fixtures.ExerciseFixture;
 import io.openbas.utils.fixtures.InjectFixture;
 import io.openbas.utils.fixtures.PauseFixture;
@@ -17,7 +18,7 @@
 @SpringBootTest
 @TestInstance(PER_CLASS)
 @Transactional
-public class InjectTest {
+public class InjectTest extends IntegrationTest {
 
   @Autowired private ExerciseComposer exerciseComposer;
   @Autowired private InjectComposer injectComposer;
diff --git a/openbas-api/src/test/java/io/openbas/database/model/SimulationTest.java b/openbas-api/src/test/java/io/openbas/database/model/SimulationTest.java
--- a/openbas-api/src/test/java/io/openbas/database/model/SimulationTest.java
+++ b/openbas-api/src/test/java/io/openbas/database/model/SimulationTest.java
@@ -2,15 +2,13 @@
 
 import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.repository.ExerciseRepository;
 import io.openbas.utils.fixtures.ExerciseFixture;
 import io.openbas.utils.fixtures.composers.ExerciseComposer;
 import jakarta.persistence.EntityManager;
 import java.time.Instant;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.transaction.annotation.Transactional;
@@ -18,7 +16,7 @@
 @SpringBootTest
 @TestInstance(PER_CLASS)
 @Transactional
-class SimulationTest {
+class SimulationTest extends IntegrationTest {
   @Autowired private ExerciseComposer exerciseComposer;
   @Autowired private ExerciseRepository exerciseRepository;
   @Autowired private EntityManager entityManager;
diff --git a/openbas-api/src/test/java/io/openbas/helper/InjectHelperTest.java b/openbas-api/src/test/java/io/openbas/helper/InjectHelperTest.java
--- a/openbas-api/src/test/java/io/openbas/helper/InjectHelperTest.java
+++ b/openbas-api/src/test/java/io/openbas/helper/InjectHelperTest.java
@@ -5,6 +5,7 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.*;
 import io.openbas.database.repository.*;
 import io.openbas.execution.ExecutableInject;
@@ -18,7 +19,7 @@
 import org.springframework.boot.test.context.SpringBootTest;
 
 @SpringBootTest
-public class InjectHelperTest {
+public class InjectHelperTest extends IntegrationTest {
 
   public static final String USER_EMAIL = "test@gmail.com";
   @Autowired private InjectHelper injectHelper;
diff --git a/openbas-api/src/test/java/io/openbas/importer/V1_DataImporterTest.java b/openbas-api/src/test/java/io/openbas/importer/V1_DataImporterTest.java
--- a/openbas-api/src/test/java/io/openbas/importer/V1_DataImporterTest.java
+++ b/openbas-api/src/test/java/io/openbas/importer/V1_DataImporterTest.java
@@ -7,6 +7,7 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 import io.openbas.IntegrationTest;
 import io.openbas.database.model.*;
+import io.openbas.database.model.Tag;
 import io.openbas.database.repository.*;
 import io.openbas.utils.Constants;
 import java.io.IOException;
@@ -16,9 +17,7 @@
 import java.util.Map;
 import java.util.Optional;
 import org.jetbrains.annotations.NotNull;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.*;
 import org.mockito.MockitoAnnotations;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.jpa.domain.Specification;
diff --git a/openbas-api/src/test/java/io/openbas/injector_contract/InjectorContratApiTest.java b/openbas-api/src/test/java/io/openbas/injector_contract/InjectorContratApiTest.java
--- a/openbas-api/src/test/java/io/openbas/injector_contract/InjectorContratApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/injector_contract/InjectorContratApiTest.java
@@ -14,10 +14,7 @@
 import io.openbas.utils.pagination.SearchPaginationInput;
 import io.openbas.utils.pagination.SortField;
 import java.util.List;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Nested;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.test.web.servlet.MockMvc;
diff --git a/openbas-api/src/test/java/io/openbas/injects/Expectation/ExpectationUtilsTest.java b/openbas-api/src/test/java/io/openbas/injects/Expectation/ExpectationUtilsTest.java
--- a/openbas-api/src/test/java/io/openbas/injects/Expectation/ExpectationUtilsTest.java
+++ b/openbas-api/src/test/java/io/openbas/injects/Expectation/ExpectationUtilsTest.java
@@ -4,6 +4,7 @@
 import static io.openbas.utils.ExpectationUtils.*;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.*;
 import io.openbas.model.expectation.DetectionExpectation;
 import io.openbas.model.expectation.PreventionExpectation;
@@ -15,7 +16,7 @@
 import org.mockito.junit.jupiter.MockitoExtension;
 
 @ExtendWith(MockitoExtension.class)
-class ExpectationUtilsTest {
+class ExpectationUtilsTest extends IntegrationTest {
 
   @Test
   @DisplayName("Build expectations with the signature parent process name for obas implant")
diff --git a/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java b/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java
--- a/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java
+++ b/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java
@@ -3,6 +3,7 @@
 import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Exercise;
 import io.openbas.database.model.Inject;
 import io.openbas.database.repository.ExerciseRepository;
@@ -15,7 +16,7 @@
 import org.springframework.boot.test.context.SpringBootTest;
 
 @SpringBootTest
-class InjectCrudTest {
+class InjectCrudTest extends IntegrationTest {
 
   @Autowired private InjectRepository injectRepository;
 
diff --git a/openbas-api/src/test/java/io/openbas/injects/atomic_testing/ResultUtilsTest.java b/openbas-api/src/test/java/io/openbas/injects/atomic_testing/ResultUtilsTest.java
--- a/openbas-api/src/test/java/io/openbas/injects/atomic_testing/ResultUtilsTest.java
+++ b/openbas-api/src/test/java/io/openbas/injects/atomic_testing/ResultUtilsTest.java
@@ -9,6 +9,7 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.when;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.InjectExpectation;
 import io.openbas.database.raw.RawInjectExpectation;
 import io.openbas.database.repository.InjectExpectationRepository;
@@ -27,7 +28,7 @@
 import org.mockito.junit.jupiter.MockitoExtension;
 
 @ExtendWith(MockitoExtension.class)
-class ResultUtilsTest {
+class ResultUtilsTest extends IntegrationTest {
 
   @Mock private InjectExpectationRepository injectExpectationRepository;
   @Mock private InjectRepository injectRepository;
diff --git a/openbas-api/src/test/java/io/openbas/injects/email/EmailExecutorTest.java b/openbas-api/src/test/java/io/openbas/injects/email/EmailExecutorTest.java
--- a/openbas-api/src/test/java/io/openbas/injects/email/EmailExecutorTest.java
+++ b/openbas-api/src/test/java/io/openbas/injects/email/EmailExecutorTest.java
@@ -5,6 +5,7 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Execution;
 import io.openbas.database.model.Inject;
 import io.openbas.database.model.InjectExpectation;
@@ -26,7 +27,7 @@
 import org.springframework.boot.test.context.SpringBootTest;
 
 @SpringBootTest
-public class EmailExecutorTest {
+public class EmailExecutorTest extends IntegrationTest {
 
   @Autowired private EmailExecutor emailExecutor;
   @Autowired private UserRepository userRepository;
diff --git a/openbas-api/src/test/java/io/openbas/injects/manual/ManualExecutorTest.java b/openbas-api/src/test/java/io/openbas/injects/manual/ManualExecutorTest.java
--- a/openbas-api/src/test/java/io/openbas/injects/manual/ManualExecutorTest.java
+++ b/openbas-api/src/test/java/io/openbas/injects/manual/ManualExecutorTest.java
@@ -4,6 +4,7 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Execution;
 import io.openbas.database.model.Inject;
 import io.openbas.database.model.InjectExpectation;
@@ -24,7 +25,7 @@
 import org.springframework.test.util.ReflectionTestUtils;
 
 @SpringBootTest
-public class ManualExecutorTest {
+public class ManualExecutorTest extends IntegrationTest {
 
   @Mock InjectExpectationService injectExpectationService;
 
diff --git a/openbas-api/src/test/java/io/openbas/octi/OpenCTIApiTest.java b/openbas-api/src/test/java/io/openbas/octi/OpenCTIApiTest.java
--- a/openbas-api/src/test/java/io/openbas/octi/OpenCTIApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/octi/OpenCTIApiTest.java
@@ -4,6 +4,7 @@
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 
+import io.openbas.IntegrationTest;
 import io.openbas.opencti.OpenCTIApi;
 import io.openbas.rest.attack_pattern.AttackPatternApi;
 import io.openbas.rest.inject.InjectApi;
@@ -45,7 +46,7 @@
  * endpoints.
  */
 @ExtendWith(MockitoExtension.class)
-class OpenCTIApiTest {
+class OpenCTIApiTest extends IntegrationTest {
 
   @Mock InjectApi injectApi;
   @Mock ScenarioInjectApi scenarioInjectApi;
diff --git a/openbas-api/src/test/java/io/openbas/rest/ChannelApiTest.java b/openbas-api/src/test/java/io/openbas/rest/ChannelApiTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/ChannelApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/ChannelApiTest.java
@@ -9,6 +9,7 @@
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 
 import com.jayway.jsonpath.JsonPath;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Channel;
 import io.openbas.database.model.Scenario;
 import io.openbas.database.repository.ArticleRepository;
@@ -29,7 +30,7 @@
 @AutoConfigureMockMvc
 @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 @TestInstance(PER_CLASS)
-class ChannelApiTest {
+class ChannelApiTest extends IntegrationTest {
 
   @Autowired private MockMvc mvc;
 
diff --git a/openbas-api/src/test/java/io/openbas/rest/HealthCheckApiTest.java b/openbas-api/src/test/java/io/openbas/rest/HealthCheckApiTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/HealthCheckApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/HealthCheckApiTest.java
@@ -5,6 +5,7 @@
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.verify;
 
+import io.openbas.IntegrationTest;
 import io.openbas.rest.health_check.HealthCheckApi;
 import io.openbas.service.HealthCheckService;
 import io.openbas.service.exception.HealthCheckFailureException;
@@ -19,7 +20,7 @@
 
 @SpringBootTest
 @TestInstance(PER_CLASS)
-public class HealthCheckApiTest {
+public class HealthCheckApiTest extends IntegrationTest {
 
   private static final String KEY = "KEY";
 
diff --git a/openbas-api/src/test/java/io/openbas/rest/MapperApiTest.java b/openbas-api/src/test/java/io/openbas/rest/MapperApiTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/MapperApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/MapperApiTest.java
@@ -9,6 +9,7 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jayway.jsonpath.JsonPath;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.ImportMapper;
 import io.openbas.database.repository.ImportMapperRepository;
 import io.openbas.rest.inject.service.InjectService;
@@ -48,7 +49,7 @@
 
 @SpringBootTest
 @ExtendWith(MockitoExtension.class)
-public class MapperApiTest {
+public class MapperApiTest extends IntegrationTest {
 
   private MockMvc mvc;
 
diff --git a/openbas-api/src/test/java/io/openbas/rest/ReportApiTest.java b/openbas-api/src/test/java/io/openbas/rest/ReportApiTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/ReportApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/ReportApiTest.java
@@ -10,6 +10,7 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jayway.jsonpath.JsonPath;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.*;
 import io.openbas.rest.exercise.service.ExerciseService;
 import io.openbas.rest.inject.service.InjectService;
@@ -38,7 +39,7 @@
 @AutoConfigureMockMvc
 @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 @TestInstance(PER_CLASS)
-public class ReportApiTest {
+public class ReportApiTest extends IntegrationTest {
 
   private MockMvc mvc;
 
diff --git a/openbas-api/src/test/java/io/openbas/rest/TagApiTest.java b/openbas-api/src/test/java/io/openbas/rest/TagApiTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/TagApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/TagApiTest.java
@@ -15,10 +15,7 @@
 import io.openbas.utils.fixtures.composers.TagComposer;
 import io.openbas.utils.mockUser.WithMockAdminUser;
 import jakarta.persistence.EntityManager;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.test.web.servlet.MockMvc;
diff --git a/openbas-api/src/test/java/io/openbas/rest/VariableApiTest.java b/openbas-api/src/test/java/io/openbas/rest/VariableApiTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/VariableApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/VariableApiTest.java
@@ -10,6 +10,7 @@
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 
 import com.jayway.jsonpath.JsonPath;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Scenario;
 import io.openbas.database.model.Variable;
 import io.openbas.database.repository.ScenarioRepository;
@@ -28,7 +29,7 @@
 @AutoConfigureMockMvc
 @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 @TestInstance(PER_CLASS)
-public class VariableApiTest {
+public class VariableApiTest extends IntegrationTest {
 
   @Autowired private MockMvc mvc;
 
@@ -42,7 +43,7 @@ public class VariableApiTest {
   @AfterAll
   void afterAll() {
     this.scenarioRepository.deleteById(SCENARIO_ID);
-    this.variableRepository.deleteById(SCENARIO_ID);
+    this.variableRepository.deleteById(VARIABLE_ID);
   }
 
   // -- SCENARIOS --
diff --git a/openbas-api/src/test/java/io/openbas/rest/attack_pattern/AttackPatternApiTest.java b/openbas-api/src/test/java/io/openbas/rest/attack_pattern/AttackPatternApiTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/attack_pattern/AttackPatternApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/attack_pattern/AttackPatternApiTest.java
@@ -14,10 +14,7 @@
 import io.openbas.utils.mockUser.WithMockAdminUser;
 import jakarta.servlet.ServletException;
 import java.util.Objects;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Nested;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.*;
 import org.mockito.Mockito;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.mock.mockito.MockBean;
@@ -27,14 +24,12 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.mock.web.MockPart;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
 
 @Transactional
 @TestInstance(PER_CLASS)
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
 public class AttackPatternApiTest extends IntegrationTest {
   @Autowired private Environment env;
 
diff --git a/openbas-api/src/test/java/io/openbas/rest/exercise/ExerciseApiStatusTest.java b/openbas-api/src/test/java/io/openbas/rest/exercise/ExerciseApiStatusTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/exercise/ExerciseApiStatusTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/exercise/ExerciseApiStatusTest.java
@@ -16,6 +16,7 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jayway.jsonpath.JsonPath;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.*;
 import io.openbas.database.repository.*;
 import io.openbas.execution.ExecutableInject;
@@ -43,7 +44,7 @@
 @SpringBootTest
 @AutoConfigureMockMvc
 @TestInstance(PER_CLASS)
-public class ExerciseApiStatusTest {
+public class ExerciseApiStatusTest extends IntegrationTest {
 
   static Exercise SCHEDULED_EXERCISE;
   static Exercise RUNNING_EXERCISE;
diff --git a/openbas-api/src/test/java/io/openbas/rest/exercise/ExerciseApiTest.java b/openbas-api/src/test/java/io/openbas/rest/exercise/ExerciseApiTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/exercise/ExerciseApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/exercise/ExerciseApiTest.java
@@ -11,6 +11,7 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jayway.jsonpath.JsonPath;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.*;
 import io.openbas.database.model.Tag;
 import io.openbas.database.repository.*;
@@ -34,7 +35,7 @@
 @SpringBootTest
 @AutoConfigureMockMvc
 @TestInstance(PER_CLASS)
-public class ExerciseApiTest {
+public class ExerciseApiTest extends IntegrationTest {
   @Autowired private MockMvc mvc;
   @Autowired private ObjectMapper objectMapper;
   @Autowired private AgentComposer agentComposer;
diff --git a/openbas-api/src/test/java/io/openbas/rest/exercise/exports/ExportOptionsTest.java b/openbas-api/src/test/java/io/openbas/rest/exercise/exports/ExportOptionsTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/exercise/exports/ExportOptionsTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/exercise/exports/ExportOptionsTest.java
@@ -3,10 +3,7 @@
 import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
 
 import io.openbas.IntegrationTest;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.*;
 
 @TestInstance(PER_CLASS)
 public class ExportOptionsTest extends IntegrationTest {
diff --git a/openbas-api/src/test/java/io/openbas/rest/exercise/service/ExerciseServiceTest.java b/openbas-api/src/test/java/io/openbas/rest/exercise/service/ExerciseServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/exercise/service/ExerciseServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/exercise/service/ExerciseServiceTest.java
@@ -9,6 +9,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import io.openbas.IntegrationTest;
 import io.openbas.config.cache.LicenseCacheManager;
 import io.openbas.database.model.*;
 import io.openbas.database.repository.*;
@@ -46,7 +47,7 @@
 
 @SpringBootTest
 @ExtendWith(MockitoExtension.class)
-class ExerciseServiceTest {
+class ExerciseServiceTest extends IntegrationTest {
 
   @Mock private Ee eeService;
   @Mock private GrantService grantService;
diff --git a/openbas-api/src/test/java/io/openbas/rest/finding/FindingServiceTest.java b/openbas-api/src/test/java/io/openbas/rest/finding/FindingServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/finding/FindingServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/finding/FindingServiceTest.java
@@ -22,9 +22,7 @@
 import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.*;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.InjectMocks;
diff --git a/openbas-api/src/test/java/io/openbas/rest/inject/InjectImportTest.java b/openbas-api/src/test/java/io/openbas/rest/inject/InjectImportTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/inject/InjectImportTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/inject/InjectImportTest.java
@@ -52,6 +52,10 @@
 @DisplayName("Importing injects tests")
 public class InjectImportTest extends IntegrationTest {
 
+  public final String INJECT_IMPORT_URI = INJECT_URI + "/import";
+  private final Map<String, ArticleComposer.Composer> staticArticleWrappers = new HashMap<>();
+  private final String KNOWN_ARTICLE_WRAPPER_KEY = "known article key";
+
   @Autowired ObjectMapper objectMapper;
   @Autowired MockMvc mvc;
   @Autowired InjectExportService exportService;
@@ -108,10 +112,6 @@ void before() throws Exception {
     clearEntityManager();
   }
 
-  public final String INJECT_IMPORT_URI = INJECT_URI + "/import";
-  private final Map<String, ArticleComposer.Composer> staticArticleWrappers = new HashMap<>();
-  private final String KNOWN_ARTICLE_WRAPPER_KEY = "known article key";
-
   private Map<String, ArticleComposer.Composer> getStaticArticleWrappers() {
     if (!staticArticleWrappers.containsKey(KNOWN_ARTICLE_WRAPPER_KEY)) {
       staticArticleWrappers.put(
diff --git a/openbas-api/src/test/java/io/openbas/rest/inject/StructuredOutputUtilsTest.java b/openbas-api/src/test/java/io/openbas/rest/inject/StructuredOutputUtilsTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/inject/StructuredOutputUtilsTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/inject/StructuredOutputUtilsTest.java
@@ -5,19 +5,18 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.*;
 import io.openbas.rest.inject.service.StructuredOutputUtils;
 import java.util.Arrays;
 import java.util.Optional;
 import java.util.Set;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.*;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.junit.jupiter.MockitoExtension;
 
 @ExtendWith(MockitoExtension.class)
-class StructuredOutputUtilsTest {
+class StructuredOutputUtilsTest extends IntegrationTest {
 
   public static final String SIMPLE_RAW_OUTPUT_TASKLIST =
       "\r\nImage Name                 PID  Session Name        Session#    Mem Usage\r\n"
diff --git a/openbas-api/src/test/java/io/openbas/rest/inject/service/InjectServiceTest.java b/openbas-api/src/test/java/io/openbas/rest/inject/service/InjectServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/inject/service/InjectServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/inject/service/InjectServiceTest.java
@@ -30,9 +30,7 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Optional;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.*;
 import org.mockito.ArgumentCaptor;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
diff --git a/openbas-api/src/test/java/io/openbas/rest/scenario/ScenarioImportApiTest.java b/openbas-api/src/test/java/io/openbas/rest/scenario/ScenarioImportApiTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/scenario/ScenarioImportApiTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/scenario/ScenarioImportApiTest.java
@@ -6,6 +6,7 @@
 import static org.mockito.Mockito.when;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.ImportMapper;
 import io.openbas.database.repository.ImportMapperRepository;
 import io.openbas.rest.inject.service.InjectService;
@@ -29,7 +30,7 @@
 
 @SpringBootTest
 @ExtendWith(MockitoExtension.class)
-public class ScenarioImportApiTest {
+public class ScenarioImportApiTest extends IntegrationTest {
 
   private MockMvc mvc;
 
diff --git a/openbas-api/src/test/java/io/openbas/rest/scenario/ScenarioToExerciseServiceTest.java b/openbas-api/src/test/java/io/openbas/rest/scenario/ScenarioToExerciseServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/scenario/ScenarioToExerciseServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/scenario/ScenarioToExerciseServiceTest.java
@@ -12,6 +12,7 @@
 import static io.openbas.utils.fixtures.UserFixture.getUser;
 import static org.junit.jupiter.api.Assertions.*;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.*;
 import io.openbas.database.repository.*;
 import io.openbas.service.LoadService;
@@ -30,7 +31,7 @@
 
 @SpringBootTest
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
-class ScenarioToExerciseServiceTest {
+class ScenarioToExerciseServiceTest extends IntegrationTest {
 
   @Autowired private ScenarioToExerciseService scenarioToExerciseService;
   @Autowired private LoadService loadService;
diff --git a/openbas-api/src/test/java/io/openbas/rest/scenario/service/ScenarioStatisticServiceTest.java b/openbas-api/src/test/java/io/openbas/rest/scenario/service/ScenarioStatisticServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/rest/scenario/service/ScenarioStatisticServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/rest/scenario/service/ScenarioStatisticServiceTest.java
@@ -5,6 +5,7 @@
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.when;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.raw.RawFinishedExerciseWithInjects;
 import io.openbas.database.repository.ExerciseRepository;
 import io.openbas.expectation.ExpectationType;
@@ -25,7 +26,7 @@
 import org.mockito.junit.jupiter.MockitoExtension;
 
 @ExtendWith(MockitoExtension.class)
-class ScenarioStatisticServiceTest {
+class ScenarioStatisticServiceTest extends IntegrationTest {
   @Mock private ExerciseRepository exerciseRepository;
   @Mock private ResultUtils resultUtils;
 
diff --git a/openbas-api/src/test/java/io/openbas/runner/InitAdminCommandLineRunnerTest.java b/openbas-api/src/test/java/io/openbas/runner/InitAdminCommandLineRunnerTest.java
--- a/openbas-api/src/test/java/io/openbas/runner/InitAdminCommandLineRunnerTest.java
+++ b/openbas-api/src/test/java/io/openbas/runner/InitAdminCommandLineRunnerTest.java
@@ -4,6 +4,7 @@
 import static io.openbas.database.model.User.ADMIN_UUID;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Token;
 import io.openbas.database.model.User;
 import io.openbas.database.repository.TokenRepository;
@@ -17,7 +18,7 @@
 
 @SpringBootTest
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public class InitAdminCommandLineRunnerTest {
+public class InitAdminCommandLineRunnerTest extends IntegrationTest {
 
   @Autowired private UserRepository userRepository;
 
diff --git a/openbas-api/src/test/java/io/openbas/scheduler/jobs/InjectsExecutionJobTest.java b/openbas-api/src/test/java/io/openbas/scheduler/jobs/InjectsExecutionJobTest.java
--- a/openbas-api/src/test/java/io/openbas/scheduler/jobs/InjectsExecutionJobTest.java
+++ b/openbas-api/src/test/java/io/openbas/scheduler/jobs/InjectsExecutionJobTest.java
@@ -2,6 +2,7 @@
 
 import static org.junit.jupiter.api.Assertions.*;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.*;
 import io.openbas.database.repository.ExerciseRepository;
 import io.openbas.database.repository.InjectRepository;
@@ -23,7 +24,7 @@
 @SpringBootTest
 @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
-class InjectsExecutionJobTest {
+class InjectsExecutionJobTest extends IntegrationTest {
 
   @Autowired private InjectsExecutionJob job;
 
diff --git a/openbas-api/src/test/java/io/openbas/scheduler/jobs/ScenarioExecutionJobTest.java b/openbas-api/src/test/java/io/openbas/scheduler/jobs/ScenarioExecutionJobTest.java
--- a/openbas-api/src/test/java/io/openbas/scheduler/jobs/ScenarioExecutionJobTest.java
+++ b/openbas-api/src/test/java/io/openbas/scheduler/jobs/ScenarioExecutionJobTest.java
@@ -4,6 +4,7 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Exercise;
 import io.openbas.database.model.Scenario;
 import io.openbas.database.repository.ExerciseRepository;
@@ -22,7 +23,7 @@
 @SpringBootTest
 @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
-class ScenarioExecutionJobTest {
+class ScenarioExecutionJobTest extends IntegrationTest {
 
   @Autowired private ScenarioExecutionJob job;
 
diff --git a/openbas-api/src/test/java/io/openbas/service/EmailServiceTest.java b/openbas-api/src/test/java/io/openbas/service/EmailServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/EmailServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/EmailServiceTest.java
@@ -3,6 +3,7 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.*;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Execution;
 import io.openbas.execution.ExecutionContext;
 import io.openbas.injectors.email.service.EmailService;
@@ -20,7 +21,7 @@
 import org.springframework.mail.javamail.JavaMailSender;
 
 @ExtendWith(MockitoExtension.class)
-class EmailServiceTest {
+class EmailServiceTest extends IntegrationTest {
 
   @Mock private JavaMailSender emailSender;
   @InjectMocks private EmailService emailService;
diff --git a/openbas-api/src/test/java/io/openbas/service/ExerciseExpectationServiceTest.java b/openbas-api/src/test/java/io/openbas/service/ExerciseExpectationServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/ExerciseExpectationServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/ExerciseExpectationServiceTest.java
@@ -5,6 +5,7 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Exercise;
 import io.openbas.database.model.Inject;
 import io.openbas.database.model.InjectExpectation;
@@ -20,7 +21,7 @@
 
 @SpringBootTest
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public class ExerciseExpectationServiceTest {
+public class ExerciseExpectationServiceTest extends IntegrationTest {
 
   public static final String EXPECTATION_NAME =
       "The animation team can validate the audience reaction";
diff --git a/openbas-api/src/test/java/io/openbas/service/ExerciseServiceIntegrationTest.java b/openbas-api/src/test/java/io/openbas/service/ExerciseServiceIntegrationTest.java
--- a/openbas-api/src/test/java/io/openbas/service/ExerciseServiceIntegrationTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/ExerciseServiceIntegrationTest.java
@@ -9,6 +9,7 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
+import io.openbas.IntegrationTest;
 import io.openbas.config.cache.LicenseCacheManager;
 import io.openbas.database.model.*;
 import io.openbas.database.repository.*;
@@ -34,7 +35,7 @@
 
 @SpringBootTest
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
-class ExerciseServiceIntegrationTest {
+class ExerciseServiceIntegrationTest extends IntegrationTest {
 
   @Mock Ee eeService;
   @Mock GrantService grantService;
diff --git a/openbas-api/src/test/java/io/openbas/service/GrantServiceTest.java b/openbas-api/src/test/java/io/openbas/service/GrantServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/GrantServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/GrantServiceTest.java
@@ -4,6 +4,7 @@
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.when;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Grant;
 import io.openbas.database.model.User;
 import io.openbas.database.raw.RawGrant;
@@ -16,7 +17,7 @@
 import org.springframework.boot.test.context.SpringBootTest;
 
 @SpringBootTest
-public class GrantServiceTest {
+public class GrantServiceTest extends IntegrationTest {
 
   private static final String USER_ID = "userid";
   private static final String RESOURCE_ID = "resourceid";
diff --git a/openbas-api/src/test/java/io/openbas/service/HealthCheckServiceTest.java b/openbas-api/src/test/java/io/openbas/service/HealthCheckServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/HealthCheckServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/HealthCheckServiceTest.java
@@ -9,6 +9,7 @@
 import io.minio.BucketExistsArgs;
 import io.minio.MinioClient;
 import io.minio.errors.*;
+import io.openbas.IntegrationTest;
 import io.openbas.config.MinioConfig;
 import io.openbas.database.repository.*;
 import io.openbas.driver.MinioDriver;
@@ -24,7 +25,7 @@
 
 @SpringBootTest
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
-class HealthCheckServiceTest {
+class HealthCheckServiceTest extends IntegrationTest {
 
   private static final String BUCKET = "bucket";
 
diff --git a/openbas-api/src/test/java/io/openbas/service/InjectImportServiceTest.java b/openbas-api/src/test/java/io/openbas/service/InjectImportServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/InjectImportServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/InjectImportServiceTest.java
@@ -4,6 +4,7 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.RuleAttribute;
 import io.openbas.service.utils.InjectImportUtils;
 import io.openbas.utils.mockMapper.MockMapperUtils;
@@ -19,7 +20,7 @@
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.junit.jupiter.api.*;
 
-public class InjectImportServiceTest {
+public class InjectImportServiceTest extends IntegrationTest {
   private Row row;
   private Cell cell;
   private ObjectNode json;
diff --git a/openbas-api/src/test/java/io/openbas/service/MapperServiceTest.java b/openbas-api/src/test/java/io/openbas/service/MapperServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/MapperServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/MapperServiceTest.java
@@ -8,6 +8,7 @@
 import static org.mockito.Mockito.when;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.ImportMapper;
 import io.openbas.database.model.InjectImporter;
 import io.openbas.database.repository.EndpointRepository;
@@ -28,7 +29,7 @@
 
 @SpringBootTest
 @ExtendWith(MockitoExtension.class)
-public class MapperServiceTest {
+public class MapperServiceTest extends IntegrationTest {
 
   @Mock private ImportMapperRepository importMapperRepository;
   @Mock private InjectorContractRepository injectorContractRepository;
diff --git a/openbas-api/src/test/java/io/openbas/service/NotificationEvenServiceTest.java b/openbas-api/src/test/java/io/openbas/service/NotificationEvenServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/NotificationEvenServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/NotificationEvenServiceTest.java
@@ -3,6 +3,7 @@
 import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.verify;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.NotificationRuleResourceType;
 import io.openbas.notification.handler.ScenarioNotificationEventHandler;
 import io.openbas.notification.model.NotificationEvent;
@@ -16,7 +17,7 @@
 import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
 
 @SpringBootTest
-public class NotificationEvenServiceTest {
+public class NotificationEvenServiceTest extends IntegrationTest {
 
   @Mock private ApplicationEventPublisher appPublisher;
   @Mock private ScenarioNotificationEventHandler scenarioNotificationEventHandler;
diff --git a/openbas-api/src/test/java/io/openbas/service/NotificationRuleServiceTest.java b/openbas-api/src/test/java/io/openbas/service/NotificationRuleServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/NotificationRuleServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/NotificationRuleServiceTest.java
@@ -3,6 +3,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.NotificationRule;
 import io.openbas.database.model.NotificationRuleResourceType;
 import io.openbas.database.model.NotificationRuleTrigger;
@@ -17,7 +18,7 @@
 import org.springframework.boot.test.context.SpringBootTest;
 
 @SpringBootTest
-public class NotificationRuleServiceTest {
+public class NotificationRuleServiceTest extends IntegrationTest {
 
   @Mock private NotificationRuleRepository notificationRuleRepository;
 
diff --git a/openbas-api/src/test/java/io/openbas/service/PermissionServiceTest.java b/openbas-api/src/test/java/io/openbas/service/PermissionServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/PermissionServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/PermissionServiceTest.java
@@ -4,6 +4,7 @@
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.when;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Action;
 import io.openbas.database.model.Capability;
 import io.openbas.database.model.Group;
@@ -21,7 +22,7 @@
 import org.springframework.boot.test.context.SpringBootTest;
 
 @SpringBootTest
-public class PermissionServiceTest {
+public class PermissionServiceTest extends IntegrationTest {
   private static final String RESOURCE_ID = "resourceid";
   private static final String USER_ID = "userid";
 
diff --git a/openbas-api/src/test/java/io/openbas/service/PlatformServiceSettingsTest.java b/openbas-api/src/test/java/io/openbas/service/PlatformServiceSettingsTest.java
--- a/openbas-api/src/test/java/io/openbas/service/PlatformServiceSettingsTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/PlatformServiceSettingsTest.java
@@ -4,6 +4,7 @@
 import static org.hamcrest.Matchers.*;
 import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
 
+import io.openbas.IntegrationTest;
 import io.openbas.config.OpenBASConfig;
 import io.openbas.config.RabbitmqConfig;
 import io.openbas.rest.settings.PreviewFeature;
@@ -24,7 +25,7 @@
 @SpringBootTest
 @ExtendWith(MockitoExtension.class)
 @TestInstance(PER_CLASS)
-public class PlatformServiceSettingsTest {
+public class PlatformServiceSettingsTest extends IntegrationTest {
 
   @Autowired private PlatformSettingsService platformSettingsService;
   @Resource private RabbitmqConfig rabbitmqConfig;
diff --git a/openbas-api/src/test/java/io/openbas/service/ReportServiceTest.java b/openbas-api/src/test/java/io/openbas/service/ReportServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/ReportServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/ReportServiceTest.java
@@ -5,6 +5,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.*;
 import io.openbas.rest.report.form.ReportInformationInput;
 import io.openbas.rest.report.form.ReportInjectCommentInput;
@@ -18,10 +19,7 @@
 import java.util.List;
 import java.util.Optional;
 import java.util.UUID;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Nested;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.*;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
@@ -30,7 +28,7 @@
 
 @SpringBootTest
 @ExtendWith(MockitoExtension.class)
-public class ReportServiceTest {
+public class ReportServiceTest extends IntegrationTest {
 
   @Mock private ReportRepository reportRepository;
 
diff --git a/openbas-api/src/test/java/io/openbas/service/RoleServiceTest.java b/openbas-api/src/test/java/io/openbas/service/RoleServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/RoleServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/RoleServiceTest.java
@@ -1,5 +1,6 @@
 package io.openbas.service;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.repository.RoleRepository;
 import org.junit.jupiter.api.Test;
 import org.mockito.InjectMocks;
@@ -7,7 +8,7 @@
 import org.springframework.boot.test.context.SpringBootTest;
 
 @SpringBootTest
-public class RoleServiceTest {
+public class RoleServiceTest extends IntegrationTest {
 
   @Mock RoleRepository roleRepository;
 
diff --git a/openbas-api/src/test/java/io/openbas/service/ScenarioServiceTest.java b/openbas-api/src/test/java/io/openbas/service/ScenarioServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/ScenarioServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/ScenarioServiceTest.java
@@ -9,6 +9,7 @@
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.mockito.Mockito.*;
 
+import io.openbas.IntegrationTest;
 import io.openbas.config.cache.LicenseCacheManager;
 import io.openbas.database.model.*;
 import io.openbas.database.model.Tag;
@@ -34,7 +35,7 @@
 
 @SpringBootTest
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
-class ScenarioServiceTest {
+class ScenarioServiceTest extends IntegrationTest {
 
   @Autowired ScenarioRepository scenarioRepository;
   @Autowired private TeamRepository teamRepository;
diff --git a/openbas-api/src/test/java/io/openbas/service/TagRuleServiceTest.java b/openbas-api/src/test/java/io/openbas/service/TagRuleServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/TagRuleServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/TagRuleServiceTest.java
@@ -5,6 +5,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.AssetGroup;
 import io.openbas.database.model.Tag;
 import io.openbas.database.model.TagRule;
@@ -25,7 +26,7 @@
 import org.springframework.boot.test.context.SpringBootTest;
 
 @SpringBootTest
-public class TagRuleServiceTest {
+public class TagRuleServiceTest extends IntegrationTest {
   private static final String TAG_RULE_ID = "tagruleid";
   private static final String TAG_RULE_ID_2 = "tagruleid2";
 
diff --git a/openbas-api/src/test/java/io/openbas/service/VariableServiceTest.java b/openbas-api/src/test/java/io/openbas/service/VariableServiceTest.java
--- a/openbas-api/src/test/java/io/openbas/service/VariableServiceTest.java
+++ b/openbas-api/src/test/java/io/openbas/service/VariableServiceTest.java
@@ -3,6 +3,7 @@
 import static org.junit.jupiter.api.Assertions.*;
 import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
 
+import io.openbas.IntegrationTest;
 import io.openbas.database.model.Exercise;
 import io.openbas.database.model.Variable;
 import io.openbas.database.model.Variable.VariableType;
@@ -16,7 +17,7 @@
 @SpringBootTest
 @TestInstance(PER_CLASS)
 @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class VariableServiceTest {
+public class VariableServiceTest extends IntegrationTest {
 
   @Autowired private VariableService variableService;
 
diff --git a/openbas-api/src/test/java/io/openbas/utils/mockUser/WithMockObserverUserSecurityContextFactory.java b/openbas-api/src/test/java/io/openbas/utils/mockUser/WithMockObserverUserSecurityContextFactory.java
--- a/openbas-api/src/test/java/io/openbas/utils/mockUser/WithMockObserverUserSecurityContextFactory.java
+++ b/openbas-api/src/test/java/io/openbas/utils/mockUser/WithMockObserverUserSecurityContextFactory.java
@@ -26,6 +26,7 @@ public class WithMockObserverUserSecurityContextFactory
     implements WithSecurityContextFactory<WithMockObserverUser> {
 
   public static final String MOCK_USER_OBSERVER_EMAIL = "observer@openbas.io";
+  public static final String MOCK_OBSERVER_GROUP = "Mock Observer group";
   @Autowired private GrantRepository grantRepository;
   @Autowired private GroupRepository groupRepository;
   @Autowired private UserRepository userRepository;
@@ -51,17 +52,18 @@ public void preDestroy() {
   }
 
   private void createObserverMockUser() {
-    if (this.userRepository.findByEmailIgnoreCase(MOCK_USER_OBSERVER_EMAIL).isPresent()) {
+    Optional<User> userOpt = this.userRepository.findByEmailIgnoreCase(MOCK_USER_OBSERVER_EMAIL);
+    if (userOpt.isPresent() && userOpt.get().isObserver()) {
       return;
     }
 
     // Create group
-    String groupName = "Observer group";
-    Optional<Group> groupOpt = this.groupRepository.findOne(GroupSpecification.fromName(groupName));
+    Optional<Group> groupOpt =
+        this.groupRepository.findOne(GroupSpecification.fromName(MOCK_OBSERVER_GROUP));
     Group group;
     if (groupOpt.isEmpty()) {
       Group newGroup = new Group();
-      newGroup.setName(groupName);
+      newGroup.setName(MOCK_OBSERVER_GROUP);
       newGroup.setScenariosDefaultGrants(List.of(OBSERVER));
       newGroup.setExercisesDefaultGrants(List.of(OBSERVER));
       group = this.groupRepository.save(newGroup);
@@ -74,12 +76,14 @@ private void createObserverMockUser() {
       group = groupOpt.get();
     }
     // Create user
-    Optional<User> userOpt = this.userRepository.findByEmailIgnoreCase(MOCK_USER_OBSERVER_EMAIL);
     if (userOpt.isEmpty()) {
       User user = new User();
       user.setGroups(List.of(group));
       user.setEmail(MOCK_USER_OBSERVER_EMAIL);
       this.userRepository.save(user);
+    } else if (!userOpt.get().isObserver()) {
+      userOpt.get().setGroups(List.of(group));
+      this.userRepository.save(userOpt.get());
     }
   }
 }
diff --git a/openbas-api/src/test/java/io/openbas/utils/mockUser/WithMockPlannerUserSecurityContextFactory.java b/openbas-api/src/test/java/io/openbas/utils/mockUser/WithMockPlannerUserSecurityContextFactory.java
--- a/openbas-api/src/test/java/io/openbas/utils/mockUser/WithMockPlannerUserSecurityContextFactory.java
+++ b/openbas-api/src/test/java/io/openbas/utils/mockUser/WithMockPlannerUserSecurityContextFactory.java
@@ -26,6 +26,7 @@ public class WithMockPlannerUserSecurityContextFactory
     implements WithSecurityContextFactory<WithMockPlannerUser> {
 
   public static final String MOCK_USER_PLANNER_EMAIL = "planner@openbas.io";
+  public static final String MOCK_PLANNER_GROUP = "Mock Planner group";
   @Autowired private GrantRepository grantRepository;
   @Autowired private GroupRepository groupRepository;
   @Autowired private UserRepository userRepository;
@@ -51,16 +52,17 @@ public void preDestroy() {
   }
 
   private void createPlannerMockUser() {
-    if (this.userRepository.findByEmailIgnoreCase(MOCK_USER_PLANNER_EMAIL).isPresent()) {
+    Optional<User> userOpt = this.userRepository.findByEmailIgnoreCase(MOCK_USER_PLANNER_EMAIL);
+    if (userOpt.isPresent() && userOpt.get().isPlanner()) {
       return;
     }
     // Create group
-    String groupName = "Planner group";
-    Optional<Group> groupOpt = this.groupRepository.findOne(GroupSpecification.fromName(groupName));
+    Optional<Group> groupOpt =
+        this.groupRepository.findOne(GroupSpecification.fromName(MOCK_PLANNER_GROUP));
     Group group;
     if (groupOpt.isEmpty()) {
       Group newGroup = new Group();
-      newGroup.setName(groupName);
+      newGroup.setName(MOCK_PLANNER_GROUP);
       newGroup.setScenariosDefaultGrants(List.of(PLANNER));
       newGroup.setExercisesDefaultGrants(List.of(PLANNER));
       group = this.groupRepository.save(newGroup);
@@ -73,12 +75,14 @@ private void createPlannerMockUser() {
       group = groupOpt.get();
     }
     // Create user
-    Optional<User> userOpt = this.userRepository.findByEmailIgnoreCase(MOCK_USER_PLANNER_EMAIL);
     if (userOpt.isEmpty()) {
       User user = new User();
       user.setGroups(List.of(group));
       user.setEmail(MOCK_USER_PLANNER_EMAIL);
       this.userRepository.save(user);
+    } else if (!userOpt.get().isPlanner()) {
+      userOpt.get().setGroups(List.of(group));
+      this.userRepository.save(userOpt.get());
     }
   }
 }
diff --git a/openbas-api/src/test/java/io/openbas/utilstest/DatabaseSnapshotManager.java b/openbas-api/src/test/java/io/openbas/utilstest/DatabaseSnapshotManager.java
new file mode 100644
--- /dev/null
+++ b/openbas-api/src/test/java/io/openbas/utilstest/DatabaseSnapshotManager.java
@@ -0,0 +1,199 @@
+package io.openbas.utilstest;
+
+import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import io.openbas.config.EngineConfig;
+import java.util.*;
+import java.util.stream.Collectors;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.event.EventListener;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+@RequiredArgsConstructor
+public class DatabaseSnapshotManager {
+
+  private final JdbcTemplate jdbcTemplate;
+  private final ElasticsearchClient esClient;
+  private final EngineConfig config;
+
+  private static final Map<String, List<Map<String, Object>>> startupData = new HashMap<>();
+  private static final List<String> TABLE_WITHOUT_RESTORATION = List.of("indexing_status");
+  private static List<String> tablesInOrder;
+
+  private static boolean snapshotCreated = false;
+
+  /** Create a snapshot of the database at startup */
+  @EventListener(ApplicationReadyEvent.class)
+  public void onApplicationReady() {
+    createSnapshot();
+  }
+
+  /** Create a snapshot of the database */
+  public void createSnapshot() {
+    synchronized (DatabaseSnapshotManager.class) {
+      if (snapshotCreated) return;
+
+      try {
+        List<String> tables =
+            jdbcTemplate.queryForList(
+                "SELECT tablename FROM pg_tables WHERE schemaname = 'public' ORDER BY tablename",
+                String.class);
+
+        for (String table : tables) {
+          List<Map<String, Object>> tableData = jdbcTemplate.queryForList("SELECT * FROM " + table);
+          startupData.put(table, new ArrayList<>(tableData));
+        }
+
+        snapshotCreated = true;
+        log.info("Startup snapshot created with JDBC ({} tables)", startupData.size());
+
+      } catch (Exception e) {
+        log.error("Failed to create startup snapshot: {}", e.getMessage(), e);
+      }
+    }
+  }
+
+  /** Restore database to the snapshot */
+  public void restoreToSnapshotState() {
+    if (!snapshotCreated) {
+      log.error("Snapshot not created yet, cannot restore!");
+      return;
+    }
+
+    try {
+      // Get tables order
+      if (tablesInOrder == null) {
+        tablesInOrder = getTablesInDependencyOrder();
+      }
+
+      cleanElasticsearchIndices();
+
+      // Deactivate FK for now
+      jdbcTemplate.execute("SET session_replication_role = 'replica';");
+
+      // Empty tables
+      List<String> reverseOrder = new ArrayList<>(tablesInOrder);
+      Collections.reverse(reverseOrder);
+      for (String table : reverseOrder) {
+        jdbcTemplate.execute("DELETE FROM " + table);
+      }
+
+      // Restore tables in the correct order
+      for (String table : tablesInOrder) {
+        if (!TABLE_WITHOUT_RESTORATION.contains(table)) {
+          restoreTableData(table);
+        }
+      }
+
+      // Activate FK back
+      jdbcTemplate.execute("SET session_replication_role = 'origin';");
+
+      log.info("Database restored to startup state via JDBC");
+
+    } catch (Exception e) {
+      throw new RuntimeException("Error restoring startup state", e);
+    }
+  }
+
+  /** Delete ES indices */
+  private void cleanElasticsearchIndices() {
+    if (esClient == null) {
+      return;
+    }
+
+    try {
+      esClient
+          .indices()
+          .delete(
+              d ->
+                  d.index(config.getIndexPrefix() + "_*")
+                      .ignoreUnavailable(true)
+                      .allowNoIndices(true));
+      log.info("Deleted all openbas_* Elasticsearch indices");
+    } catch (Exception e) {
+      log.warn("Could not clean Elasticsearch: {}", e.getMessage());
+    }
+  }
+
+  /**
+   * Get the list of tables in dependency order
+   *
+   * @return the list of tables in dependency order
+   */
+  private List<String> getTablesInDependencyOrder() {
+    // Get all the dependencies
+    List<Map<String, Object>> dependencies =
+        jdbcTemplate.queryForList(
+            """
+                    SELECT
+                        tc.table_name as dependent_table,
+                        ccu.table_name as referenced_table
+                    FROM information_schema.table_constraints tc
+                    JOIN information_schema.key_column_usage kcu
+                        ON tc.constraint_name = kcu.constraint_name
+                    JOIN information_schema.constraint_column_usage ccu
+                        ON ccu.constraint_name = tc.constraint_name
+                    WHERE tc.constraint_type = 'FOREIGN KEY'
+                        AND tc.table_schema = 'public'
+                        AND tc.table_name != ccu.table_name
+                    """);
+
+    // Get all tables
+    Set<String> allTables =
+        new HashSet<>(
+            jdbcTemplate.queryForList(
+                "SELECT tablename FROM pg_tables WHERE schemaname = 'public'", String.class));
+
+    // Build dependency graph
+    Map<String, Set<String>> deps = new HashMap<>();
+    for (String table : allTables) {
+      deps.put(table, new HashSet<>());
+    }
+
+    for (Map<String, Object> dep : dependencies) {
+      String dependent = (String) dep.get("dependent_table");
+      String referenced = (String) dep.get("referenced_table");
+      deps.get(dependent).add(referenced);
+    }
+
+    // Topological sort
+    List<String> result = new ArrayList<>();
+    Set<String> processed = new HashSet<>();
+
+    while (processed.size() < allTables.size()) {
+      for (String table : allTables) {
+        if (!processed.contains(table)) {
+          // Check if the table has already been added
+          if (processed.containsAll(deps.get(table))) {
+            result.add(table);
+            processed.add(table);
+          }
+        }
+      }
+    }
+
+    return result;
+  }
+
+  /**
+   * Restore the data of a specific table
+   *
+   * @param table the table to restore
+   */
+  private void restoreTableData(String table) {
+    List<Map<String, Object>> data = startupData.get(table);
+    if (data == null || data.isEmpty()) return;
+
+    for (Map<String, Object> row : data) {
+      String columns = String.join(", ", row.keySet());
+      String placeholders = row.keySet().stream().map(k -> "?").collect(Collectors.joining(", "));
+
+      String sql = "INSERT INTO " + table + " (" + columns + ") VALUES (" + placeholders + ")";
+      jdbcTemplate.update(sql, row.values().toArray());
+    }
+  }
+}
diff --git a/openbas-api/src/test/java/io/openbas/utilstest/StartupSnapshotTestListener.java b/openbas-api/src/test/java/io/openbas/utilstest/StartupSnapshotTestListener.java
new file mode 100644
--- /dev/null
+++ b/openbas-api/src/test/java/io/openbas/utilstest/StartupSnapshotTestListener.java
@@ -0,0 +1,29 @@
+package io.openbas.utilstest;
+
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Nested;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.TestContext;
+import org.springframework.test.context.TestExecutionListener;
+
+@Slf4j
+public class StartupSnapshotTestListener implements TestExecutionListener {
+
+  @Override
+  public void afterTestClass(TestContext testContext) throws Exception {
+    Class<?> testClass = testContext.getTestClass();
+
+    // Ignoring nested classes
+    if (testClass.isAnnotationPresent(Nested.class)) {
+      log.info("Skipping restore for @Nested class: {}", testClass.getSimpleName());
+      return;
+    }
+
+    // Restoring data to startup state
+    ApplicationContext context = testContext.getApplicationContext();
+    DatabaseSnapshotManager snapshotManager = context.getBean(DatabaseSnapshotManager.class);
+    snapshotManager.restoreToSnapshotState();
+
+    log.info("Restore completed after main test class: {}", testClass.getSimpleName());
+  }
+}
diff --git a/openbas-api/src/test/resources/application.properties b/openbas-api/src/test/resources/application.properties
--- a/openbas-api/src/test/resources/application.properties
+++ b/openbas-api/src/test/resources/application.properties
@@ -133,4 +133,9 @@ collector.mitre-attack.enable=false
 ## Collector Caldera
 collector.caldera.enable=false
 
+executor.tanium.id=fbcce3cc-9cd3-4fdb-b451-1c90f4ae035d
+executor.crowdstrike.id=2a16dcc4-55ac-40fc-8110-d5968a46cdd1
+executor.caldera.id=2a16dcc4-55ac-40fc-8110-d5968a46cdd1
+injector.caldera.id=2a16dcc4-55ac-40fc-8110-d5968a46cdd1
+
 spring.datasource.hikari.maximum-pool-size=2
\ No newline at end of file
diff --git a/openbas-api/src/test/resources/junit-platform.properties b/openbas-api/src/test/resources/junit-platform.properties
new file mode 100644
--- /dev/null
+++ b/openbas-api/src/test/resources/junit-platform.properties
@@ -0,0 +1 @@
+junit.jupiter.testclass.order.default=org.junit.jupiter.api.ClassOrderer$ClassName
\ No newline at end of file