Skip to content

Commit 27c4cb7

Browse files
Merge remote-tracking branch 'origin/master' into release/current
# Conflicts: # .drone.yml # openbas-api/src/test/java/io/openbas/rest/inject/InjectImportTest.java
2 parents 0ce3c15 + 895f90e commit 27c4cb7

File tree

61 files changed

+380
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+380
-104
lines changed

.drone.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
kind: pipeline
33
name: openbas-tests
44

5+
node:
6+
env: kubernetes
7+
58
steps:
69
- name: Runner information
710
image: alpine:3.22
@@ -16,12 +19,13 @@ steps:
1619
MINIO_PORT: 9000
1720
ENGINE_URL: http://elastic:9200
1821
commands:
22+
- sleep 60
1923
- mvn clean install -q -DskipTests
2024
- mvn spotless:check
2125
- cd openbas-api
22-
- mvn test -q
26+
- mvn test
2327
- cd ../openbas-framework
24-
- mvn test -q
28+
- mvn test
2529

2630
- name: frontend-tests
2731
image: node:22.17.1-alpine
@@ -84,6 +88,9 @@ steps:
8488

8589
- name: frontend-api-types
8690
image: node:22.17.1
91+
volumes:
92+
- name: cache-node-frontend-api-types
93+
path: /drone/src/openbas-front/node_modules
8794
commands:
8895
- apt update
8996
- apt -y install netcat-traditional
@@ -188,4 +195,4 @@ services:
188195
environment:
189196
discovery.type: single-node
190197
xpack.security.enabled: false
191-
ES_JAVA_OPTS: -Xms2g -Xmx2g
198+
ES_JAVA_OPTS: -Xms4g -Xmx4g

