1212import static org .assertj .core .api .Assertions .assertThatNoException ;
1313import static org .junit .jupiter .api .Assertions .assertTrue ;
1414import static org .junit .jupiter .api .TestInstance .Lifecycle .PER_CLASS ;
15+ import static org .mockito .ArgumentMatchers .any ;
16+ import static org .mockito .Mockito .verify ;
17+ import static org .mockserver .model .HttpRequest .request ;
18+ import static org .mockserver .model .HttpResponse .response ;
1519import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .post ;
1620import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
1721
5054import org .mockserver .configuration .Configuration ;
5155import org .mockserver .integration .ClientAndServer ;
5256import org .mockserver .socket .PortFactory ;
53- import org .mockserver .client .MockServerClient ;
54- import org .mockserver .configuration .Configuration ;
55- import org .mockserver .integration .ClientAndServer ;
56- import org .mockserver .socket .PortFactory ;
5757import org .springframework .beans .factory .annotation .Autowired ;
5858import org .springframework .http .MediaType ;
5959import org .springframework .test .context .DynamicPropertyRegistry ;
6060import org .springframework .test .context .DynamicPropertySource ;
6161import org .springframework .test .context .TestPropertySource ;
6262import org .springframework .test .context .bean .override .mockito .MockitoSpyBean ;
63- import org .springframework .test .context .TestPropertySource ;
64- import org .springframework .test .context .DynamicPropertyRegistry ;
65- import org .springframework .test .context .DynamicPropertySource ;
6663import org .springframework .test .web .servlet .MockMvc ;
6764import org .springframework .transaction .annotation .Transactional ;
6865
6966@ TestInstance (PER_CLASS )
7067@ Transactional
7168@ WithMockUser (withCapabilities = {Capability .MANAGE_STIX_BUNDLE })
7269@ DisplayName ("STIX API Integration Tests" )
70+ @ TestPropertySource (properties = {"openaev.xtm.opencti.enable=true" })
7371class StixApiTest extends IntegrationTest {
7472
7573 public static final String T_1531 = "T1531" ;
@@ -232,6 +230,38 @@ void setUp() throws Exception {
232230 vulnerabilityComposer .forVulnerability (
233231 VulnerabilityFixture .createVulnerabilityInput ("CVE-2025-56786" )))
234232 .persist ();
233+
234+ injectorContractComposer
235+ .forInjectorContract (injectorContractFixture .getWellKnownSingleManualContract ())
236+ .persist ();
237+
238+ // need to mock unregistered connector to be use in process
239+ mockServer
240+ .when (request ().withMethod ("POST" ).withPath ("" ))
241+ .respond (
242+ response ()
243+ .withStatusCode (200 )
244+ .withHeader ("Content-Type" , "application/json" )
245+ .withBody (
246+ """
247+ {
248+ "data": {}
249+ }
250+ """ ));
251+ openCTIConnectorService .registerOrPingAllConnectors ();
252+
253+ mockServer
254+ .when (request ().withMethod ("POST" ).withPath ("graphql" ))
255+ .respond (
256+ response ()
257+ .withStatusCode (200 )
258+ .withHeader ("Content-Type" , "application/json" )
259+ .withBody (
260+ """
261+ {
262+ "data": {}
263+ }
264+ """ ));
235265 }
236266
237267 @ Nested
@@ -254,6 +284,7 @@ class ImportStixBundles {
254284 .getResponse ()
255285 .getContentAsString ();
256286
287+ verify (securityCoverageService ).pushSecurityCoverageBundleWithExternalURI (any ());
257288 assertThat (response ).isNotBlank ();
258289 String scenarioId = JsonPath .read (response , "$.scenarioId" );
259290 Scenario createdScenario = scenarioRepository .findById (scenarioId ).orElseThrow ();
0 commit comments