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 3520ef4649..3a474a3461 100644 --- a/openbas-api/src/test/java/io/openbas/rest/AtomicTestingApiTest.java +++ b/openbas-api/src/test/java/io/openbas/rest/AtomicTestingApiTest.java @@ -13,7 +13,9 @@ import io.openbas.database.repository.InjectStatusRepository; import io.openbas.database.repository.InjectorContractRepository; import io.openbas.utils.mockUser.WithMockAdminUser; + import java.time.Instant; + import org.junit.jupiter.api.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; @@ -30,10 +32,14 @@ public class AtomicTestingApiTest extends IntegrationTest { static InjectStatus INJECT_STATUS; static String NEW_INJECT_ID; - @Autowired private MockMvc mvc; - @Autowired private InjectRepository injectRepository; - @Autowired private InjectorContractRepository injectorContractRepository; - @Autowired private InjectStatusRepository injectStatusRepository; + @Autowired + private MockMvc mvc; + @Autowired + private InjectRepository injectRepository; + @Autowired + private InjectorContractRepository injectorContractRepository; + @Autowired + private InjectStatusRepository injectStatusRepository; @BeforeAll void beforeAll() { @@ -81,7 +87,6 @@ void findAnAtomicTestingTestWithoutPayload() throws Exception { // -- ASSERT -- assertNotNull(response); assertEquals(INJECT_WITHOUT_PAYLOAD.getId(), JsonPath.read(response, "$.inject_id")); - assertNull(JsonPath.read(response, "$.inject_commands_lines")); } @DisplayName("Find an atomic testing with payload") @@ -100,7 +105,6 @@ void findAnAtomicTestingTestWithPayload() throws Exception { // -- ASSERT -- assertNotNull(response); assertEquals(INJECT_WITH_PAYLOAD.getId(), JsonPath.read(response, "$.inject_id")); - assertNotNull(JsonPath.read(response, "$.inject_commands_lines")); } @DisplayName("Duplicate and delete an atomic testing") diff --git a/openbas-front/src/admin/components/atomic_testings/atomic_testing/AtomicTesting.tsx b/openbas-front/src/admin/components/atomic_testings/atomic_testing/AtomicTesting.tsx index 4ba01690b8..9bc429b586 100644 --- a/openbas-front/src/admin/components/atomic_testings/atomic_testing/AtomicTesting.tsx +++ b/openbas-front/src/admin/components/atomic_testings/atomic_testing/AtomicTesting.tsx @@ -2,6 +2,7 @@ import { Chip, Grid, List, Paper, Tooltip, Typography } from '@mui/material'; import { makeStyles } from '@mui/styles'; import { useContext, useEffect, useState } from 'react'; +import { fetchAtomicTestingPayload } from '../../../../actions/atomic_testings/atomic-testing-actions'; import Empty from '../../../../components/Empty'; import ExpandableMarkdown from '../../../../components/ExpandableMarkdown'; import { useFormatter } from '../../../../components/i18n'; @@ -9,7 +10,7 @@ import ItemStatus from '../../../../components/ItemStatus'; import Loader from '../../../../components/Loader'; import PlatformIcon from '../../../../components/PlatformIcon'; import SearchFilter from '../../../../components/SearchFilter'; -import type { AttackPatternSimple, InjectTargetWithResult, KillChainPhaseSimple } from '../../../../utils/api-types'; +import { AttackPatternSimpleDto, InjectTargetWithResult, KillChainPhaseSimple, PayloadOutputDto } from '../../../../utils/api-types'; import useSearchAnFilter from '../../../../utils/SortingFiltering'; import { isNotEmptyField } from '../../../../utils/utils'; import InjectIcon from '../../common/injects/InjectIcon'; @@ -46,6 +47,7 @@ const AtomicTesting = () => { const [selectedTarget, setSelectedTarget] = useState(); const [currentParentTarget, setCurrentParentTarget] = useState(); const filtering = useSearchAnFilter('', 'name', ['name']); + const [payloadOutput, setPayloadOutput] = useState(); // Fetching data const { injectResultOverviewOutput } = useContext(InjectResultOverviewOutputContext); @@ -55,6 +57,14 @@ const AtomicTesting = () => { const sortedTargets: InjectTargetWithResult[] = filtering.filterAndSort(injectResultOverviewOutput?.inject_targets ?? []); + useEffect(() => { + if (injectResultOverviewOutput) { + fetchAtomicTestingPayload(injectResultOverviewOutput.inject_id).then((result: { data: PayloadOutputDto }) => { + setPayloadOutput(result.data); + }); + } + }, []); + // Handles const handleTargetClick = (target: InjectTargetWithResult, currentParent?: InjectTargetWithResult) => { setSelectedTarget(target); @@ -103,13 +113,11 @@ const AtomicTesting = () => {
{ {t('Attack Patterns')} {(injectResultOverviewOutput.inject_attack_patterns ?? []).length === 0 && '-'} - {injectResultOverviewOutput.inject_attack_patterns?.map((attackPattern: AttackPatternSimple) => ( + {injectResultOverviewOutput.inject_attack_patterns?.map((attackPattern: AttackPatternSimpleDto) => (