openbas-api/src/main/java/io/openbas/executors/crowdstrike/service/CrowdStrikeExecutorService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ public CrowdStrikeExecutorService(
9191
Endpoint.PLATFORM_TYPE.MacOS.name()
9292
});
9393
} else {
94-
executorService.remove(config.getId());
94+
if (executor != null) {
95+
executorService.remove(config.getId());
96+
}
9597
}
9698
} catch (Exception e) {
9799
log.error(String.format("Error creating CrowdStrike executor: %s", e.getMessage()), e);

openbas-api/src/main/java/io/openbas/helper/RabbitMQHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class RabbitMQHelper {
4444
*/
4545
public static String getRabbitMQVersion(RabbitmqConfig rabbitmqConfig) {
4646
// If we already have the version, we don't need to get it again
47-
if (rabbitMQVersion == null) {
47+
if (rabbitMQVersion == null && rabbitmqConfig.getHostname() != null) {
4848
// Init the rabbit MQ management api overview url
4949
String uri =
5050
"http://"

openbas-api/src/main/resources/logback-spring.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<configuration>
2-
<springProfile name="dev">
2+
<springProfile name="dev | test">
33
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
44
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
55
<encoder>
@@ -11,7 +11,7 @@
1111
<appender-ref ref="STDOUT" />
1212
</root>
1313
</springProfile>
14-
<springProfile name="!dev">
14+
<springProfile name="!(dev | test)">
1515
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
1616
<appender name="jsonEncoder" class="ch.qos.logback.core.ConsoleAppender">
1717
<encoder class="ch.qos.logback.classic.encoder.JsonEncoder">
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package io.openbas;
22

3+
import io.openbas.utilstest.StartupSnapshotTestListener;
34
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
45
import org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrint;
56
import org.springframework.boot.test.context.SpringBootTest;
7+
import org.springframework.test.context.TestExecutionListeners;
68

79
@AutoConfigureMockMvc(print = MockMvcPrint.SYSTEM_ERR)
810
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
11+
@TestExecutionListeners(
12+
value = {StartupSnapshotTestListener.class},
13+
mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS)
914
public abstract class IntegrationTest {}

openbas-api/src/test/java/io/openbas/config/OpenCTIConfigTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.assertj.core.api.Assertions.assertThat;
44

5+
import io.openbas.IntegrationTest;
56
import io.openbas.injectors.opencti.config.OpenCTIConfig;
67
import io.openbas.utils.mockConfig.WithMockOpenCTIConfig;
78
import org.junit.jupiter.api.DisplayName;
@@ -12,7 +13,8 @@
1213

1314
@SpringBootTest
1415
@DisplayName("OpenCTIConfig tests")
15-
public class OpenCTIConfigTest {
16+
public class OpenCTIConfigTest extends IntegrationTest {
17+
1618
@Nested
1719
@WithMockOpenCTIConfig(url = "public_url")
1820
@DisplayName("When setting only the public URL")

openbas-api/src/test/java/io/openbas/database/model/InjectTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
44

5+
import io.openbas.IntegrationTest;
56
import io.openbas.utils.fixtures.ExerciseFixture;
67
import io.openbas.utils.fixtures.InjectFixture;
78
import io.openbas.utils.fixtures.PauseFixture;
@@ -17,7 +18,7 @@
1718
@SpringBootTest
1819
@TestInstance(PER_CLASS)
1920
@Transactional
20-
public class InjectTest {
21+
public class InjectTest extends IntegrationTest {
2122

2223
@Autowired private ExerciseComposer exerciseComposer;
2324
@Autowired private InjectComposer injectComposer;

openbas-api/src/test/java/io/openbas/database/model/SimulationTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22

33
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
44

5+
import io.openbas.IntegrationTest;
56
import io.openbas.database.repository.ExerciseRepository;
67
import io.openbas.utils.fixtures.ExerciseFixture;
78
import io.openbas.utils.fixtures.composers.ExerciseComposer;
89
import jakarta.persistence.EntityManager;
910
import java.time.Instant;
10-
import org.junit.jupiter.api.Assertions;
11-
import org.junit.jupiter.api.DisplayName;
12-
import org.junit.jupiter.api.Test;
13-
import org.junit.jupiter.api.TestInstance;
11+
import org.junit.jupiter.api.*;
1412
import org.springframework.beans.factory.annotation.Autowired;
1513
import org.springframework.boot.test.context.SpringBootTest;
1614
import org.springframework.transaction.annotation.Transactional;
1715

1816
@SpringBootTest
1917
@TestInstance(PER_CLASS)
2018
@Transactional
21-
class SimulationTest {
19+
class SimulationTest extends IntegrationTest {
2220
@Autowired private ExerciseComposer exerciseComposer;
2321
@Autowired private ExerciseRepository exerciseRepository;
2422
@Autowired private EntityManager entityManager;

openbas-api/src/test/java/io/openbas/helper/InjectHelperTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.junit.jupiter.api.Assertions.assertEquals;
66
import static org.junit.jupiter.api.Assertions.assertFalse;
77

8+
import io.openbas.IntegrationTest;
89
import io.openbas.database.model.*;
910
import io.openbas.database.repository.*;
1011
import io.openbas.execution.ExecutableInject;
@@ -18,7 +19,7 @@
1819
import org.springframework.boot.test.context.SpringBootTest;
1920

2021
@SpringBootTest
21-
public class InjectHelperTest {
22+
public class InjectHelperTest extends IntegrationTest {
2223

2324
public static final String USER_EMAIL = "[email protected]";
2425
@Autowired private InjectHelper injectHelper;

openbas-api/src/test/java/io/openbas/importer/V1_DataImporterTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.fasterxml.jackson.databind.ObjectMapper;
88
import io.openbas.IntegrationTest;
99
import io.openbas.database.model.*;
10+
import io.openbas.database.model.Tag;
1011
import io.openbas.database.repository.*;
1112
import io.openbas.utils.Constants;
1213
import java.io.IOException;
@@ -16,9 +17,7 @@
1617
import java.util.Map;
1718
import java.util.Optional;
1819
import org.jetbrains.annotations.NotNull;
19-
import org.junit.jupiter.api.BeforeEach;
20-
import org.junit.jupiter.api.Test;
21-
import org.junit.jupiter.api.TestInstance;
20+
import org.junit.jupiter.api.*;
2221
import org.mockito.MockitoAnnotations;
2322
import org.springframework.beans.factory.annotation.Autowired;
2423
import org.springframework.data.jpa.domain.Specification;

0 commit comments

Comments
 (0)