diff --git a/openbas-api/pom.xml b/openbas-api/pom.xml index 7011897a23..d83827648c 100644 --- a/openbas-api/pom.xml +++ b/openbas-api/pom.xml @@ -70,7 +70,7 @@ org.springframework.boot spring-boot-starter-security - 3.2.11 + 3.4.0 org.springframework.boot @@ -79,7 +79,7 @@ org.springframework.boot spring-boot-starter-oauth2-client - 3.2.11 + 3.4.0 org.springframework.boot diff --git a/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java b/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java index 4597c01410..cf888e3a51 100644 --- a/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java +++ b/openbas-api/src/test/java/io/openbas/injects/InjectCrudTest.java @@ -1,50 +1,55 @@ package io.openbas.injects; import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT; +import static io.openbas.utils.fixtures.ExerciseFixture.getExercise; +import static io.openbas.utils.fixtures.InjectFixture.createDefaultInjectEmail; import static org.junit.jupiter.api.Assertions.assertNotNull; +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.Inject; -import io.openbas.database.repository.ExerciseRepository; +import io.openbas.database.model.InjectorContract; import io.openbas.database.repository.InjectRepository; import io.openbas.database.repository.InjectorContractRepository; -import java.util.List; +import io.openbas.rest.exercise.service.ExerciseService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; -@SpringBootTest -class InjectCrudTest { +@TestInstance(PER_CLASS) +class InjectCrudTest extends IntegrationTest { + @Autowired private InjectorContractRepository injectorContractRepository; @Autowired private InjectRepository injectRepository; - @Autowired private ExerciseRepository exerciseRepository; - - @Autowired private InjectorContractRepository injectorContractRepository; + @Autowired private ExerciseService exerciseService; @DisplayName("Test inject creation with non null depends duration") @Test + @Transactional void createInjectSuccess() { // -- PREPARE -- - Exercise exercise = new Exercise(); - exercise.setName("Exercise name"); - exercise.setFrom("test@test.com"); - exercise.setReplyTos(List.of("test@test.com")); - Exercise exerciseCreated = this.exerciseRepository.save(exercise); - Inject inject = new Inject(); - inject.setTitle("test"); - inject.setInjectorContract( - this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow()); - inject.setExercise(exerciseCreated); - inject.setDependsDuration(0L); + Exercise exercise = this.exerciseService.createExercise(getExercise()); + assertNotNull(exercise.getId(), "Exercise should be successfully created"); + + InjectorContract contract = + injectorContractRepository + .findById(EMAIL_DEFAULT) + .orElseThrow(() -> new IllegalStateException("Injector contract not found.")); + Inject inject = createDefaultInjectEmail(contract); + inject.setExercise(exercise); // -- EXECUTE -- Inject injectCreated = this.injectRepository.save(inject); - assertNotNull(injectCreated); + assertNotNull(injectCreated.getId(), "Inject should be successfully created"); - // -- CLEAN -- - this.exerciseRepository.delete(exercise); - this.injectRepository.delete(inject); + // -- VALIDATE -- + assertNotNull(injectCreated.getExercise(), "Inject should reference a valid Exercise."); + assertNotNull( + injectRepository.findById(injectCreated.getId()), + "Inject should be persisted in the database."); } } diff --git a/openbas-api/src/test/java/io/openbas/rest/AtomicTestingApiTest.java b/openbas-api/src/test/java/io/openbas/rest/AtomicTestingApiTest.java index 473d32247f..ad345c0a68 100644 --- a/openbas-api/src/test/java/io/openbas/rest/AtomicTestingApiTest.java +++ b/openbas-api/src/test/java/io/openbas/rest/AtomicTestingApiTest.java @@ -42,10 +42,10 @@ public class AtomicTestingApiTest extends IntegrationTest { @BeforeAll void beforeAll() { INJECTOR_CONTRACT = injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow(); - Inject injectWithoutPayload = InjectFixture.getInjectForEmailContract(INJECTOR_CONTRACT); + Inject injectWithoutPayload = InjectFixture.createDefaultInjectEmail(INJECTOR_CONTRACT); INJECT_WITHOUT_STATUS = injectRepository.save(injectWithoutPayload); - Inject injectWithPayload = InjectFixture.getInjectForEmailContract(INJECTOR_CONTRACT); + Inject injectWithPayload = InjectFixture.createDefaultInjectEmail(INJECTOR_CONTRACT); INJECT_WITH_STATUS_AND_COMMAND_LINES = injectRepository.save(injectWithPayload); InjectStatus injectStatus = InjectStatusFixture.createDefaultInjectStatus(); injectStatus.setInject(injectWithPayload); diff --git a/openbas-api/src/test/java/io/openbas/rest/ChallengeApiTest.java b/openbas-api/src/test/java/io/openbas/rest/ChallengeApiTest.java index eaf1ce1b29..7935e87115 100644 --- a/openbas-api/src/test/java/io/openbas/rest/ChallengeApiTest.java +++ b/openbas-api/src/test/java/io/openbas/rest/ChallengeApiTest.java @@ -28,8 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; -@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestInstance(PER_CLASS) class ChallengeApiTest extends IntegrationTest { @@ -41,50 +41,34 @@ class ChallengeApiTest extends IntegrationTest { @Autowired private InjectorContractRepository injectorContractRepository; @Resource private ObjectMapper objectMapper; - private static String SCENARIO_ID; - private static String CHALLENGE_ID; - private static String INJECT_ID; - - @AfterAll - void afterAll() { - this.scenarioService.deleteScenario(SCENARIO_ID); - this.challengeRepository.deleteById(CHALLENGE_ID); - this.injectRepository.deleteById(INJECT_ID); - } - // -- SCENARIOS -- @DisplayName("Retrieve challenges for scenario") @Test - @Order(1) + @Transactional @WithMockObserverUser void retrieveChallengesVariableForScenarioTest() throws Exception { // -- PREPARE -- - Scenario scenario = createDefaultCrisisScenario(); - Scenario scenarioCreated = this.scenarioService.createScenario(scenario); + Scenario scenarioCreated = this.scenarioService.createScenario(createDefaultCrisisScenario()); assertNotNull(scenarioCreated, "Scenario should be successfully created"); - SCENARIO_ID = scenarioCreated.getId(); - Challenge challenge = createDefaultChallenge(); - Challenge challengeCreated = this.challengeRepository.save(challenge); + Challenge challengeCreated = this.challengeRepository.save(createDefaultChallenge()); assertNotNull(challengeCreated, "Challenge should be successfully created"); - CHALLENGE_ID = challengeCreated.getId(); Inject inject = createDefaultInjectChallenge( this.injectorContractRepository.findById(CHALLENGE_PUBLISH).orElseThrow(), this.objectMapper, - List.of(CHALLENGE_ID)); + List.of(challengeCreated.getId())); inject.setScenario(scenarioCreated); Inject injectCreated = this.injectRepository.save(inject); assertNotNull(injectCreated, "Inject should be successfully created"); - INJECT_ID = injectCreated.getId(); // -- EXECUTE -- String response = this.mvc .perform( - get(SCENARIO_URI + "/" + SCENARIO_ID + "/challenges") + get(SCENARIO_URI + "/" + scenarioCreated.getId() + "/challenges") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().is2xxSuccessful()) .andReturn() @@ -94,7 +78,7 @@ void retrieveChallengesVariableForScenarioTest() throws Exception { // -- ASSERT -- assertNotNull(response, "Response should not be null"); assertEquals( - challenge.getName(), + challengeCreated.getName(), JsonPath.read(response, "$[0].challenge_name"), "Challenge name should match the expected value"); } diff --git a/openbas-api/src/test/java/io/openbas/rest/InjectApiTest.java b/openbas-api/src/test/java/io/openbas/rest/InjectApiTest.java index b3b8d89376..eb9f0b123f 100644 --- a/openbas-api/src/test/java/io/openbas/rest/InjectApiTest.java +++ b/openbas-api/src/test/java/io/openbas/rest/InjectApiTest.java @@ -7,7 +7,7 @@ import static io.openbas.rest.inject.InjectApi.INJECT_URI; import static io.openbas.rest.scenario.ScenarioApi.SCENARIO_URI; import static io.openbas.utils.JsonUtils.asJsonString; -import static io.openbas.utils.fixtures.InjectFixture.getInjectForEmailContract; +import static io.openbas.utils.fixtures.InjectFixture.createDefaultInjectEmail; import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.mockito.Mockito.*; @@ -389,7 +389,7 @@ void executeEmailInjectForExerciseTest() throws Exception { // -- PREPARE -- InjectorContract injectorContract = this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow(); - Inject inject = getInjectForEmailContract(injectorContract); + Inject inject = createDefaultInjectEmail(injectorContract); User user = userRepository.findById(currentUser().getId()).orElseThrow(); DirectInjectInput input = new DirectInjectInput(); input.setTitle(inject.getTitle()); @@ -450,7 +450,7 @@ void executeEmailInjectForExerciseWithNoTeam() throws Exception { // -- PREPARE -- InjectorContract injectorContract = this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow(); - Inject inject = getInjectForEmailContract(injectorContract); + Inject inject = createDefaultInjectEmail(injectorContract); DirectInjectInput input = new DirectInjectInput(); input.setTitle(inject.getTitle()); @@ -489,7 +489,7 @@ void executeEmailInjectForExerciseWithNoContentTest() throws Exception { // -- PREPARE -- InjectorContract injectorContract = this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow(); - Inject inject = getInjectForEmailContract(injectorContract); + Inject inject = createDefaultInjectEmail(injectorContract); DirectInjectInput input = new DirectInjectInput(); input.setTitle(inject.getTitle()); diff --git a/openbas-api/src/test/java/io/openbas/rest/PayloadApiTest.java b/openbas-api/src/test/java/io/openbas/rest/PayloadApiTest.java index e2d74b401b..d1ad2cd498 100644 --- a/openbas-api/src/test/java/io/openbas/rest/PayloadApiTest.java +++ b/openbas-api/src/test/java/io/openbas/rest/PayloadApiTest.java @@ -31,6 +31,7 @@ import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; @TestInstance(PER_CLASS) class PayloadApiTest extends IntegrationTest { @@ -52,11 +53,11 @@ void beforeAll() { @AfterAll void afterAll() { this.documentRepository.deleteAll(List.of(EXECUTABLE_FILE)); - this.payloadRepository.deleteAll(); } @Test @DisplayName("Create Payload") + @Transactional @WithMockAdminUser void createExecutablePayload() throws Exception { PayloadCreateInput input = PayloadInputFixture.createDefaultPayloadCreateInputForExecutable(); @@ -77,6 +78,7 @@ void createExecutablePayload() throws Exception { @Test @DisplayName("Creating a Payload with a null as arch should fail") + @Transactional @WithMockAdminUser void createPayloadWithNullArch() throws Exception { PayloadCreateInput input = PayloadInputFixture.createDefaultPayloadCreateInputForCommandLine(); @@ -89,6 +91,7 @@ void createPayloadWithNullArch() throws Exception { @Test @DisplayName( "Creating an executable Payload with an arch different from x86_64 or arm64 should fail") + @Transactional @WithMockAdminUser void createExecutablePayloadWithoutArch() throws Exception { PayloadCreateInput input = PayloadInputFixture.createDefaultPayloadCreateInputForExecutable(); @@ -107,6 +110,7 @@ void createExecutablePayloadWithoutArch() throws Exception { @Test @DisplayName("Update Executable Payload") + @Transactional @WithMockAdminUser void updateExecutablePayload() throws Exception { PayloadCreateInput createInput = @@ -147,6 +151,7 @@ void updateExecutablePayload() throws Exception { @Test @DisplayName("Updating an Executed Payload with null as arch should fail") + @Transactional @WithMockAdminUser void updateExecutablePayloadWithoutArch() throws Exception { PayloadCreateInput createInput = @@ -183,6 +188,7 @@ void updateExecutablePayloadWithoutArch() throws Exception { @Test @DisplayName("Updating a Payload no Executable without arch should set ALL_ARCHITECTURES") + @Transactional @WithMockAdminUser void updatePayloadNoExecutableWithoutArch() throws Exception { PayloadCreateInput createInput = @@ -217,6 +223,7 @@ void updatePayloadNoExecutableWithoutArch() throws Exception { @Test @DisplayName("Upsert architecture of a Payload") + @Transactional @WithMockPlannerUser void upsertCommandPayloadToValidateArchitecture() throws Exception { Payload payload = payloadRepository.save(PayloadFixture.createDefaultCommand()); @@ -252,6 +259,7 @@ void upsertCommandPayloadToValidateArchitecture() throws Exception { @Test @DisplayName("Creating Command Line payload with both set executor and content should succeed") + @Transactional @WithMockAdminUser void createCommandLinePayloadWithBothSetExecutorAndContent() throws Exception { PayloadCreateInput createInput = @@ -270,6 +278,7 @@ void createCommandLinePayloadWithBothSetExecutorAndContent() throws Exception { @Test @DisplayName( "Creating Command Line payload with both null cleanup executor and command should succeed") + @Transactional @WithMockAdminUser void createCommandLinePayloadWithBothNullCleanupExecutorAndCommand() throws Exception { PayloadCreateInput createInput = @@ -288,6 +297,7 @@ void createCommandLinePayloadWithBothNullCleanupExecutorAndCommand() throws Exce @Test @DisplayName( "Creating Command Line payload with both set cleanup executor and command should succeed") + @Transactional @WithMockAdminUser void createCommandLinePayloadWithBothSetCleanupExecutorAndCommand() throws Exception { PayloadCreateInput createInput = @@ -306,6 +316,7 @@ void createCommandLinePayloadWithBothSetCleanupExecutorAndCommand() throws Excep @Test @DisplayName( "Creating Command Line payload with only set cleanup executor and null command should fail") + @Transactional @WithMockAdminUser void createCommandLinePayloadWithOnlySetCleanupExecutorAndNullCommand() throws Exception { PayloadCreateInput createInput = @@ -324,6 +335,7 @@ void createCommandLinePayloadWithOnlySetCleanupExecutorAndNullCommand() throws E @Test @DisplayName( "Creating Command Line payload with only set cleanup command and null executor should fail") + @Transactional @WithMockAdminUser void createCommandLinePayloadWithOnlySetCommandAndNullExecutor() throws Exception { PayloadCreateInput createInput = @@ -342,6 +354,7 @@ void createCommandLinePayloadWithOnlySetCommandAndNullExecutor() throws Exceptio @Test @DisplayName( "Updating Command Line payload with only set cleanup command and null executor should fail") + @Transactional @WithMockAdminUser void updateCommandLinePayloadWithOnlySetCommandAndNullExecutor() throws Exception { PayloadCreateInput createInput = @@ -380,6 +393,7 @@ void updateCommandLinePayloadWithOnlySetCommandAndNullExecutor() throws Exceptio @Test @DisplayName( "Duplicating a Community and Verified Payload should result in a Manual and Unverified Payload") + @Transactional @WithMockAdminUser void duplicateExecutablePayload() throws Exception { PayloadCreateInput createInput = @@ -420,6 +434,7 @@ void duplicateExecutablePayload() throws Exception { @Test @DisplayName("Process Deprecated Payloads") + @Transactional @WithMockAdminUser void processDeprecatedPayloads() throws Exception { String collectorId = "039eee9b-b95d-4b11-95bb-a9ac233f1738"; diff --git a/openbas-api/src/test/java/io/openbas/rest/ScenarioInjectApiSearchTest.java b/openbas-api/src/test/java/io/openbas/rest/ScenarioInjectApiSearchTest.java index a38cafd078..13bc08052a 100644 --- a/openbas-api/src/test/java/io/openbas/rest/ScenarioInjectApiSearchTest.java +++ b/openbas-api/src/test/java/io/openbas/rest/ScenarioInjectApiSearchTest.java @@ -4,7 +4,7 @@ import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT; import static io.openbas.rest.scenario.ScenarioApi.SCENARIO_URI; import static io.openbas.utils.JsonUtils.asJsonString; -import static io.openbas.utils.fixtures.InjectFixture.getInjectForEmailContract; +import static io.openbas.utils.fixtures.InjectFixture.createDefaultInjectEmail; import static io.openbas.utils.fixtures.ScenarioFixture.createDefaultCrisisScenario; import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -52,14 +52,14 @@ void beforeAll() { Scenario scenarioSaved = this.scenarioRepository.save(scenario); SCENARIO_ID = scenarioSaved.getId(); - Inject injectDefaultEmail = getInjectForEmailContract(injectorContract); + Inject injectDefaultEmail = createDefaultInjectEmail(injectorContract); injectDefaultEmail.setScenario(scenarioSaved); injectDefaultEmail.setTitle("Inject default email"); injectDefaultEmail.setDependsDuration(1L); Inject injectDefaultEmailSaved = this.injectRepository.save(injectDefaultEmail); INJECT_IDS.add(injectDefaultEmailSaved.getId()); - Inject injectDefaultGlobal = getInjectForEmailContract(injectorContract); + Inject injectDefaultGlobal = createDefaultInjectEmail(injectorContract); injectDefaultGlobal.setScenario(scenarioSaved); injectDefaultGlobal.setTitle("Inject global email"); Inject injectDefaultGlobalSaved = this.injectRepository.save(injectDefaultGlobal); 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 index d8db098629..b6649a7424 100644 --- a/openbas-api/src/test/java/io/openbas/rest/exercise/ExerciseApiStatusTest.java +++ b/openbas-api/src/test/java/io/openbas/rest/exercise/ExerciseApiStatusTest.java @@ -3,7 +3,7 @@ import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT; import static io.openbas.rest.exercise.ExerciseApi.EXERCISE_URI; import static io.openbas.utils.JsonUtils.asJsonString; -import static io.openbas.utils.fixtures.InjectFixture.getInjectForEmailContract; +import static io.openbas.utils.fixtures.InjectFixture.createDefaultInjectEmail; import static java.time.Instant.now; import static java.time.temporal.ChronoUnit.MINUTES; import static org.junit.jupiter.api.Assertions.*; @@ -92,26 +92,26 @@ void beforeAll() { InjectorContract injectorContract = this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow(); - Inject inject1 = getInjectForEmailContract(injectorContract); + Inject inject1 = createDefaultInjectEmail(injectorContract); EmailContent content = new EmailContent(); content.setSubject("Subject email"); content.setBody("A body"); inject1.setContent(this.mapper.valueToTree(content)); inject1.setExercise(scheduledExercise); - Inject inject2 = getInjectForEmailContract(injectorContract); + Inject inject2 = createDefaultInjectEmail(injectorContract); inject2.setContent(this.mapper.valueToTree(content)); inject2.setExercise(runningExercise); - Inject inject3 = getInjectForEmailContract(injectorContract); + Inject inject3 = createDefaultInjectEmail(injectorContract); inject3.setContent(this.mapper.valueToTree(content)); inject3.setExercise(pausedExercise); - Inject inject4 = getInjectForEmailContract(injectorContract); + Inject inject4 = createDefaultInjectEmail(injectorContract); inject4.setContent(this.mapper.valueToTree(content)); inject4.setExercise(canceledExercise); - Inject inject5 = getInjectForEmailContract(injectorContract); + Inject inject5 = createDefaultInjectEmail(injectorContract); inject5.setContent(this.mapper.valueToTree(content)); inject5.setExercise(finishedExercise); 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 index 71b526ea3a..6a186aa981 100644 --- a/openbas-api/src/test/java/io/openbas/rest/scenario/ScenarioToExerciseServiceTest.java +++ b/openbas-api/src/test/java/io/openbas/rest/scenario/ScenarioToExerciseServiceTest.java @@ -4,7 +4,7 @@ import static io.openbas.utils.fixtures.ArticleFixture.ARTICLE_NAME; import static io.openbas.utils.fixtures.ArticleFixture.getArticle; import static io.openbas.utils.fixtures.DocumentFixture.getDocumentJpeg; -import static io.openbas.utils.fixtures.InjectFixture.getInjectForEmailContract; +import static io.openbas.utils.fixtures.InjectFixture.createDefaultInjectEmail; import static io.openbas.utils.fixtures.ObjectiveFixture.OBJECTIVE_NAME; import static io.openbas.utils.fixtures.ObjectiveFixture.getObjective; import static io.openbas.utils.fixtures.TagFixture.getTag; @@ -211,7 +211,7 @@ void scenarioToExerciseTest() { // Inject Inject inject = - getInjectForEmailContract( + createDefaultInjectEmail( this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow()); inject.setTeams( new ArrayList<>() { diff --git a/openbas-api/src/test/java/io/openbas/service/ExerciseServiceIntegrationTest.java b/openbas-api/src/test/java/io/openbas/service/ExerciseServiceIntegrationTest.java index afa6470179..27c89d7862 100644 --- a/openbas-api/src/test/java/io/openbas/service/ExerciseServiceIntegrationTest.java +++ b/openbas-api/src/test/java/io/openbas/service/ExerciseServiceIntegrationTest.java @@ -3,7 +3,7 @@ import static io.openbas.database.specification.TeamSpecification.fromExercise; import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT; import static io.openbas.utils.fixtures.ExerciseFixture.getExercise; -import static io.openbas.utils.fixtures.InjectFixture.getInjectForEmailContract; +import static io.openbas.utils.fixtures.InjectFixture.createDefaultInjectEmail; import static io.openbas.utils.fixtures.TeamFixture.getTeam; import static io.openbas.utils.fixtures.UserFixture.getUser; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -134,7 +134,7 @@ void testRemoveTeams() { InjectorContract injectorContract = this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow(); - Inject injectDefaultEmail = getInjectForEmailContract(injectorContract); + Inject injectDefaultEmail = createDefaultInjectEmail(injectorContract); injectDefaultEmail.setExercise(exerciseSaved); injectDefaultEmail.setTeams(List.of(teamSaved)); Inject injectDefaultEmailSaved = this.injectRepository.saveAndFlush(injectDefaultEmail); diff --git a/openbas-api/src/test/java/io/openbas/service/ScenarioServiceTest.java b/openbas-api/src/test/java/io/openbas/service/ScenarioServiceTest.java index ffde237c0e..296bd4b037 100644 --- a/openbas-api/src/test/java/io/openbas/service/ScenarioServiceTest.java +++ b/openbas-api/src/test/java/io/openbas/service/ScenarioServiceTest.java @@ -2,7 +2,7 @@ import static io.openbas.database.specification.TeamSpecification.fromScenario; import static io.openbas.injectors.email.EmailContract.EMAIL_DEFAULT; -import static io.openbas.utils.fixtures.InjectFixture.getInjectForEmailContract; +import static io.openbas.utils.fixtures.InjectFixture.createDefaultInjectEmail; import static io.openbas.utils.fixtures.TeamFixture.getTeam; import static io.openbas.utils.fixtures.UserFixture.getUser; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -156,7 +156,7 @@ void testRemoveTeams() { InjectorContract injectorContract = this.injectorContractRepository.findById(EMAIL_DEFAULT).orElseThrow(); - Inject injectDefaultEmail = getInjectForEmailContract(injectorContract); + Inject injectDefaultEmail = createDefaultInjectEmail(injectorContract); injectDefaultEmail.setScenario(scenarioSaved); injectDefaultEmail.setTeams(List.of(teamSaved)); Inject injectDefaultEmailSaved = this.injectRepository.saveAndFlush(injectDefaultEmail); diff --git a/openbas-api/src/test/java/io/openbas/utils/fixtures/InjectFixture.java b/openbas-api/src/test/java/io/openbas/utils/fixtures/InjectFixture.java index 944696410c..d2d2cd8003 100644 --- a/openbas-api/src/test/java/io/openbas/utils/fixtures/InjectFixture.java +++ b/openbas-api/src/test/java/io/openbas/utils/fixtures/InjectFixture.java @@ -15,14 +15,14 @@ public class InjectFixture { private static Inject createInject(InjectorContract injectorContract, String title) { Inject inject = new Inject(); - inject.setTitle(INJECT_EMAIL_NAME); + inject.setTitle(title); inject.setInjectorContract(injectorContract); inject.setEnabled(true); inject.setDependsDuration(0L); return inject; } - public static Inject getInjectForEmailContract(InjectorContract injectorContract) { + public static Inject createDefaultInjectEmail(InjectorContract injectorContract) { return createInject(injectorContract, INJECT_EMAIL_NAME); } diff --git a/pom.xml b/pom.xml index c2c7639093..6e21f5c6b9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 3.3.5 + 3.4.0 io.openbas