Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[frontend/backend] e2e tests for CRUD operations on Reports (#5648) #6682

Merged
merged 6 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ services:
- BRANCH=$(echo $DRONE_COMMIT_BRANCH | cut -d "/" -f 2)
- CLIENT_PYTHON_BRANCH=$([[ "$(echo "$(git ls-remote --heads https://github.com/OpenCTI-Platform/client-python.git opencti/$BRANCH)")" != '' ]] && echo opencti/$BRANCH || echo 'master')
- pip3 install --upgrade --force git+https://github.com/OpenCTI-Platform/client-python@$CLIENT_PYTHON_BRANCH
- yarn build:dev
- yarn wait-api && yarn insert:dev &
- NODE_OPTIONS=--max_old_space_size=8192 yarn start

volumes:
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module.exports = {
ignoreTemplateLiterals: true,
},
],
'@typescript-eslint/lines-between-class-members': 'off',
'@typescript-eslint/naming-convention': ['error', {
selector: 'variable',
format: ['camelCase', 'UPPER_CASE'],
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,7 @@
"Renew": "Erneuern",
"Replace": "Ersetzen Sie",
"Report": "Bericht",
"Report actions": "Aktionen melden",
"Report name": "Name des Berichts",
"Report representation": "Berichtsdarstellung",
"Report type": "Berichtstyp",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,7 @@
"Renew": "Renew",
"Replace": "Replace",
"Report": "Report",
"Report actions": "Report actions",
"Report name": "Report name",
"Report representation": "Report representation",
"Report type": "Report type",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,7 @@
"Renew": "Renovar",
"Replace": "Reemplazarr",
"Report": "Informe",
"Report actions": "Informar de las acciones",
"Report name": "Nombre del informe",
"Report representation": "Informe de representación",
"Report type": "Tipo de informe",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,7 @@
"Renew": "Renouveler",
"Replace": "Remplacer",
"Report": "Report",
"Report actions": "Rapport d'actions",
"Report name": "Nom du rapport",
"Report representation": "Représentation du rapport",
"Report type": "Type de rapport",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,7 @@
"Renew": "更新",
"Replace": "置換",
"Report": "レポート",
"Report actions": "活動報告",
"Report name": "レポート名",
"Report representation": "レポート表現",
"Report type": "レポートタイプ",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,7 @@
"Renew": "更新",
"Replace": "替换",
"Report": "报告",
"Report actions": "报告行动",
"Report name": "报告名称",
"Report representation": "报告表示",
"Report type": "报告类型",
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default defineConfig({
screenshot: "only-on-failure",
ignoreHTTPSErrors: true,
},
expect: { timeout: 200000 },
expect: { timeout: 60000 },
timeout: 200000,
/* Configure projects for major browsers */
projects: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { fieldToAutocomplete } from 'formik-mui';
import { useField } from 'formik';
import { isNil } from 'ramda';
import { truncate } from '../utils/String';
import { useFormatter } from './i18n';

const AutocompleteField = (props) => {
const {
Expand All @@ -24,6 +25,7 @@ const AutocompleteField = (props) => {
endAdornment,
} = props;
const [, meta] = useField(name);
const { t_i18n } = useFormatter();
const internalOnChange = React.useCallback(
(_, value) => {
if (typeof onInternalChange === 'function') {
Expand Down Expand Up @@ -100,6 +102,7 @@ const AutocompleteField = (props) => {
edge="end"
style={{ position: 'absolute', top: 5, right: 35 }}
size="large"
title={t_i18n('Add')}
>
<Add />
</IconButton>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { isNil } from 'ramda';
import { getIn, useField } from 'formik';
import { v4 as uuid } from 'uuid';
import MuiSelect from '@mui/material/Select';
import InputLabel from '@mui/material/InputLabel';
import FormControl from '@mui/material/FormControl';
Expand Down Expand Up @@ -68,6 +69,8 @@ const SelectField = (props) => {
const [, meta] = useField(name);
const { value, ...otherProps } = fieldToSelect(props);

const labelId = uuid();

return (
<FormControl
style={props.containerstyle}
Expand All @@ -76,6 +79,7 @@ const SelectField = (props) => {
<InputLabel
style={{ color: props.disabled ? '#4f4f4f' : '' }}
variant={props.variant}
id={labelId}
>
{props.label}
</InputLabel>
Expand All @@ -85,6 +89,7 @@ const SelectField = (props) => {
onChange={internalOnChange}
onFocus={internalOnFocus}
onBlur={internalOnBlur}
labelId={labelId}
/>
<FormHelperText
variant={props.variant}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const ReportPopover = ({ id }) => {
value="popover"
size="small"
onClick={handleOpen}
title={t_i18n('Report actions')}
>
<MoreVert fontSize="small" color="primary" />
</ToggleButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const ConfidenceField: FunctionComponent<ConfidenceFieldProps> = ({
icon={false}
variant="outlined"
style={{ position: 'relative' }}
aria-label={finalLabel}
>
<Field
component={InputSliderField}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ const StixCoreObjectOrCoreRelationshipLabelsView = (props) => {
<Security needs={[KNOWLEDGE_KNUPDATE]}>
<IconButton
color="primary"
aria-label="Label"
aria-label={t_i18n('Add new labels')}
title={t_i18n('Add new labels')}
onClick={handleOpenAdd}
style={{ float: 'left', margin: '-15px 0 0 -2px' }}
size="large"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,24 @@ class StixDomainObjectOverview extends Component {
/>
</>
)}
<Typography
variant="h3"
gutterBottom={true}
style={{
marginTop:
withPattern
|| (!withoutMarking && stixDomainObject.objectMarking)
? 20
: 0,
}}
>
{t('Author')}
</Typography>
<ItemAuthor
createdBy={R.propOr(null, 'createdBy', stixDomainObject)}
/>
<div>
<Typography
variant="h3"
gutterBottom={true}
style={{
marginTop:
withPattern
|| (!withoutMarking && stixDomainObject.objectMarking)
? 20
: 0,
}}
>
{t('Author')}
</Typography>
<ItemAuthor
createdBy={R.propOr(null, 'createdBy', stixDomainObject)}
/>
</div>
{(displayConfidence || displayReliability) && (
<Grid container={true} columnSpacing={1}>
{displayReliability && (
Expand Down Expand Up @@ -236,7 +238,7 @@ class StixDomainObjectOverview extends Component {
disabled={!stixDomainObject.workflowEnabled}
/>
{displayAssignees && (
<>
<div>
<Typography
variant="h3"
gutterBottom={true}
Expand All @@ -245,10 +247,10 @@ class StixDomainObjectOverview extends Component {
{t('Assignees')}
</Typography>
<ItemAssignees assignees={stixDomainObject.objectAssignee ?? []}/>
</>
</div>
)}
{displayParticipants && (
<>
<div>
<Typography
variant="h3"
gutterBottom={true}
Expand All @@ -257,7 +259,7 @@ class StixDomainObjectOverview extends Component {
{t('Participants')}
</Typography>
<ItemParticipants participants={stixDomainObject.objectParticipant ?? []}/>
</>
</div>
)}
<Typography
variant="h3"
Expand Down Expand Up @@ -285,14 +287,16 @@ class StixDomainObjectOverview extends Component {
{t('Platform creation date')}
</Typography>
{fldt(stixDomainObject.created_at)}
<Typography
variant="h3"
gutterBottom={true}
style={{ marginTop: 20 }}
>
{t('Creators')}
</Typography>
<ItemCreators creators={stixDomainObject.creators ?? []} />
<div>
<Typography
variant="h3"
gutterBottom={true}
style={{ marginTop: 20 }}
>
{t('Creators')}
</Typography>
<ItemCreators creators={stixDomainObject.creators ?? []} />
</div>
<div style={{ marginTop: 20 }}>
<Typography
variant="h3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ class ToolBar extends Component {
},
}}
>
<Toolbar style={{ minHeight: 54 }}>
<Toolbar style={{ minHeight: 54 }} data-testid='opencti-toolbar'>
<Typography
className={classes.title}
color="inherit"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { expect, test } from '../fixtures/baseFixtures';
import ReportDetailsPage from '../model/reportDetails.pageModel';
import FormExportPageModel from '../model/formExport.pageModel';
import FormExportPageModel from '../model/form/formExport.pageModel';
import ReportPage from '../model/report.pageModel';
import ReportFormPage from '../model/reportForm.pageModel';
import ReportFormPage from '../model/form/reportForm.pageModel';

test.skip('Add an Export in a report and check the export is present in content', async ({ page }) => {
const reportPage = new ReportPage(page);
const reportForm = new ReportFormPage(page);
const reportDetailsPage = new ReportDetailsPage(page);
const formExportPage = new FormExportPageModel(page);
await page.goto('/dashboard/analyses/reports');
await reportPage.addNewReport();
await reportForm.fillNameInput('test e2e object-markings');
await reportPage.openNewReportForm();
await reportForm.nameField.fill('test e2e object-markings');
await reportPage.getCreateReportButton().click();
await reportPage.getItemFromList('test e2e object-markings').click();
await reportDetailsPage.getExportButton().click();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from '../fixtures/baseFixtures';
import DashboardPage from '../model/dashboard.pageModel';
import DashboardDetailsPage from '../model/dashboardDetails.pageModel';
import DashboardFormPage from '../model/dashboardForm.pageModel';
import DashboardFormPage from '../model/form/dashboardForm.pageModel';

test('Create a new dashboard page', async ({ page }) => {
const dashboardPage = new DashboardPage(page);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from '../fixtures/baseFixtures';
import DashboardPage from '../model/dashboard.pageModel';
import DashboardDetailsPage from '../model/dashboardDetails.pageModel';
import DashboardFormPage from '../model/dashboardForm.pageModel';
import DashboardFormPage from '../model/form/dashboardForm.pageModel';

test('Create a new dashboard page and test update', async ({ page }) => {
const dashboardPage = new DashboardPage(page);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import { expect, test } from '../fixtures/baseFixtures';
import ReportPage from '../model/report.pageModel';
import ContainerObservablesPage from '../model/containerObservables.pageModel';
import ReportDetailsPage from '../model/reportDetails.pageModel';
import ReportFormPage from '../model/reportForm.pageModel';
import ReportFormPage from '../model/form/reportForm.pageModel';
import LoginPage from '../model/login.pageModel';
import DashboardPage from '../model/dashboard.pageModel';
import CommitMessagePage from '../model/commitMessage.pageModel';
import ContainerAddObservablesPage from '../model/containerAddObservables.pageModel';
import RolesSettingsPage from '../model/rolesSettings.pageModel';
import RoleFormPage from '../model/roleForm.pageModel';
import RoleFormPage from '../model/form/roleForm.pageModel';
import RolePage from '../model/role.pageModel';
import GroupsSettingsPage from '../model/groupsSettings.pageModel';
import GroupPage from '../model/group.pageModel';
import GroupFormPage from '../model/groupForm.pageModel';
import GroupFormPage from '../model/form/groupForm.pageModel';
import UsersSettingsPage from '../model/usersSettings.pageModel';
import UserPage from '../model/user.pageModel';
import UserFormPage from '../model/userForm.pageModel';
import UserFormPage from '../model/form/userForm.pageModel';
import LeftBarPage from '../model/menu/leftBar.pageModel';

const noBypassUserAuthFile = 'tests_e2e/.setup/.auth/no-bypass-ref-user.json';
Expand Down Expand Up @@ -116,12 +116,12 @@ test('Add and remove observable from Observables tab of a Report as Admin user',
// Create a report and check that adding an observable is possible
await page.goto('/dashboard/analyses/reports');
await page.getByTestId('ChevronRightIcon').click();
await reportPage.addNewReport();
await reportForm.fillNameInput('Test add observable e2e');
await reportPage.openNewReportForm();
await reportForm.nameField.fill('Test add observable e2e');
await reportPage.getCreateReportButton().click();
await reportPage.getItemFromList('Test add observable e2e').click();
await expect(reportDetailsPage.getReportDetailsPage()).toBeVisible();
await reportDetailsPage.getObservablesTab().click();
await reportDetailsPage.goToObservablesTab();
await expect(containerObservablesPage.getContainerObservablesPage()).toBeVisible();
await containerObservablesPage.getAddObservableListButton().click();
await containerAddObservablesPage.createNewIPV4Observable('8.8.8.8');
Expand All @@ -140,7 +140,7 @@ test('Add and remove observable from Observables tab of a Report as Admin user',

await leftBarPage.clickOnMenu('Analyses', 'Reports');
await reportPage.getItemFromList('Test add observable e2e').click();
await reportDetailsPage.getObservablesTab().click();
await reportDetailsPage.goToObservablesTab();
await expect(containerObservablesPage.getContainerObservablesPage()).toBeVisible();
await containerObservablesPage.getAddObservableListButton().click();
await expect(containerAddObservablesPage.getObservable('IPv4 address 8.8.8.8')).toBeVisible();
Expand Down Expand Up @@ -168,12 +168,12 @@ test.describe('Add and remove observable from Observables tab of a Report as noB
// Create a report and check that adding an observable is possible
await page.goto('/dashboard/analyses/reports');
await page.getByTestId('ChevronRightIcon').click();
await reportPage.addNewReport();
await reportForm.fillNameInput('Test add observable e2e 2');
await reportPage.openNewReportForm();
await reportForm.nameField.fill('Test add observable e2e 2');
await reportPage.getCreateReportButton().click();
await reportPage.getItemFromList('Test add observable e2e 2').click();
await expect(reportDetailsPage.getReportDetailsPage()).toBeVisible();
await reportDetailsPage.getObservablesTab().click();
await reportDetailsPage.goToObservablesTab();
await expect(containerObservablesPage.getContainerObservablesPage()).toBeVisible();
await containerObservablesPage.getAddObservableListButton().click();
await containerAddObservablesPage.createNewIPV4Observable('9.9.9.9');
Expand All @@ -192,7 +192,7 @@ test.describe('Add and remove observable from Observables tab of a Report as noB

await leftBarPage.clickOnMenu('Analyses', 'Reports');
await reportPage.getItemFromList('Test add observable e2e 2').click();
await reportDetailsPage.getObservablesTab().click();
await reportDetailsPage.goToObservablesTab();
await expect(containerObservablesPage.getContainerObservablesPage()).toBeVisible();
await containerObservablesPage.getAddObservableListButton().click();
await expect(containerAddObservablesPage.getObservable('IPv4 address 9.9.9.9')).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '../fixtures/baseFixtures';
import GroupingsPage from '../model/grouping.pageModel';
import GroupingFormPage from '../model/groupingForm.pageModel';
import GroupingFormPage from '../model/form/groupingForm.pageModel';
import GroupingDetailsPage from '../model/groupingDetails.pageModel';
import StixDomainObjectContentTabPage from '../model/StixDomainObjectContentTab.pageModel';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect, test } from '../fixtures/baseFixtures';
import IntrusionSetPage from '../model/intrusionSet.pageModel';
import IntrusionSetFormPage from '../model/intrusionSetForm.pageModel';
import IntrusionSetFormPage from '../model/form/intrusionSetForm.pageModel';
import IntrusionSetDetailsPage from '../model/intrusionSetDetails.pageModel';
import StixCoreRelationshipCreationFromEntityFormPage from '../model/stixCoreRelationshipCreationFromEntityForm.pageModel';
import StixCoreRelationshipCreationFromEntityFormPage from '../model/form/stixCoreRelationshipCreationFromEntityForm.pageModel';

test('Create a new relationship in intrusion set knowledge', async ({ page }) => {
const intrusionSetPage = new IntrusionSetPage(page);
Expand Down