From 6103c28889ff81ef970ccc3804e52d406c9ed8e9 Mon Sep 17 00:00:00 2001 From: Paul Tavares <56442535+paul-tavares@users.noreply.github.com> Date: Tue, 27 Feb 2024 15:59:59 -0500 Subject: [PATCH] [Security Solution][Endpoint] Un-skip response console Cy tests (#177726) ## Summary - Deletes test file `cases_response_console.cy.ts` - duplicate test. Coverage already exists under `responder.cy.ts` - Fixes #172720 ) - unskips repsonder test - Fixes #169894 --- .../cases_response_console.cy.ts | 123 ------------------ .../e2e/response_actions/responder.cy.ts | 11 +- 2 files changed, 3 insertions(+), 131 deletions(-) delete mode 100644 x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/cases_response_console.cy.ts diff --git a/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/cases_response_console.cy.ts b/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/cases_response_console.cy.ts deleted file mode 100644 index 573d3749c7391..0000000000000 --- a/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/cases_response_console.cy.ts +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { loadPage } from '../../tasks/common'; -import { closeAllToasts } from '../../tasks/toasts'; -import { - addAlertToCase, - getAlertsTableRows, - openAlertDetailsView, - openResponderFromEndpointAlertDetails, -} from '../../screens/alerts'; -import { ensureOnResponder } from '../../screens/responder'; -import { cleanupCase, cleanupRule, loadCase, loadRule } from '../../tasks/api_fixtures'; -import type { PolicyData } from '../../../../../common/endpoint/types'; -import type { CreateAndEnrollEndpointHostResponse } from '../../../../../scripts/endpoint/common/endpoint_host_services'; -import { waitForEndpointListPageToBeLoaded } from '../../tasks/response_console'; -import type { IndexedFleetEndpointPolicyResponse } from '../../../../../common/endpoint/data_loaders/index_fleet_endpoint_policy'; -import { createAgentPolicyTask, getEndpointIntegrationVersion } from '../../tasks/fleet'; -import { openCaseAlertDetails, toggleRuleOffAndOn, visitRuleAlerts } from '../../tasks/isolate'; - -import { login } from '../../tasks/login'; -import { enableAllPolicyProtections } from '../../tasks/endpoint_policy'; -import { createEndpointHost } from '../../tasks/create_endpoint_host'; -import { deleteAllLoadedEndpointData } from '../../tasks/delete_all_endpoint_data'; -import { APP_CASES_PATH } from '../../../../../common/constants'; - -// TIMING OUT: https://github.com/elastic/kibana/issues/172720 -describe.skip('Response console', { tags: ['@ess', '@serverless', '@brokenInServerless'] }, () => { - let indexedPolicy: IndexedFleetEndpointPolicyResponse; - let policy: PolicyData; - let createdHost: CreateAndEnrollEndpointHostResponse; - - before(() => { - getEndpointIntegrationVersion().then((version) => - createAgentPolicyTask(version).then((data) => { - indexedPolicy = data; - policy = indexedPolicy.integrationPolicies[0]; - - return enableAllPolicyProtections(policy.id).then(() => { - // Create and enroll a new Endpoint host - return createEndpointHost(policy.policy_id).then((host) => { - createdHost = host as CreateAndEnrollEndpointHostResponse; - }); - }); - }) - ); - }); - - beforeEach(() => { - login(); - }); - - after(() => { - if (createdHost) { - cy.task('destroyEndpointHost', createdHost); - } - - if (indexedPolicy) { - cy.task('deleteIndexedFleetEndpointPolicies', indexedPolicy); - } - - if (createdHost) { - deleteAllLoadedEndpointData({ endpointAgentIds: [createdHost.agentId] }); - } - }); - - describe('From Cases', () => { - let ruleId: string; - let ruleName: string; - let caseId: string; - const caseOwner = 'securitySolution'; - - beforeEach(() => { - loadRule( - { query: `agent.name: ${createdHost.hostname} and agent.type: endpoint` }, - false - ).then((data) => { - ruleId = data.id; - ruleName = data.name; - }); - loadCase(caseOwner).then((data) => { - caseId = data.id; - }); - }); - - afterEach(() => { - if (ruleId) { - cleanupRule(ruleId); - } - if (caseId) { - cleanupCase(caseId); - } - }); - - it('should open responder', () => { - waitForEndpointListPageToBeLoaded(createdHost.hostname); - toggleRuleOffAndOn(ruleName); - visitRuleAlerts(ruleName); - closeAllToasts(); - - getAlertsTableRows().should('have.length.greaterThan', 0); - openAlertDetailsView(); - addAlertToCase(caseId, caseOwner); - - // visit case details page - cy.intercept('GET', `/api/cases/${caseId}/user_actions/_find*`).as('case'); - loadPage(`${APP_CASES_PATH}/${caseId}`); - - cy.wait('@case', { timeout: 30000 }).then(({ response: res }) => { - const caseAlertId = res?.body.userActions[1].id; - closeAllToasts(); - openCaseAlertDetails(caseAlertId); - }); - - openResponderFromEndpointAlertDetails(); - ensureOnResponder(); - }); - }); -}); diff --git a/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/responder.cy.ts b/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/responder.cy.ts index ebcac6dd439df..e737779ad8ff9 100644 --- a/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/responder.cy.ts +++ b/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/responder.cy.ts @@ -36,12 +36,11 @@ describe('When accessing Endpoint Response Console', { tags: ['@ess', '@serverle closeResponder(); }; - before(() => { + beforeEach(() => { login(); }); - // FLAKY: https://github.com/elastic/kibana/issues/169894 - describe.skip('from Cases', () => { + describe('from Cases', () => { let endpointData: ReturnTypeFromChainable; let caseData: ReturnTypeFromChainable; let alertData: ReturnTypeFromChainable; @@ -51,7 +50,7 @@ describe('When accessing Endpoint Response Console', { tags: ['@ess', '@serverle const openCaseAlertDetails = () => { cy.getByTestSubj(`comment-action-show-alert-${caseAlertActions.comments[alertId]}`).click(); - cy.getByTestSubj('take-action-dropdown-btn').click(); + return cy.getByTestSubj('take-action-dropdown-btn').click(); }; before(() => { @@ -100,10 +99,6 @@ describe('When accessing Endpoint Response Console', { tags: ['@ess', '@serverle } }); - beforeEach(() => { - login(); - }); - it('should display responder option in take action menu', () => { loadPage(caseUrlPath); closeAllToasts();