Skip to content

Commit 99ea48f

Browse files
authored
[Security Solution] [Cases] Cypress for case connector selector options (#80745)
1 parent 7a77900 commit 99ea48f

File tree

7 files changed

+412
-16
lines changed

7 files changed

+412
-16
lines changed

x-pack/plugins/security_solution/cypress/integration/cases.spec.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ import { TIMELINE_DESCRIPTION, TIMELINE_QUERY, TIMELINE_TITLE } from '../screens
3939

4040
import { goToCaseDetails, goToCreateNewCase } from '../tasks/all_cases';
4141
import { openCaseTimeline } from '../tasks/case_details';
42-
import { backToCases, createNewCaseWithTimeline } from '../tasks/create_new_case';
42+
import {
43+
attachTimeline,
44+
backToCases,
45+
createCase,
46+
fillCasesMandatoryfields,
47+
} from '../tasks/create_new_case';
4348
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login';
4449
import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver';
4550

@@ -57,7 +62,9 @@ describe('Cases', () => {
5762
it('Creates a new case with timeline and opens the timeline', () => {
5863
loginAndWaitForPageWithoutDateRange(CASES_URL);
5964
goToCreateNewCase();
60-
createNewCaseWithTimeline(case1);
65+
fillCasesMandatoryfields(case1);
66+
attachTimeline(case1);
67+
createCase();
6168
backToCases();
6269

6370
cy.get(ALL_CASES_PAGE_TITLE).should('have.text', 'Cases');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login';
8+
import {
9+
case1,
10+
connectorIds,
11+
mockConnectorsResponse,
12+
executeResponses,
13+
ibmResilientConnectorOptions,
14+
jiraConnectorOptions,
15+
serviceNowConnectorOpions,
16+
} from '../objects/case';
17+
import {
18+
createCase,
19+
fillCasesMandatoryfields,
20+
fillIbmResilientConnectorOptions,
21+
fillJiraConnectorOptions,
22+
fillServiceNowConnectorOptions,
23+
} from '../tasks/create_new_case';
24+
import { goToCreateNewCase } from '../tasks/all_cases';
25+
import { deleteCase } from '../tasks/case_details';
26+
import { CASES_URL } from '../urls/navigation';
27+
import { CONNECTOR_CARD_DETAILS, CONNECTOR_TITLE } from '../screens/case_details';
28+
29+
describe('Cases connector incident fields', () => {
30+
before(() => {
31+
cy.server();
32+
cy.route('GET', '**/api/cases/configure/connectors/_find', mockConnectorsResponse);
33+
cy.route2('POST', `**/api/actions/action/${connectorIds.jira}/_execute`, (req) => {
34+
const response =
35+
JSON.parse(req.body).params.subAction === 'issueTypes'
36+
? executeResponses.jira.issueTypes
37+
: executeResponses.jira.fieldsByIssueType;
38+
req.reply(JSON.stringify(response));
39+
});
40+
cy.route2('POST', `**/api/actions/action/${connectorIds.resilient}/_execute`, (req) => {
41+
const response =
42+
JSON.parse(req.body).params.subAction === 'incidentTypes'
43+
? executeResponses.resilient.incidentTypes
44+
: executeResponses.resilient.severity;
45+
req.reply(JSON.stringify(response));
46+
});
47+
});
48+
49+
after(() => {
50+
deleteCase();
51+
});
52+
53+
it('Correct incident fields show when connector is changed', () => {
54+
loginAndWaitForPageWithoutDateRange(CASES_URL);
55+
goToCreateNewCase();
56+
fillCasesMandatoryfields(case1);
57+
fillJiraConnectorOptions(jiraConnectorOptions);
58+
fillServiceNowConnectorOptions(serviceNowConnectorOpions);
59+
fillIbmResilientConnectorOptions(ibmResilientConnectorOptions);
60+
createCase();
61+
62+
cy.get(CONNECTOR_TITLE).should('have.text', ibmResilientConnectorOptions.title);
63+
cy.get(CONNECTOR_CARD_DETAILS).should(
64+
'have.text',
65+
`${
66+
ibmResilientConnectorOptions.title
67+
}Incident Types: ${ibmResilientConnectorOptions.incidentTypes.join(', ')}Severity: ${
68+
ibmResilientConnectorOptions.severity
69+
}`
70+
);
71+
});
72+
});

x-pack/plugins/security_solution/cypress/objects/case.ts

+220
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ export interface Connector {
2121
password: string;
2222
}
2323

24+
export interface JiraConnectorOptions {
25+
issueType: string;
26+
priority: string;
27+
}
28+
29+
export interface ServiceNowconnectorOptions {
30+
urgency: string;
31+
severity: string;
32+
impact: string;
33+
}
34+
35+
export interface IbmResilientConnectorOptions {
36+
title: string;
37+
severity: string;
38+
incidentTypes: string[];
39+
}
40+
2441
export const caseTimeline: TimelineWithId = {
2542
title: 'SIEM test',
2643
description: 'description',
@@ -43,4 +60,207 @@ export const serviceNowConnector: Connector = {
4360
password: 'password',
4461
};
4562

63+
export const jiraConnectorOptions: JiraConnectorOptions = {
64+
issueType: '10006',
65+
priority: 'High',
66+
};
67+
68+
export const serviceNowConnectorOpions: ServiceNowconnectorOptions = {
69+
urgency: '2',
70+
severity: '1',
71+
impact: '3',
72+
};
73+
74+
export const ibmResilientConnectorOptions: IbmResilientConnectorOptions = {
75+
title: 'Resilient',
76+
severity: 'Medium',
77+
incidentTypes: ['Communication error (fax; email)', 'Denial of Service'],
78+
};
79+
4680
export const TIMELINE_CASE_ID = '68248e00-f689-11ea-9ab2-59238b522856';
81+
export const connectorIds = {
82+
jira: '000e5f86-08b0-4882-adfd-6df981d45c1b',
83+
sn: '93a69ba3-3c31-4b4c-bf86-cc79a090f437',
84+
resilient: 'a6a8dd7f-7e88-48fe-9b9f-70b668da8cbc',
85+
};
86+
87+
export const mockConnectorsResponse = [
88+
{
89+
id: connectorIds.jira,
90+
actionTypeId: '.jira',
91+
name: 'Jira',
92+
config: {
93+
incidentConfiguration: {
94+
mapping: [
95+
{ source: 'title', target: 'summary', actionType: 'overwrite' },
96+
{ source: 'description', target: 'description', actionType: 'overwrite' },
97+
{ source: 'comments', target: 'comments', actionType: 'append' },
98+
],
99+
},
100+
isCaseOwned: true,
101+
apiUrl: 'https://siem-kibana.atlassian.net',
102+
projectKey: 'RJ',
103+
},
104+
isPreconfigured: false,
105+
referencedByCount: 0,
106+
},
107+
{
108+
id: connectorIds.resilient,
109+
actionTypeId: '.resilient',
110+
name: 'Resilient',
111+
config: {
112+
incidentConfiguration: {
113+
mapping: [
114+
{ source: 'title', target: 'name', actionType: 'overwrite' },
115+
{ source: 'description', target: 'description', actionType: 'overwrite' },
116+
{ source: 'comments', target: 'comments', actionType: 'append' },
117+
],
118+
},
119+
isCaseOwned: true,
120+
apiUrl: 'https://ibm-resilient.siem.estc.dev',
121+
orgId: '201',
122+
},
123+
isPreconfigured: false,
124+
referencedByCount: 0,
125+
},
126+
{
127+
id: connectorIds.sn,
128+
actionTypeId: '.servicenow',
129+
name: 'ServiceNow',
130+
config: {
131+
incidentConfiguration: {
132+
mapping: [
133+
{ source: 'title', target: 'short_description', actionType: 'overwrite' },
134+
{ source: 'description', target: 'description', actionType: 'overwrite' },
135+
{ source: 'comments', target: 'comments', actionType: 'append' },
136+
],
137+
},
138+
isCaseOwned: true,
139+
apiUrl: 'https://dev65287.service-now.com',
140+
},
141+
isPreconfigured: false,
142+
referencedByCount: 0,
143+
},
144+
];
145+
export const executeResponses = {
146+
jira: {
147+
issueTypes: {
148+
status: 'ok',
149+
data: [
150+
{ id: '10006', name: 'Task' },
151+
{ id: '10007', name: 'Sub-task' },
152+
],
153+
actionId: connectorIds.jira,
154+
},
155+
fieldsByIssueType: {
156+
status: 'ok',
157+
data: {
158+
summary: { allowedValues: [], defaultValue: {} },
159+
issuetype: {
160+
allowedValues: [
161+
{
162+
self: 'https://siem-kibana.atlassian.net/rest/api/2/issuetype/10006',
163+
id: '10006',
164+
description: 'A small, distinct piece of work.',
165+
iconUrl:
166+
'https://siem-kibana.atlassian.net/secure/viewavatar?size=medium&avatarId=10318&avatarType=issuetype',
167+
name: 'Task',
168+
subtask: false,
169+
avatarId: 10318,
170+
},
171+
],
172+
defaultValue: {},
173+
},
174+
attachment: { allowedValues: [], defaultValue: {} },
175+
duedate: { allowedValues: [], defaultValue: {} },
176+
description: { allowedValues: [], defaultValue: {} },
177+
project: {
178+
allowedValues: [
179+
{
180+
self: 'https://siem-kibana.atlassian.net/rest/api/2/project/10011',
181+
id: '10011',
182+
key: 'RJ',
183+
name: 'Refactor Jira',
184+
projectTypeKey: 'business',
185+
simplified: false,
186+
avatarUrls: {
187+
'48x48':
188+
'https://siem-kibana.atlassian.net/secure/projectavatar?pid=10011&avatarId=10423',
189+
'24x24':
190+
'https://siem-kibana.atlassian.net/secure/projectavatar?size=small&s=small&pid=10011&avatarId=10423',
191+
'16x16':
192+
'https://siem-kibana.atlassian.net/secure/projectavatar?size=xsmall&s=xsmall&pid=10011&avatarId=10423',
193+
'32x32':
194+
'https://siem-kibana.atlassian.net/secure/projectavatar?size=medium&s=medium&pid=10011&avatarId=10423',
195+
},
196+
},
197+
],
198+
defaultValue: {},
199+
},
200+
assignee: { allowedValues: [], defaultValue: {} },
201+
priority: {
202+
allowedValues: [
203+
{
204+
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/1',
205+
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/highest.svg',
206+
name: 'Highest',
207+
id: '1',
208+
},
209+
{
210+
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/2',
211+
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/high.svg',
212+
name: 'High',
213+
id: '2',
214+
},
215+
{
216+
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/3',
217+
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/medium.svg',
218+
name: 'Medium',
219+
id: '3',
220+
},
221+
{
222+
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/4',
223+
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/low.svg',
224+
name: 'Low',
225+
id: '4',
226+
},
227+
{
228+
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/5',
229+
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/lowest.svg',
230+
name: 'Lowest',
231+
id: '5',
232+
},
233+
],
234+
defaultValue: {
235+
self: 'https://siem-kibana.atlassian.net/rest/api/2/priority/3',
236+
iconUrl: 'https://siem-kibana.atlassian.net/images/icons/priorities/medium.svg',
237+
name: 'Medium',
238+
id: '3',
239+
},
240+
},
241+
timetracking: { allowedValues: [], defaultValue: {} },
242+
labels: { allowedValues: [], defaultValue: {} },
243+
},
244+
actionId: connectorIds.jira,
245+
},
246+
},
247+
resilient: {
248+
incidentTypes: {
249+
status: 'ok',
250+
data: [
251+
{ id: 17, name: 'Communication error (fax; email)' },
252+
{ id: 21, name: 'Denial of Service' },
253+
],
254+
actionId: connectorIds.resilient,
255+
},
256+
severity: {
257+
status: 'ok',
258+
data: [
259+
{ id: 4, name: 'Low' },
260+
{ id: 5, name: 'Medium' },
261+
{ id: 6, name: 'High' },
262+
],
263+
actionId: connectorIds.resilient,
264+
},
265+
},
266+
};

x-pack/plugins/security_solution/cypress/screens/case_details.ts

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
export const CASE_ACTIONS_BTN = '[data-test-subj="property-actions-ellipses"]';
8+
79
export const CASE_DETAILS_DESCRIPTION =
810
'[data-test-subj="description-action"] [data-test-subj="user-action-markdown"]';
911

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

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

32+
export const CONNECTOR_CARD_DETAILS = '[data-test-subj="settings-connector-card"]';
33+
34+
export const CONNECTOR_TITLE = '[data-test-subj="settings-connector-card"] span.euiTitle';
35+
36+
export const DELETE_CASE_BTN = '[data-test-subj="property-actions-trash"]';
37+
38+
export const DELETE_CASE_CONFIRMATION_BTN = '[data-test-subj="confirmModalConfirmButton"]';
39+
3040
export const PARTICIPANTS = 1;
3141

3242
export const REPORTER = 0;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { connectorIds } from '../objects/case';
8+
9+
export const CONNECTOR_RESILIENT = `[data-test-subj="connector-settings-resilient"]`;
10+
11+
export const CONNECTOR_SELECTOR = '[data-test-subj="dropdown-connectors"]';
12+
13+
export const SELECT_IMPACT = `[data-test-subj="impactSelect"]`;
14+
15+
export const SELECT_INCIDENT_TYPE = `[data-test-subj="incidentTypeComboBox"] input[data-test-subj="comboBoxSearchInput"]`;
16+
17+
export const SELECT_ISSUE_TYPE = `[data-test-subj="issueTypeSelect"]`;
18+
19+
export const SELECT_JIRA = `[data-test-subj="dropdown-connector-${connectorIds.jira}"]`;
20+
21+
export const SELECT_PRIORITY = `[data-test-subj="prioritySelect"]`;
22+
23+
export const SELECT_RESILIENT = `[data-test-subj="dropdown-connector-${connectorIds.resilient}"]`;
24+
25+
export const SELECT_SEVERITY = `[data-test-subj="severitySelect"]`;
26+
27+
export const SELECT_SN = `[data-test-subj="dropdown-connector-${connectorIds.sn}"]`;
28+
29+
export const SELECT_URGENCY = `[data-test-subj="urgencySelect"]`;

0 commit comments

Comments
 (0)