From b6df3e41658da002e10cd70f12130be063904bf4 Mon Sep 17 00:00:00 2001 From: Stephanya Casanova Date: Mon, 23 Dec 2024 10:45:37 +0100 Subject: [PATCH] [backend] Add enabled property to injectInput (#2043) --- .../main/java/io/openbas/rest/inject/form/InjectInput.java | 4 ++++ openbas-api/src/test/java/io/openbas/octi/OpenCTIApiTest.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openbas-api/src/main/java/io/openbas/rest/inject/form/InjectInput.java b/openbas-api/src/main/java/io/openbas/rest/inject/form/InjectInput.java index 80cfe0c737..8ac01b7ab7 100644 --- a/openbas-api/src/main/java/io/openbas/rest/inject/form/InjectInput.java +++ b/openbas-api/src/main/java/io/openbas/rest/inject/form/InjectInput.java @@ -56,6 +56,9 @@ public class InjectInput { @JsonProperty("inject_tags") private List tagIds = new ArrayList<>(); + @JsonProperty("inject_enabled") + private boolean enabled = true; + public Inject toInject(@NotNull final InjectorContract injectorContract) { Inject inject = new Inject(); inject.setTitle(getTitle()); @@ -66,6 +69,7 @@ public Inject toInject(@NotNull final InjectorContract injectorContract) { inject.setAllTeams(isAllTeams()); inject.setCountry(getCountry()); inject.setCity(getCity()); + inject.setEnabled(isEnabled()); return inject; } } diff --git a/openbas-api/src/test/java/io/openbas/octi/OpenCTIApiTest.java b/openbas-api/src/test/java/io/openbas/octi/OpenCTIApiTest.java index c91a80169c..3bca902d83 100644 --- a/openbas-api/src/test/java/io/openbas/octi/OpenCTIApiTest.java +++ b/openbas-api/src/test/java/io/openbas/octi/OpenCTIApiTest.java @@ -164,7 +164,7 @@ public void testCreateScenario_ValidInput() throws Exception { @Test @DisplayName( "Test to validate existence of 'Add Inject to Scenario' endpoint and validate InjectInput") - public void testCreateInjectForScenario_ValidInput() throws Exception { + public void testCreateInjectForScenario_ValidInput_Additional_param() throws Exception { // -- PREPARE -- String jsonInput = "{" @@ -174,6 +174,7 @@ public void testCreateInjectForScenario_ValidInput() throws Exception { + "\"inject_content\": null, " + "\"inject_depends_duration\": 100, " + "\"inject_tags\": [\"Tag1\"], " + + "\"inject_enabled\": false, " + "\"inject_additional_param\": \"additional_param\"" + "}";