Skip to content

Commit

Permalink
[Security Solution] [Cases] Cypress for case connector selector optio…
Browse files Browse the repository at this point in the history
…ns (#80745)
  • Loading branch information
stephmilovic committed Dec 1, 2020
1 parent 7c5ebed commit 02f19eb
Show file tree
Hide file tree
Showing 7 changed files with 412 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ import { TIMELINE_DESCRIPTION, TIMELINE_QUERY, TIMELINE_TITLE } from '../screens

import { goToCaseDetails, goToCreateNewCase } from '../tasks/all_cases';
import { openCaseTimeline } from '../tasks/case_details';
import { backToCases, createNewCaseWithTimeline } from '../tasks/create_new_case';
import {
attachTimeline,
backToCases,
createCase,
fillCasesMandatoryfields,
} from '../tasks/create_new_case';
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login';
import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver';

Expand All @@ -57,7 +62,9 @@ describe('Cases', () => {
it('Creates a new case with timeline and opens the timeline', () => {
loginAndWaitForPageWithoutDateRange(CASES_URL);
goToCreateNewCase();
createNewCaseWithTimeline(case1);
fillCasesMandatoryfields(case1);
attachTimeline(case1);
createCase();
backToCases();

cy.get(ALL_CASES_PAGE_TITLE).should('have.text', 'Cases');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { loginAndWaitForPageWithoutDateRange } from '../tasks/login';
import {
case1,
connectorIds,
mockConnectorsResponse,
executeResponses,
ibmResilientConnectorOptions,
jiraConnectorOptions,
serviceNowConnectorOpions,
} from '../objects/case';
import {
createCase,
fillCasesMandatoryfields,
fillIbmResilientConnectorOptions,
fillJiraConnectorOptions,
fillServiceNowConnectorOptions,
} from '../tasks/create_new_case';
import { goToCreateNewCase } from '../tasks/all_cases';
import { deleteCase } from '../tasks/case_details';
import { CASES_URL } from '../urls/navigation';
import { CONNECTOR_CARD_DETAILS, CONNECTOR_TITLE } from '../screens/case_details';

describe('Cases connector incident fields', () => {
before(() => {
cy.server();
cy.route('GET', '**/api/cases/configure/connectors/_find', mockConnectorsResponse);
cy.route2('POST', `**/api/actions/action/${connectorIds.jira}/_execute`, (req) => {
const response =
JSON.parse(req.body).params.subAction === 'issueTypes'
? executeResponses.jira.issueTypes
: executeResponses.jira.fieldsByIssueType;
req.reply(JSON.stringify(response));
});
cy.route2('POST', `**/api/actions/action/${connectorIds.resilient}/_execute`, (req) => {
const response =
JSON.parse(req.body).params.subAction === 'incidentTypes'
? executeResponses.resilient.incidentTypes
: executeResponses.resilient.severity;
req.reply(JSON.stringify(response));
});
});

after(() => {
deleteCase();
});

it('Correct incident fields show when connector is changed', () => {
loginAndWaitForPageWithoutDateRange(CASES_URL);
goToCreateNewCase();
fillCasesMandatoryfields(case1);
fillJiraConnectorOptions(jiraConnectorOptions);
fillServiceNowConnectorOptions(serviceNowConnectorOpions);
fillIbmResilientConnectorOptions(ibmResilientConnectorOptions);
createCase();

cy.get(CONNECTOR_TITLE).should('have.text', ibmResilientConnectorOptions.title);
cy.get(CONNECTOR_CARD_DETAILS).should(
'have.text',
`${
ibmResilientConnectorOptions.title
}Incident Types: ${ibmResilientConnectorOptions.incidentTypes.join(', ')}Severity: ${
ibmResilientConnectorOptions.severity
}`
);
});
});
220 changes: 220 additions & 0 deletions x-pack/plugins/security_solution/cypress/objects/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ export interface Connector {
password: string;
}

export interface JiraConnectorOptions {
issueType: string;
priority: string;
}

export interface ServiceNowconnectorOptions {
urgency: string;
severity: string;
impact: string;
}

export interface IbmResilientConnectorOptions {
title: string;
severity: string;
incidentTypes: string[];
}

export const caseTimeline: TimelineWithId = {
title: 'SIEM test',
description: 'description',
Expand All @@ -43,4 +60,207 @@ export const serviceNowConnector: Connector = {
password: 'password',
};

export const jiraConnectorOptions: JiraConnectorOptions = {
issueType: '10006',
priority: 'High',
};

export const serviceNowConnectorOpions: ServiceNowconnectorOptions = {
urgency: '2',
severity: '1',
impact: '3',
};

export const ibmResilientConnectorOptions: IbmResilientConnectorOptions = {
title: 'Resilient',
severity: 'Medium',
incidentTypes: ['Communication error (fax; email)', 'Denial of Service'],
};

export const TIMELINE_CASE_ID = '68248e00-f689-11ea-9ab2-59238b522856';
export const connectorIds = {
jira: '000e5f86-08b0-4882-adfd-6df981d45c1b',
sn: '93a69ba3-3c31-4b4c-bf86-cc79a090f437',
resilient: 'a6a8dd7f-7e88-48fe-9b9f-70b668da8cbc',
};

export const mockConnectorsResponse = [
{
id: connectorIds.jira,
actionTypeId: '.jira',
name: 'Jira',
config: {
incidentConfiguration: {
mapping: [
{ source: 'title', target: 'summary', actionType: 'overwrite' },
{ source: 'description', target: 'description', actionType: 'overwrite' },
{ source: 'comments', target: 'comments', actionType: 'append' },
],
},
isCaseOwned: true,
apiUrl: 'https://siem-kibana.atlassian.net',
projectKey: 'RJ',
},
isPreconfigured: false,
referencedByCount: 0,
},
{
id: connectorIds.resilient,
actionTypeId: '.resilient',
name: 'Resilient',
config: {
incidentConfiguration: {
mapping: [
{ source: 'title', target: 'name', actionType: 'overwrite' },
{ source: 'description', target: 'description', actionType: 'overwrite' },
{ source: 'comments', target: 'comments', actionType: 'append' },
],
},
isCaseOwned: true,
apiUrl: 'https://ibm-resilient.siem.estc.dev',
orgId: '201',
},
isPreconfigured: false,
referencedByCount: 0,
},
{
id: connectorIds.sn,
actionTypeId: '.servicenow',
name: 'ServiceNow',
config: {
incidentConfiguration: {
mapping: [
{ source: 'title', target: 'short_description', actionType: 'overwrite' },
{ source: 'description', target: 'description', actionType: 'overwrite' },
{ source: 'comments', target: 'comments', actionType: 'append' },
],
},
isCaseOwned: true,
apiUrl: 'https://dev65287.service-now.com',
},
isPreconfigured: false,
referencedByCount: 0,
},
];
export const executeResponses = {
jira: {
issueTypes: {
status: 'ok',
data: [
{ id: '10006', name: 'Task' },
{ id: '10007', name: 'Sub-task' },
],
actionId: connectorIds.jira,
},
fieldsByIssueType: {
status: 'ok',
data: {
summary: { allowedValues: [], defaultValue: {} },
issuetype: {
allowedValues: [
{
self: 'https://siem-kibana.atlassian.net/rest/api/2/issuetype/10006',
id: '10006',
description: 'A small, distinct piece of work.',
iconUrl:
'https://siem-kibana.atlassian.net/secure/viewavatar?size=medium&avatarId=10318&avatarType=issuetype',
name: 'Task',
subtask: false,
avatarId: 10318,
},
],
defaultValue: {},
},
attachment: { allowedValues: [], defaultValue: {} },
duedate: { allowedValues: [], defaultValue: {} },
description: { allowedValues: [], defaultValue: {} },
project: {
allowedValues: [
{
self: 'https://siem-kibana.atlassian.net/rest/api/2/project/10011',
id: '10011',
key: 'RJ',
name: 'Refactor Jira',
projectTypeKey: 'business',
simplified: false,
avatarUrls: {
'48x48':
'https://siem-kibana.atlassian.net/secure/projectavatar?pid=10011&avatarId=10423',
'24x24':
'https://siem-kibana.atlassian.net/secure/projectavatar?size=small&s=small&pid=10011&avatarId=10423',
'16x16':
'https://siem-kibana.atlassian.net/secure/projectavatar?size=xsmall&s=xsmall&pid=10011&avatarId=10423',
'32x32':
'https://siem-kibana.atlassian.net/secure/projectavatar?size=medium&s=medium&pid=10011&avatarId=10423',
},
},
],
defaultValue: {},
},
assignee: { allowedValues: [], defaultValue: {} },
priority: {
allowedValues: [
{
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/1',
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/highest.svg',
name: 'Highest',
id: '1',
},
{
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/2',
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/high.svg',
name: 'High',
id: '2',
},
{
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/3',
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/medium.svg',
name: 'Medium',
id: '3',
},
{
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/4',
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/low.svg',
name: 'Low',
id: '4',
},
{
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/5',
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/lowest.svg',
name: 'Lowest',
id: '5',
},
],
defaultValue: {
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/3',
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/medium.svg',
name: 'Medium',
id: '3',
},
},
timetracking: { allowedValues: [], defaultValue: {} },
labels: { allowedValues: [], defaultValue: {} },
},
actionId: connectorIds.jira,
},
},
resilient: {
incidentTypes: {
status: 'ok',
data: [
{ id: 17, name: 'Communication error (fax; email)' },
{ id: 21, name: 'Denial of Service' },
],
actionId: connectorIds.resilient,
},
severity: {
status: 'ok',
data: [
{ id: 4, name: 'Low' },
{ id: 5, name: 'Medium' },
{ id: 6, name: 'High' },
],
actionId: connectorIds.resilient,
},
},
};
10 changes: 10 additions & 0 deletions x-pack/plugins/security_solution/cypress/screens/case_details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const CASE_ACTIONS_BTN = '[data-test-subj="property-actions-ellipses"]';

export const CASE_DETAILS_DESCRIPTION =
'[data-test-subj="description-action"] [data-test-subj="user-action-markdown"]';

Expand All @@ -27,6 +29,14 @@ export const CASE_DETAILS_USER_ACTION_DESCRIPTION_USERNAME =

export const CASE_DETAILS_USERNAMES = '[data-test-subj="case-view-username"]';

export const CONNECTOR_CARD_DETAILS = '[data-test-subj="settings-connector-card"]';

export const CONNECTOR_TITLE = '[data-test-subj="settings-connector-card"] span.euiTitle';

export const DELETE_CASE_BTN = '[data-test-subj="property-actions-trash"]';

export const DELETE_CASE_CONFIRMATION_BTN = '[data-test-subj="confirmModalConfirmButton"]';

export const PARTICIPANTS = 1;

export const REPORTER = 0;
29 changes: 29 additions & 0 deletions x-pack/plugins/security_solution/cypress/screens/edit_connector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { connectorIds } from '../objects/case';

export const CONNECTOR_RESILIENT = `[data-test-subj="connector-settings-resilient"]`;

export const CONNECTOR_SELECTOR = '[data-test-subj="dropdown-connectors"]';

export const SELECT_IMPACT = `[data-test-subj="impactSelect"]`;

export const SELECT_INCIDENT_TYPE = `[data-test-subj="incidentTypeComboBox"] input[data-test-subj="comboBoxSearchInput"]`;

export const SELECT_ISSUE_TYPE = `[data-test-subj="issueTypeSelect"]`;

export const SELECT_JIRA = `[data-test-subj="dropdown-connector-${connectorIds.jira}"]`;

export const SELECT_PRIORITY = `[data-test-subj="prioritySelect"]`;

export const SELECT_RESILIENT = `[data-test-subj="dropdown-connector-${connectorIds.resilient}"]`;

export const SELECT_SEVERITY = `[data-test-subj="severitySelect"]`;

export const SELECT_SN = `[data-test-subj="dropdown-connector-${connectorIds.sn}"]`;

export const SELECT_URGENCY = `[data-test-subj="urgencySelect"]`;
Loading

0 comments on commit 02f19eb

Please sign in to comment.