Skip to content

Commit

Permalink
Resolve drone errors
Browse files Browse the repository at this point in the history
  • Loading branch information
johanah29 committed Nov 29, 2024
1 parent 996ff70 commit 6be12a7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ 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';
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';
Expand Down Expand Up @@ -46,6 +47,7 @@ const AtomicTesting = () => {
const [selectedTarget, setSelectedTarget] = useState<InjectTargetWithResult>();
const [currentParentTarget, setCurrentParentTarget] = useState<InjectTargetWithResult>();
const filtering = useSearchAnFilter('', 'name', ['name']);
const [payloadOutput, setPayloadOutput] = useState<PayloadOutputDto>();

// Fetching data
const { injectResultOverviewOutput } = useContext<InjectResultOverviewOutputContextType>(InjectResultOverviewOutputContext);
Expand All @@ -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);
Expand Down Expand Up @@ -103,13 +113,11 @@ const AtomicTesting = () => {
<div style={{ display: 'flex' }}>
<InjectIcon
variant="inline"
isPayload={isNotEmptyField(injectResultOverviewOutput.inject_injector_contract?.injector_contract_payload)}
type={
injectResultOverviewOutput.inject_injector_contract?.injector_contract_payload
? injectResultOverviewOutput.inject_injector_contract.injector_contract_payload?.payload_collector_type
|| injectResultOverviewOutput.inject_injector_contract.injector_contract_payload?.payload_type
: injectResultOverviewOutput.inject_type
}
isPayload={isNotEmptyField(payloadOutput)}
type={payloadOutput
? payloadOutput.payload_collector_type
|| payloadOutput.payload_type
: injectResultOverviewOutput.inject_type}
/>
<Tooltip title={tPick(injectResultOverviewOutput.inject_injector_contract?.injector_contract_labels)}>
<div style={{
Expand Down Expand Up @@ -195,7 +203,7 @@ const AtomicTesting = () => {
{t('Attack Patterns')}
</Typography>
{(injectResultOverviewOutput.inject_attack_patterns ?? []).length === 0 && '-'}
{injectResultOverviewOutput.inject_attack_patterns?.map((attackPattern: AttackPatternSimple) => (
{injectResultOverviewOutput.inject_attack_patterns?.map((attackPattern: AttackPatternSimpleDto) => (
<Tooltip key={attackPattern.attack_pattern_id} title={`[${attackPattern.attack_pattern_external_id}] ${attackPattern.attack_pattern_name}`}>
<Chip
variant="outlined"
Expand Down

0 comments on commit 6be12a7

Please sign in to comment.