From fdfd5506cb10a11b0372201cc0309d3959c9e1dc Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 15 Oct 2020 13:50:23 -0600 Subject: [PATCH 1/7] adding --- .../security_solution/cypress/objects/case.ts | 204 ++++++++++++++++++ .../cypress/screens/edit_connector.ts | 23 ++ .../cypress/tasks/create_new_case.ts | 37 ++++ 3 files changed, 264 insertions(+) create mode 100644 x-pack/plugins/security_solution/cypress/screens/edit_connector.ts diff --git a/x-pack/plugins/security_solution/cypress/objects/case.ts b/x-pack/plugins/security_solution/cypress/objects/case.ts index 084df31a604a3..4800e486b43bd 100644 --- a/x-pack/plugins/security_solution/cypress/objects/case.ts +++ b/x-pack/plugins/security_solution/cypress/objects/case.ts @@ -44,3 +44,207 @@ export const serviceNowConnector: Connector = { }; export const TIMELINE_CASE_ID = '68248e00-f689-11ea-9ab2-59238b522856'; +export const ids = { + jira: '000e5f86-08b0-4882-adfd-6df981d45c1b', + sn: '93a69ba3-3c31-4b4c-bf86-cc79a090f437', + resilient: 'a6a8dd7f-7e88-48fe-9b9f-70b668da8cbc', +}; + +export const mockConnectorsResponse = [ + { + id: ids.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: ids.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: ids.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 responses = { + jira: { + issueTypes: { + status: 'ok', + data: [ + { id: '10006', name: 'Task' }, + { id: '10007', name: 'Sub-task' }, + ], + actionId: '000e5f86-08b0-4882-adfd-6df981d45c1b', + }, + 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: '000e5f86-08b0-4882-adfd-6df981d45c1b', + }, + }, + resilient: { + incidentTypes: { + status: 'ok', + data: [ + { id: 17, name: 'Communication error (fax; email)' }, + { id: 1001, name: 'Custom type' }, + { id: 21, name: 'Denial of Service' }, + { id: 6, name: 'Improper disposal: digital asset(s)' }, + { id: 7, name: 'Improper disposal: documents / files' }, + { id: 4, name: 'Lost documents / files / records' }, + { id: 3, name: 'Lost PC / laptop / tablet' }, + { id: 1, name: 'Lost PDA / smartphone' }, + { id: 8, name: 'Lost storage device / media' }, + { id: 19, name: 'Malware' }, + { id: 23, name: 'Not an Issue' }, + { id: 18, name: 'Other' }, + { id: 22, name: 'Phishing' }, + { id: 11, name: 'Stolen documents / files / records' }, + { id: 12, name: 'Stolen PC / laptop / tablet' }, + { id: 13, name: 'Stolen PDA / smartphone' }, + { id: 14, name: 'Stolen storage device / media' }, + { id: 20, name: 'System Intrusion' }, + { id: 16, name: 'TBD / Unknown' }, + { id: 15, name: 'Vendor / 3rd party error' }, + ], + actionId: 'a6a8dd7f-7e88-48fe-9b9f-70b668da8cbc', + }, + severity: { + status: 'ok', + data: [ + { id: 4, name: 'Low' }, + { id: 5, name: 'Medium' }, + { id: 6, name: 'High' }, + ], + actionId: 'a6a8dd7f-7e88-48fe-9b9f-70b668da8cbc', + }, + }, +}; diff --git a/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts b/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts new file mode 100644 index 0000000000000..5ac71d4935e5e --- /dev/null +++ b/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts @@ -0,0 +1,23 @@ +/* + * 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 { ids } from '../objects/case'; + +export const CONNECTOR_SELECTOR = '[data-test-subj="dropdown-connectors"]'; +export const SELECT_JIRA = `[data-test-subj="dropdown-connector-${ids.jira}"]`; +export const SELECT_RESILIENT = `[data-test-subj="dropdown-connector-${ids.resilient}"]`; +export const SELECT_SN = `[data-test-subj="dropdown-connector-${ids.sn}"]`; + +export const SELECT_ISSUE_TYPE = `[data-test-subj="issueTypeSelect"]`; +export const SELECT_PRIORITY = `[data-test-subj="prioritySelect"]`; +export const SELECT_INCIDENT_TYPE = `[data-test-subj="incidentTypeComboBox"]`; +export const SELECT_SEVERITY = `[data-test-subj="severitySelect"]`; + +export const SELECT_URGENCY = `[data-test-subj="urgencySelect"]`; + +export const SELECT_IMPACT = `[data-test-subj="impactSelect"]`; + +export const CONNECTOR_TITLE = `[data-test-subj="settings-connector-card"] span.euiTitle`; diff --git a/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts b/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts index f5013eed07d29..7420b507f9e81 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts @@ -16,6 +16,18 @@ import { TIMELINE_SEARCHBOX, TITLE_INPUT, } from '../screens/create_new_case'; +import { + CONNECTOR_SELECTOR, + SELECT_IMPACT, + SELECT_INCIDENT_TYPE, + SELECT_ISSUE_TYPE, + SELECT_JIRA, + SELECT_PRIORITY, + SELECT_RESILIENT, + SELECT_SEVERITY, + SELECT_SN, + SELECT_URGENCY, +} from '../screens/edit_connector'; export const backToCases = () => { cy.get(BACK_TO_CASES_BTN).click({ force: true }); @@ -47,3 +59,28 @@ export const createNewCaseWithTimeline = (newCase: TestCase) => { cy.get(LOADING_SPINNER).should('exist'); cy.get(LOADING_SPINNER).should('not.exist'); }; + +export const createNewCaseWithConnector = (newCase: TestCase) => { + cy.get(TITLE_INPUT).type(newCase.name, { force: true }); + newCase.tags.forEach((tag) => { + cy.get(TAGS_INPUT).type(`${tag}{enter}`, { force: true }); + }); + cy.get(DESCRIPTION_INPUT).type(`${newCase.description} `, { force: true }); + + cy.get(CONNECTOR_SELECTOR).click({ force: true }); + cy.get(SELECT_JIRA).click({ force: true }); + cy.get(SELECT_ISSUE_TYPE).should('exist'); + cy.get(SELECT_PRIORITY).should('exist'); + cy.get(CONNECTOR_SELECTOR).click({ force: true }); + cy.get(SELECT_SN).click({ force: true }); + cy.get(SELECT_SEVERITY).should('exist'); + cy.get(SELECT_URGENCY).should('exist'); + cy.get(SELECT_IMPACT).should('exist'); + cy.get(CONNECTOR_SELECTOR).click({ force: true }); + cy.get(SELECT_RESILIENT).click({ force: true }); + cy.get(SELECT_INCIDENT_TYPE).should('exist'); + cy.get(SELECT_SEVERITY).should('exist'); + cy.get(SUBMIT_BTN).click({ force: true }); + cy.get(LOADING_SPINNER).should('exist'); + cy.get(LOADING_SPINNER).should('not.exist'); +}; From b9b1e5da6080f45c5bfdf086cd10388029aef6f1 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 15 Oct 2020 14:06:01 -0600 Subject: [PATCH 2/7] new file for test --- .../cases_connector_options.spec.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts diff --git a/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts b/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts new file mode 100644 index 0000000000000..c69f376b03705 --- /dev/null +++ b/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts @@ -0,0 +1,39 @@ +/* + * 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, ids, mockConnectorsResponse, responses } from '../objects/case'; +import { createNewCaseWithConnector } from '../tasks/create_new_case'; +import { CONNECTOR_TITLE } from '../screens/edit_connector'; +import { goToCreateNewCase } from '../tasks/all_cases'; +import { CASES_URL } from '../urls/navigation'; + +describe('connectors in case view', () => { + before(() => { + cy.server(); + cy.route('GET', '**/api/cases/configure/connectors/_find', mockConnectorsResponse); + cy.route2('POST', `**/api/actions/action/${ids.jira}/_execute`, (req) => { + const response = + JSON.parse(req.body).params.subAction === 'issueTypes' + ? JSON.stringify(responses.jira.issueTypes) + : JSON.stringify(responses.jira.fieldsByIssueType); + req.reply(response); + }); + cy.route2('POST', `**/api/actions/action/${ids.resilient}/_execute`, (req) => { + const response = + JSON.parse(req.body).params.subAction === 'incidentTypes' + ? JSON.stringify(responses.resilient.incidentTypes) + : JSON.stringify(responses.resilient.severity); + req.reply(response); + }); + }); + it('Configures many connectors in the case', () => { + loginAndWaitForPageWithoutDateRange(CASES_URL); + goToCreateNewCase(); + createNewCaseWithConnector(case1); + cy.get(CONNECTOR_TITLE).should('have.text', 'Resilient'); + }); +}); From d78278eccb353cd7a342aa9ac955fb1871ad7f5d Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 15 Oct 2020 14:08:18 -0600 Subject: [PATCH 3/7] simplify some data --- .../security_solution/cypress/objects/case.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/objects/case.ts b/x-pack/plugins/security_solution/cypress/objects/case.ts index 4800e486b43bd..efa362bbe8dfd 100644 --- a/x-pack/plugins/security_solution/cypress/objects/case.ts +++ b/x-pack/plugins/security_solution/cypress/objects/case.ts @@ -215,25 +215,7 @@ export const responses = { status: 'ok', data: [ { id: 17, name: 'Communication error (fax; email)' }, - { id: 1001, name: 'Custom type' }, { id: 21, name: 'Denial of Service' }, - { id: 6, name: 'Improper disposal: digital asset(s)' }, - { id: 7, name: 'Improper disposal: documents / files' }, - { id: 4, name: 'Lost documents / files / records' }, - { id: 3, name: 'Lost PC / laptop / tablet' }, - { id: 1, name: 'Lost PDA / smartphone' }, - { id: 8, name: 'Lost storage device / media' }, - { id: 19, name: 'Malware' }, - { id: 23, name: 'Not an Issue' }, - { id: 18, name: 'Other' }, - { id: 22, name: 'Phishing' }, - { id: 11, name: 'Stolen documents / files / records' }, - { id: 12, name: 'Stolen PC / laptop / tablet' }, - { id: 13, name: 'Stolen PDA / smartphone' }, - { id: 14, name: 'Stolen storage device / media' }, - { id: 20, name: 'System Intrusion' }, - { id: 16, name: 'TBD / Unknown' }, - { id: 15, name: 'Vendor / 3rd party error' }, ], actionId: 'a6a8dd7f-7e88-48fe-9b9f-70b668da8cbc', }, From 1b8a4db3f1248199fb19babc9ee2b89e6c8034da Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 15 Oct 2020 14:16:38 -0600 Subject: [PATCH 4/7] rename --- .../cypress/integration/cases_connector_options.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts b/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts index c69f376b03705..c0a1b128b6ac8 100644 --- a/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts @@ -11,7 +11,7 @@ import { CONNECTOR_TITLE } from '../screens/edit_connector'; import { goToCreateNewCase } from '../tasks/all_cases'; import { CASES_URL } from '../urls/navigation'; -describe('connectors in case view', () => { +describe('Cases connector incident fields', () => { before(() => { cy.server(); cy.route('GET', '**/api/cases/configure/connectors/_find', mockConnectorsResponse); @@ -30,7 +30,7 @@ describe('connectors in case view', () => { req.reply(response); }); }); - it('Configures many connectors in the case', () => { + it('Correct incident fields show when connector is changed', () => { loginAndWaitForPageWithoutDateRange(CASES_URL); goToCreateNewCase(); createNewCaseWithConnector(case1); From 8668c644e59a4ea92ad9931230d405a538aaaf9a Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Fri, 16 Oct 2020 10:51:35 -0600 Subject: [PATCH 5/7] renaming --- .../cases_connector_options.spec.ts | 18 +++++++++--------- .../security_solution/cypress/objects/case.ts | 18 +++++++++--------- .../cypress/screens/edit_connector.ts | 8 ++++---- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts b/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts index c0a1b128b6ac8..97ad312566124 100644 --- a/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts @@ -5,7 +5,7 @@ */ import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; -import { case1, ids, mockConnectorsResponse, responses } from '../objects/case'; +import { case1, connectorIds, mockConnectorsResponse, executeResponses } from '../objects/case'; import { createNewCaseWithConnector } from '../tasks/create_new_case'; import { CONNECTOR_TITLE } from '../screens/edit_connector'; import { goToCreateNewCase } from '../tasks/all_cases'; @@ -15,19 +15,19 @@ describe('Cases connector incident fields', () => { before(() => { cy.server(); cy.route('GET', '**/api/cases/configure/connectors/_find', mockConnectorsResponse); - cy.route2('POST', `**/api/actions/action/${ids.jira}/_execute`, (req) => { + cy.route2('POST', `**/api/actions/action/${connectorIds.jira}/_execute`, (req) => { const response = JSON.parse(req.body).params.subAction === 'issueTypes' - ? JSON.stringify(responses.jira.issueTypes) - : JSON.stringify(responses.jira.fieldsByIssueType); - req.reply(response); + ? executeResponses.jira.issueTypes + : executeResponses.jira.fieldsByIssueType; + req.reply(JSON.stringify(response)); }); - cy.route2('POST', `**/api/actions/action/${ids.resilient}/_execute`, (req) => { + cy.route2('POST', `**/api/actions/action/${connectorIds.resilient}/_execute`, (req) => { const response = JSON.parse(req.body).params.subAction === 'incidentTypes' - ? JSON.stringify(responses.resilient.incidentTypes) - : JSON.stringify(responses.resilient.severity); - req.reply(response); + ? executeResponses.resilient.incidentTypes + : executeResponses.resilient.severity; + req.reply(JSON.stringify(response)); }); }); it('Correct incident fields show when connector is changed', () => { diff --git a/x-pack/plugins/security_solution/cypress/objects/case.ts b/x-pack/plugins/security_solution/cypress/objects/case.ts index efa362bbe8dfd..4ed7ce64a1092 100644 --- a/x-pack/plugins/security_solution/cypress/objects/case.ts +++ b/x-pack/plugins/security_solution/cypress/objects/case.ts @@ -44,7 +44,7 @@ export const serviceNowConnector: Connector = { }; export const TIMELINE_CASE_ID = '68248e00-f689-11ea-9ab2-59238b522856'; -export const ids = { +export const connectorIds = { jira: '000e5f86-08b0-4882-adfd-6df981d45c1b', sn: '93a69ba3-3c31-4b4c-bf86-cc79a090f437', resilient: 'a6a8dd7f-7e88-48fe-9b9f-70b668da8cbc', @@ -52,7 +52,7 @@ export const ids = { export const mockConnectorsResponse = [ { - id: ids.jira, + id: connectorIds.jira, actionTypeId: '.jira', name: 'Jira', config: { @@ -71,7 +71,7 @@ export const mockConnectorsResponse = [ referencedByCount: 0, }, { - id: ids.resilient, + id: connectorIds.resilient, actionTypeId: '.resilient', name: 'Resilient', config: { @@ -90,7 +90,7 @@ export const mockConnectorsResponse = [ referencedByCount: 0, }, { - id: ids.sn, + id: connectorIds.sn, actionTypeId: '.servicenow', name: 'ServiceNow', config: { @@ -108,7 +108,7 @@ export const mockConnectorsResponse = [ referencedByCount: 0, }, ]; -export const responses = { +export const executeResponses = { jira: { issueTypes: { status: 'ok', @@ -116,7 +116,7 @@ export const responses = { { id: '10006', name: 'Task' }, { id: '10007', name: 'Sub-task' }, ], - actionId: '000e5f86-08b0-4882-adfd-6df981d45c1b', + actionId: connectorIds.jira, }, fieldsByIssueType: { status: 'ok', @@ -207,7 +207,7 @@ export const responses = { timetracking: { allowedValues: [], defaultValue: {} }, labels: { allowedValues: [], defaultValue: {} }, }, - actionId: '000e5f86-08b0-4882-adfd-6df981d45c1b', + actionId: connectorIds.jira, }, }, resilient: { @@ -217,7 +217,7 @@ export const responses = { { id: 17, name: 'Communication error (fax; email)' }, { id: 21, name: 'Denial of Service' }, ], - actionId: 'a6a8dd7f-7e88-48fe-9b9f-70b668da8cbc', + actionId: connectorIds.resilient, }, severity: { status: 'ok', @@ -226,7 +226,7 @@ export const responses = { { id: 5, name: 'Medium' }, { id: 6, name: 'High' }, ], - actionId: 'a6a8dd7f-7e88-48fe-9b9f-70b668da8cbc', + actionId: connectorIds.resilient, }, }, }; diff --git a/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts b/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts index 5ac71d4935e5e..8dee0a2494e63 100644 --- a/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts +++ b/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ids } from '../objects/case'; +import { connectorIds } from '../objects/case'; export const CONNECTOR_SELECTOR = '[data-test-subj="dropdown-connectors"]'; -export const SELECT_JIRA = `[data-test-subj="dropdown-connector-${ids.jira}"]`; -export const SELECT_RESILIENT = `[data-test-subj="dropdown-connector-${ids.resilient}"]`; -export const SELECT_SN = `[data-test-subj="dropdown-connector-${ids.sn}"]`; +export const SELECT_JIRA = `[data-test-subj="dropdown-connector-${connectorIds.jira}"]`; +export const SELECT_RESILIENT = `[data-test-subj="dropdown-connector-${connectorIds.resilient}"]`; +export const SELECT_SN = `[data-test-subj="dropdown-connector-${connectorIds.sn}"]`; export const SELECT_ISSUE_TYPE = `[data-test-subj="issueTypeSelect"]`; export const SELECT_PRIORITY = `[data-test-subj="prioritySelect"]`; From 9ff9fb79f4bcbc35ef008deef40d44f6aa2fd1cc Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Wed, 21 Oct 2020 08:58:15 -0600 Subject: [PATCH 6/7] make selections --- .../cypress/screens/edit_connector.ts | 3 ++- .../cypress/tasks/create_new_case.ts | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts b/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts index 8dee0a2494e63..cdfa0d57c7c24 100644 --- a/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts +++ b/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts @@ -13,7 +13,8 @@ export const SELECT_SN = `[data-test-subj="dropdown-connector-${connectorIds.sn} export const SELECT_ISSUE_TYPE = `[data-test-subj="issueTypeSelect"]`; export const SELECT_PRIORITY = `[data-test-subj="prioritySelect"]`; -export const SELECT_INCIDENT_TYPE = `[data-test-subj="incidentTypeComboBox"]`; +export const SELECT_INCIDENT_TYPE = `[data-test-subj="incidentTypeComboBox"] input[data-test-subj="comboBoxSearchInput"]`; +export const CONNECTOR_RESILIENT = `[data-test-subj="connector-settings-resilient"]`; export const SELECT_SEVERITY = `[data-test-subj="severitySelect"]`; export const SELECT_URGENCY = `[data-test-subj="urgencySelect"]`; diff --git a/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts b/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts index 7420b507f9e81..de7e88ccae1fc 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TestCase } from '../objects/case'; +import { executeResponses, TestCase } from '../objects/case'; import { BACK_TO_CASES_BTN, @@ -17,6 +17,7 @@ import { TITLE_INPUT, } from '../screens/create_new_case'; import { + CONNECTOR_RESILIENT, CONNECTOR_SELECTOR, SELECT_IMPACT, SELECT_INCIDENT_TYPE, @@ -70,16 +71,30 @@ export const createNewCaseWithConnector = (newCase: TestCase) => { cy.get(CONNECTOR_SELECTOR).click({ force: true }); cy.get(SELECT_JIRA).click({ force: true }); cy.get(SELECT_ISSUE_TYPE).should('exist'); + cy.get(SELECT_PRIORITY).should('exist'); + cy.get(SELECT_ISSUE_TYPE).select('10006'); + cy.get(SELECT_PRIORITY).select('High'); cy.get(CONNECTOR_SELECTOR).click({ force: true }); cy.get(SELECT_SN).click({ force: true }); cy.get(SELECT_SEVERITY).should('exist'); cy.get(SELECT_URGENCY).should('exist'); cy.get(SELECT_IMPACT).should('exist'); + cy.get(SELECT_URGENCY).select('2'); + cy.get(SELECT_SEVERITY).select('1'); + cy.get(SELECT_IMPACT).select('3'); cy.get(CONNECTOR_SELECTOR).click({ force: true }); cy.get(SELECT_RESILIENT).click({ force: true }); cy.get(SELECT_INCIDENT_TYPE).should('exist'); cy.get(SELECT_SEVERITY).should('exist'); + cy.get( + SELECT_INCIDENT_TYPE + ).type(`${executeResponses.resilient.incidentTypes.data[0].name}{enter}`, { force: true }); + cy.get( + SELECT_INCIDENT_TYPE + ).type(`${executeResponses.resilient.incidentTypes.data[1].name}{enter}`, { force: true }); + cy.get(CONNECTOR_RESILIENT).click(); + cy.get(SELECT_SEVERITY).select('5'); cy.get(SUBMIT_BTN).click({ force: true }); cy.get(LOADING_SPINNER).should('exist'); cy.get(LOADING_SPINNER).should('not.exist'); From f5f33c4ff614ebdab2c5d485d5655b45b3fd96d3 Mon Sep 17 00:00:00 2001 From: Gloria Hornero Date: Sat, 28 Nov 2020 19:16:29 +0100 Subject: [PATCH 7/7] refactor --- .../cypress/integration/cases.spec.ts | 11 +++- .../cases_connector_options.spec.ts | 43 ++++++++++-- .../security_solution/cypress/objects/case.ts | 34 ++++++++++ .../cypress/screens/case_details.ts | 10 +++ .../cypress/screens/edit_connector.ts | 23 ++++--- .../cypress/tasks/case_details.ts | 13 +++- .../cypress/tasks/create_new_case.ts | 65 +++++++++---------- 7 files changed, 147 insertions(+), 52 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/integration/cases.spec.ts b/x-pack/plugins/security_solution/cypress/integration/cases.spec.ts index ec3887ad72625..b32402851ac7c 100644 --- a/x-pack/plugins/security_solution/cypress/integration/cases.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/cases.spec.ts @@ -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'; @@ -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'); diff --git a/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts b/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts index 97ad312566124..f227042a0f9dc 100644 --- a/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/cases_connector_options.spec.ts @@ -5,11 +5,26 @@ */ import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; -import { case1, connectorIds, mockConnectorsResponse, executeResponses } from '../objects/case'; -import { createNewCaseWithConnector } from '../tasks/create_new_case'; -import { CONNECTOR_TITLE } from '../screens/edit_connector'; +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(() => { @@ -30,10 +45,28 @@ describe('Cases connector incident fields', () => { req.reply(JSON.stringify(response)); }); }); + + after(() => { + deleteCase(); + }); + it('Correct incident fields show when connector is changed', () => { loginAndWaitForPageWithoutDateRange(CASES_URL); goToCreateNewCase(); - createNewCaseWithConnector(case1); - cy.get(CONNECTOR_TITLE).should('have.text', 'Resilient'); + 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 + }` + ); }); }); diff --git a/x-pack/plugins/security_solution/cypress/objects/case.ts b/x-pack/plugins/security_solution/cypress/objects/case.ts index 4ed7ce64a1092..01e9a9124ca88 100644 --- a/x-pack/plugins/security_solution/cypress/objects/case.ts +++ b/x-pack/plugins/security_solution/cypress/objects/case.ts @@ -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', @@ -43,6 +60,23 @@ 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', diff --git a/x-pack/plugins/security_solution/cypress/screens/case_details.ts b/x-pack/plugins/security_solution/cypress/screens/case_details.ts index 7b995f5395543..02ec74aaed29c 100644 --- a/x-pack/plugins/security_solution/cypress/screens/case_details.ts +++ b/x-pack/plugins/security_solution/cypress/screens/case_details.ts @@ -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"]'; @@ -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; diff --git a/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts b/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts index cdfa0d57c7c24..c0ae4f94c541b 100644 --- a/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts +++ b/x-pack/plugins/security_solution/cypress/screens/edit_connector.ts @@ -6,19 +6,24 @@ 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_JIRA = `[data-test-subj="dropdown-connector-${connectorIds.jira}"]`; -export const SELECT_RESILIENT = `[data-test-subj="dropdown-connector-${connectorIds.resilient}"]`; -export const SELECT_SN = `[data-test-subj="dropdown-connector-${connectorIds.sn}"]`; + +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_INCIDENT_TYPE = `[data-test-subj="incidentTypeComboBox"] input[data-test-subj="comboBoxSearchInput"]`; -export const CONNECTOR_RESILIENT = `[data-test-subj="connector-settings-resilient"]`; -export const SELECT_SEVERITY = `[data-test-subj="severitySelect"]`; -export const SELECT_URGENCY = `[data-test-subj="urgencySelect"]`; +export const SELECT_RESILIENT = `[data-test-subj="dropdown-connector-${connectorIds.resilient}"]`; -export const SELECT_IMPACT = `[data-test-subj="impactSelect"]`; +export const SELECT_SEVERITY = `[data-test-subj="severitySelect"]`; -export const CONNECTOR_TITLE = `[data-test-subj="settings-connector-card"] span.euiTitle`; +export const SELECT_SN = `[data-test-subj="dropdown-connector-${connectorIds.sn}"]`; + +export const SELECT_URGENCY = `[data-test-subj="urgencySelect"]`; diff --git a/x-pack/plugins/security_solution/cypress/tasks/case_details.ts b/x-pack/plugins/security_solution/cypress/tasks/case_details.ts index 976d568ab3a91..51850997c3685 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/case_details.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/case_details.ts @@ -5,7 +5,18 @@ */ import { TIMELINE_TITLE } from '../screens/timeline'; -import { CASE_DETAILS_TIMELINE_LINK_MARKDOWN } from '../screens/case_details'; +import { + CASE_ACTIONS_BTN, + CASE_DETAILS_TIMELINE_LINK_MARKDOWN, + DELETE_CASE_BTN, + DELETE_CASE_CONFIRMATION_BTN, +} from '../screens/case_details'; + +export const deleteCase = () => { + cy.get(CASE_ACTIONS_BTN).first().click(); + cy.get(DELETE_CASE_BTN).click(); + cy.get(DELETE_CASE_CONFIRMATION_BTN).click(); +}; export const openCaseTimeline = () => { cy.get(CASE_DETAILS_TIMELINE_LINK_MARKDOWN).click(); diff --git a/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts b/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts index de7e88ccae1fc..39654fd115a4a 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/create_new_case.ts @@ -4,7 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { executeResponses, TestCase } from '../objects/case'; +import { + IbmResilientConnectorOptions, + JiraConnectorOptions, + ServiceNowconnectorOptions, + TestCase, +} from '../objects/case'; import { BACK_TO_CASES_BTN, @@ -34,68 +39,58 @@ export const backToCases = () => { cy.get(BACK_TO_CASES_BTN).click({ force: true }); }; -export const createNewCase = (newCase: TestCase) => { +export const fillCasesMandatoryfields = (newCase: TestCase) => { cy.get(TITLE_INPUT).type(newCase.name, { force: true }); newCase.tags.forEach((tag) => { cy.get(TAGS_INPUT).type(`${tag}{enter}`, { force: true }); }); cy.get(DESCRIPTION_INPUT).type(`${newCase.description} `, { force: true }); - - cy.get(SUBMIT_BTN).click({ force: true }); - cy.get(LOADING_SPINNER).should('exist'); - cy.get(LOADING_SPINNER).should('not.exist'); }; -export const createNewCaseWithTimeline = (newCase: TestCase) => { - cy.get(TITLE_INPUT).type(newCase.name, { force: true }); - newCase.tags.forEach((tag) => { - cy.get(TAGS_INPUT).type(`${tag}{enter}`, { force: true }); - }); - cy.get(DESCRIPTION_INPUT).type(`${newCase.description} `, { force: true }); - +export const attachTimeline = (newCase: TestCase) => { cy.get(INSERT_TIMELINE_BTN).click({ force: true }); cy.get(TIMELINE_SEARCHBOX).type(`${newCase.timeline.title}{enter}`); +}; +export const createCase = () => { cy.get(SUBMIT_BTN).click({ force: true }); cy.get(LOADING_SPINNER).should('exist'); cy.get(LOADING_SPINNER).should('not.exist'); }; -export const createNewCaseWithConnector = (newCase: TestCase) => { - cy.get(TITLE_INPUT).type(newCase.name, { force: true }); - newCase.tags.forEach((tag) => { - cy.get(TAGS_INPUT).type(`${tag}{enter}`, { force: true }); - }); - cy.get(DESCRIPTION_INPUT).type(`${newCase.description} `, { force: true }); - +export const fillJiraConnectorOptions = (jiraConnector: JiraConnectorOptions) => { cy.get(CONNECTOR_SELECTOR).click({ force: true }); cy.get(SELECT_JIRA).click({ force: true }); cy.get(SELECT_ISSUE_TYPE).should('exist'); cy.get(SELECT_PRIORITY).should('exist'); - cy.get(SELECT_ISSUE_TYPE).select('10006'); - cy.get(SELECT_PRIORITY).select('High'); + cy.get(SELECT_ISSUE_TYPE).select(jiraConnector.issueType); + cy.get(SELECT_PRIORITY).select(jiraConnector.priority); +}; + +export const fillServiceNowConnectorOptions = ( + serviceNowConnectorOpions: ServiceNowconnectorOptions +) => { cy.get(CONNECTOR_SELECTOR).click({ force: true }); cy.get(SELECT_SN).click({ force: true }); cy.get(SELECT_SEVERITY).should('exist'); cy.get(SELECT_URGENCY).should('exist'); cy.get(SELECT_IMPACT).should('exist'); - cy.get(SELECT_URGENCY).select('2'); - cy.get(SELECT_SEVERITY).select('1'); - cy.get(SELECT_IMPACT).select('3'); + cy.get(SELECT_URGENCY).select(serviceNowConnectorOpions.urgency); + cy.get(SELECT_SEVERITY).select(serviceNowConnectorOpions.severity); + cy.get(SELECT_IMPACT).select(serviceNowConnectorOpions.impact); +}; + +export const fillIbmResilientConnectorOptions = ( + ibmResilientConnector: IbmResilientConnectorOptions +) => { cy.get(CONNECTOR_SELECTOR).click({ force: true }); cy.get(SELECT_RESILIENT).click({ force: true }); cy.get(SELECT_INCIDENT_TYPE).should('exist'); cy.get(SELECT_SEVERITY).should('exist'); - cy.get( - SELECT_INCIDENT_TYPE - ).type(`${executeResponses.resilient.incidentTypes.data[0].name}{enter}`, { force: true }); - cy.get( - SELECT_INCIDENT_TYPE - ).type(`${executeResponses.resilient.incidentTypes.data[1].name}{enter}`, { force: true }); + ibmResilientConnector.incidentTypes.forEach((incidentType) => { + cy.get(SELECT_INCIDENT_TYPE).type(`${incidentType}{enter}`, { force: true }); + }); cy.get(CONNECTOR_RESILIENT).click(); - cy.get(SELECT_SEVERITY).select('5'); - cy.get(SUBMIT_BTN).click({ force: true }); - cy.get(LOADING_SPINNER).should('exist'); - cy.get(LOADING_SPINNER).should('not.exist'); + cy.get(SELECT_SEVERITY).select(ibmResilientConnector.severity); };