From d124122284b7d9d5525fc89555c607a2637eae8f Mon Sep 17 00:00:00 2001 From: Jonathan Buttner Date: Wed, 10 Mar 2021 11:52:57 -0500 Subject: [PATCH] Removing resolver functional tests --- .../apps/endpoint/index.ts | 1 - .../apps/endpoint/resolver.ts | 280 ------------------ .../page_objects/hosts_page.ts | 243 --------------- .../page_objects/index.ts | 2 - 4 files changed, 526 deletions(-) delete mode 100644 x-pack/test/security_solution_endpoint/apps/endpoint/resolver.ts delete mode 100644 x-pack/test/security_solution_endpoint/page_objects/hosts_page.ts diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts index 4cf931a042221..f28545f83a890 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/index.ts @@ -32,7 +32,6 @@ export default function (providerContext: FtrProviderContext) { }); loadTestFile(require.resolve('./endpoint_list')); loadTestFile(require.resolve('./policy_details')); - loadTestFile(require.resolve('./resolver')); loadTestFile(require.resolve('./endpoint_telemetry')); loadTestFile(require.resolve('./trusted_apps_list')); loadTestFile(require.resolve('./fleet_integrations')); diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/resolver.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/resolver.ts deleted file mode 100644 index 6ab2a3e584eb8..0000000000000 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/resolver.ts +++ /dev/null @@ -1,280 +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 expect from '@kbn/expect'; -import { FtrProviderContext } from '../../ftr_provider_context'; - -export default function ({ getPageObjects, getService }: FtrProviderContext) { - const pageObjects = getPageObjects(['common', 'timePicker', 'hosts', 'settings']); - const testSubjects = getService('testSubjects'); - const esArchiver = getService('esArchiver'); - const browser = getService('browser'); - - /** - * Navigating to the hosts page must be done after data is loaded into ES otherwise - * the hosts page will display the empty default page and if we load data after that - * we'd have to set the source filter on the page. - */ - const navigateToHostsAndSetDate = async () => { - await pageObjects.hosts.navigateToSecurityHostsPage(); - await pageObjects.common.dismissBanner(); - const fromTime = 'Jan 1, 2018 @ 00:00:00.000'; - const toTime = 'now'; - await pageObjects.timePicker.setAbsoluteRange(fromTime, toTime); - }; - - describe.skip('Endpoint Event Resolver', function () { - before(async () => { - await browser.setWindowSize(1800, 1200); - }); - after(async () => { - await pageObjects.hosts.deleteDataStreams(); - }); - - describe('Endpoint Resolver Tree', function () { - before(async () => { - await esArchiver.load('empty_kibana'); - await esArchiver.load('endpoint/resolver_tree/functions', { useCreate: true }); - await navigateToHostsAndSetDate(); - await pageObjects.hosts.executeQueryAndOpenResolver('event.dataset : endpoint.events.file'); - }); - after(async () => { - await pageObjects.hosts.deleteDataStreams(); - }); - - it('check that Resolver and Data table is loaded', async () => { - await testSubjects.existOrFail('resolver:graph'); - await testSubjects.existOrFail('tableHeaderCell_name_0'); - await testSubjects.existOrFail('tableHeaderCell_timestamp_1'); - }); - - it('compare resolver Nodes Table data and Data length', async () => { - const nodeData: string[] = []; - const TableData: string[] = []; - - const Table = await testSubjects.findAll('resolver:node-list:node-link:title'); - for (const value of Table) { - const text = await value._webElement.getText(); - TableData.push(text.split('\n')[0]); - } - await (await testSubjects.find('resolver:graph-controls:zoom-out')).click(); - const Nodes = await testSubjects.findAll('resolver:node:primary-button'); - for (const value of Nodes) { - nodeData.push(await value._webElement.getText()); - } - for (let i = 0; i < nodeData.length; i++) { - expect(TableData[i]).to.eql(nodeData[i]); - } - expect(nodeData.length).to.eql(TableData.length); - await (await testSubjects.find('resolver:graph-controls:zoom-in')).click(); - }); - - it('resolver Nodes navigation Up', async () => { - const OriginalNodeDataStyle = await pageObjects.hosts.parseStyles(); - await (await testSubjects.find('resolver:graph-controls:north-button')).click(); - - const NewNodeDataStyle = await pageObjects.hosts.parseStyles(); - for (let i = 0; i < OriginalNodeDataStyle.length; i++) { - expect(parseFloat(OriginalNodeDataStyle[i].top)).to.lessThan( - parseFloat(NewNodeDataStyle[i].top) - ); - expect(parseFloat(OriginalNodeDataStyle[i].left)).to.equal( - parseFloat(NewNodeDataStyle[i].left) - ); - } - await (await testSubjects.find('resolver:graph-controls:center-button')).click(); - }); - - it('resolver Nodes navigation Down', async () => { - const OriginalNodeDataStyle = await pageObjects.hosts.parseStyles(); - await (await testSubjects.find('resolver:graph-controls:south-button')).click(); - - const NewNodeDataStyle = await pageObjects.hosts.parseStyles(); - for (let i = 0; i < NewNodeDataStyle.length; i++) { - expect(parseFloat(NewNodeDataStyle[i].top)).to.lessThan( - parseFloat(OriginalNodeDataStyle[i].top) - ); - expect(parseFloat(OriginalNodeDataStyle[i].left)).to.equal( - parseFloat(NewNodeDataStyle[i].left) - ); - } - await (await testSubjects.find('resolver:graph-controls:center-button')).click(); - }); - - it('resolver Nodes navigation Left', async () => { - const OriginalNodeDataStyle = await pageObjects.hosts.parseStyles(); - await (await testSubjects.find('resolver:graph-controls:east-button')).click(); - - const NewNodeDataStyle = await pageObjects.hosts.parseStyles(); - for (let i = 0; i < OriginalNodeDataStyle.length; i++) { - expect(parseFloat(NewNodeDataStyle[i].left)).to.lessThan( - parseFloat(OriginalNodeDataStyle[i].left) - ); - expect(parseFloat(NewNodeDataStyle[i].top)).to.equal( - parseFloat(OriginalNodeDataStyle[i].top) - ); - } - await (await testSubjects.find('resolver:graph-controls:center-button')).click(); - }); - - it('resolver Nodes navigation Right', async () => { - const OriginalNodeDataStyle = await pageObjects.hosts.parseStyles(); - await testSubjects.click('resolver:graph-controls:west-button'); - const NewNodeDataStyle = await pageObjects.hosts.parseStyles(); - for (let i = 0; i < NewNodeDataStyle.length; i++) { - expect(parseFloat(OriginalNodeDataStyle[i].left)).to.lessThan( - parseFloat(NewNodeDataStyle[i].left) - ); - expect(parseFloat(NewNodeDataStyle[i].top)).to.equal( - parseFloat(OriginalNodeDataStyle[i].top) - ); - } - await (await testSubjects.find('resolver:graph-controls:center-button')).click(); - }); - - it('resolver Nodes navigation Center', async () => { - const OriginalNodeDataStyle = await pageObjects.hosts.parseStyles(); - await (await testSubjects.find('resolver:graph-controls:east-button')).click(); - await (await testSubjects.find('resolver:graph-controls:south-button')).click(); - - const NewNodeDataStyle = await pageObjects.hosts.parseStyles(); - for (let i = 0; i < NewNodeDataStyle.length; i++) { - expect(parseFloat(NewNodeDataStyle[i].left)).to.lessThan( - parseFloat(OriginalNodeDataStyle[i].left) - ); - expect(parseFloat(NewNodeDataStyle[i].top)).to.lessThan( - parseFloat(OriginalNodeDataStyle[i].top) - ); - } - await (await testSubjects.find('resolver:graph-controls:center-button')).click(); - const CenterNodeDataStyle = await pageObjects.hosts.parseStyles(); - - for (let i = 0; i < CenterNodeDataStyle.length; i++) { - expect(parseFloat(CenterNodeDataStyle[i].left)).to.equal( - parseFloat(OriginalNodeDataStyle[i].left) - ); - expect(parseFloat(CenterNodeDataStyle[i].top)).to.equal( - parseFloat(OriginalNodeDataStyle[i].top) - ); - } - }); - - it('resolver Nodes navigation zoom in', async () => { - const OriginalNodeDataStyle = await pageObjects.hosts.parseStyles(); - await (await testSubjects.find('resolver:graph-controls:zoom-in')).click(); - - const NewNodeDataStyle = await pageObjects.hosts.parseStyles(); - for (let i = 1; i < NewNodeDataStyle.length; i++) { - expect(parseFloat(NewNodeDataStyle[i].left)).to.lessThan( - parseFloat(OriginalNodeDataStyle[i].left) - ); - expect(parseFloat(NewNodeDataStyle[i].top)).to.lessThan( - parseFloat(OriginalNodeDataStyle[i].top) - ); - expect(parseFloat(OriginalNodeDataStyle[i].width)).to.lessThan( - parseFloat(NewNodeDataStyle[i].width) - ); - expect(parseFloat(OriginalNodeDataStyle[i].height)).to.lessThan( - parseFloat(NewNodeDataStyle[i].height) - ); - await (await testSubjects.find('resolver:graph-controls:zoom-out')).click(); - } - }); - - it('resolver Nodes navigation zoom out', async () => { - const OriginalNodeDataStyle = await pageObjects.hosts.parseStyles(); - await (await testSubjects.find('resolver:graph-controls:zoom-out')).click(); - const NewNodeDataStyle1 = await pageObjects.hosts.parseStyles(); - for (let i = 1; i < OriginalNodeDataStyle.length; i++) { - expect(parseFloat(OriginalNodeDataStyle[i].left)).to.lessThan( - parseFloat(NewNodeDataStyle1[i].left) - ); - expect(parseFloat(OriginalNodeDataStyle[i].top)).to.lessThan( - parseFloat(NewNodeDataStyle1[i].top) - ); - expect(parseFloat(NewNodeDataStyle1[i].width)).to.lessThan( - parseFloat(OriginalNodeDataStyle[i].width) - ); - expect(parseFloat(NewNodeDataStyle1[i].height)).to.lessThan( - parseFloat(OriginalNodeDataStyle[i].height) - ); - } - await (await testSubjects.find('resolver:graph-controls:zoom-in')).click(); - }); - }); - - describe('node related event pills', function () { - /** - * Verifies that the pills of a node have the correct text. - * - * @param id the node ID to verify the pills for. - * @param expectedPills a map of expected pills for all nodes - */ - const verifyPills = async (id: string, expectedPills: Set) => { - const relatedEventPills = await pageObjects.hosts.findNodePills(id); - expect(relatedEventPills.length).to.equal(expectedPills.size); - for (const pill of relatedEventPills) { - const pillText = await pill._webElement.getText(); - // check that we have the pill text in our expected map - expect(expectedPills.has(pillText)).to.equal(true); - } - }; - - before(async () => { - await esArchiver.load('empty_kibana'); - await esArchiver.load('endpoint/resolver_tree/alert_events', { useCreate: true }); - await navigateToHostsAndSetDate(); - }); - after(async () => { - await pageObjects.hosts.deleteDataStreams(); - }); - - describe('endpoint.alerts filter', () => { - before(async () => { - await pageObjects.hosts.executeQueryAndOpenResolver('event.dataset : endpoint.alerts'); - await pageObjects.hosts.clickZoomOut(); - await browser.setWindowSize(2100, 1500); - }); - - it('has the correct pill text', async () => { - const expectedData: Map> = new Map([ - [ - 'MTk0YzBmOTgtNjA4My1jNWE4LTYzNjYtZjVkNzI2YWU2YmIyLTc2MzYtMTMyNDc2MTQ0NDIuOTU5MTE2NjAw', - new Set(['1 library']), - ], - [ - 'MTk0YzBmOTgtNjA4My1jNWE4LTYzNjYtZjVkNzI2YWU2YmIyLTMxMTYtMTMyNDcyNDk0MjQuOTg4ODI4NjAw', - new Set(['157 file', '520 registry']), - ], - [ - 'MTk0YzBmOTgtNjA4My1jNWE4LTYzNjYtZjVkNzI2YWU2YmIyLTUwODQtMTMyNDc2MTQ0NDIuOTcyODQ3MjAw', - new Set(), - ], - [ - 'MTk0YzBmOTgtNjA4My1jNWE4LTYzNjYtZjVkNzI2YWU2YmIyLTg2OTYtMTMyNDc2MTQ0MjEuNjc1MzY0OTAw', - new Set(['3 file']), - ], - [ - 'MTk0YzBmOTgtNjA4My1jNWE4LTYzNjYtZjVkNzI2YWU2YmIyLTcyNjAtMTMyNDc2MTQ0MjIuMjQwNDI2MTAw', - new Set(), - ], - [ - 'MTk0YzBmOTgtNjA4My1jNWE4LTYzNjYtZjVkNzI2YWU2YmIyLTczMDAtMTMyNDc2MTQ0MjEuNjg2NzI4NTAw', - new Set(), - ], - ]); - - for (const [id, expectedPills] of expectedData.entries()) { - // center the node in the view - await pageObjects.hosts.clickNodeLinkInPanel(id); - await verifyPills(id, expectedPills); - } - }); - }); - }); - }); -} diff --git a/x-pack/test/security_solution_endpoint/page_objects/hosts_page.ts b/x-pack/test/security_solution_endpoint/page_objects/hosts_page.ts deleted file mode 100644 index e7553e68d670b..0000000000000 --- a/x-pack/test/security_solution_endpoint/page_objects/hosts_page.ts +++ /dev/null @@ -1,243 +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 { WebElementWrapper } from 'test/functional/services/lib/web_element_wrapper'; -import { nudgeAnimationDuration } from '../../../plugins/security_solution/public/resolver/store/camera/scaling_constants'; -import { FtrProviderContext } from '../ftr_provider_context'; -import { - deleteEventsStream, - deleteAlertsStream, - deleteMetadataStream, - deletePolicyStream, - deleteTelemetryStream, -} from '../../security_solution_endpoint_api_int/apis/data_stream_helper'; - -export interface DataStyle { - left: string; - top: string; - width: string; - height: string; -} - -export function SecurityHostsPageProvider({ getService, getPageObjects }: FtrProviderContext) { - const pageObjects = getPageObjects(['common', 'header']); - const testSubjects = getService('testSubjects'); - const queryBar = getService('queryBar'); - const find = getService('find'); - - /** - * Returns the node IDs for the visible nodes in the resolver graph. - */ - const findVisibleNodeIDs = async (): Promise => { - const visibleNodes = await testSubjects.findAll('resolver:node'); - return Promise.all( - visibleNodes.map(async (node: WebElementWrapper) => { - return node.getAttribute('data-test-resolver-node-id'); - }) - ); - }; - - /** - * This assumes you are on the process list in the panel and will find and click the node - * with the given ID to bring it into view in the graph. - * - * @param id the ID of the node to find and click. - */ - const clickNodeLinkInPanel = async (id: string): Promise => { - await navigateToProcessListInPanel(); - const panelNodeButton = await find.byCssSelector( - `[data-test-subj='resolver:node-list:node-link'][data-test-node-id='${id}']` - ); - - await panelNodeButton?.click(); - // ensure that we wait longer than the animation time - await pageObjects.common.sleep(nudgeAnimationDuration * 2); - }; - - /** - * Finds all the pills for a particular node. - * - * @param id the ID of the node - */ - const findNodePills = async (id: string): Promise => { - return testSubjects.findAllDescendant( - 'resolver:map:node-submenu-item', - await find.byCssSelector( - `[data-test-subj='resolver:node'][data-test-resolver-node-id='${id}']` - ) - ); - }; - - /** - * Navigate back to the process list view in the panel. - */ - const navigateToProcessListInPanel = async () => { - const [ - isOnNodeListPage, - isOnCategoryPage, - isOnNodeDetailsPage, - isOnRelatedEventDetailsPage, - ] = await Promise.all([ - testSubjects.exists('resolver:node-list', { timeout: 1 }), - testSubjects.exists('resolver:node-events-in-category:breadcrumbs:node-list-link', { - timeout: 1, - }), - testSubjects.exists('resolver:node-detail:breadcrumbs:node-list-link', { timeout: 1 }), - testSubjects.exists('resolver:event-detail:breadcrumbs:node-list-link', { timeout: 1 }), - ]); - - if (isOnNodeListPage) { - return; - } else if (isOnCategoryPage) { - await ( - await testSubjects.find('resolver:node-events-in-category:breadcrumbs:node-list-link') - ).click(); - } else if (isOnNodeDetailsPage) { - await (await testSubjects.find('resolver:node-detail:breadcrumbs:node-list-link')).click(); - } else if (isOnRelatedEventDetailsPage) { - await (await testSubjects.find('resolver:event-detail:breadcrumbs:node-list-link')).click(); - } else { - // unknown page - return; - } - - await pageObjects.common.sleep(100); - }; - - /** - * Click the zoom out control. - */ - const clickZoomOut = async () => { - await (await testSubjects.find('resolver:graph-controls:zoom-out')).click(); - }; - - /** - * Navigate to Events Panel - */ - const navigateToEventsPanel = async () => { - const isFullScreen = await testSubjects.exists('exit-full-screen', { timeout: 400 }); - if (isFullScreen) { - await (await testSubjects.find('exit-full-screen')).click(); - } - - if (!(await testSubjects.exists('investigate-in-resolver-button', { timeout: 400 }))) { - await (await testSubjects.find('navigation-hosts')).click(); - await testSubjects.click('navigation-events'); - await testSubjects.existOrFail('event'); - } - }; - - /** - * @function parseStyles - * Parses a string of inline styles into a typescript object with casing for react - * @param {string} styles - * @returns {Object} - */ - const parseStyle = ( - styles: string - ): { - left?: string; - top?: string; - width?: string; - height?: string; - } => - styles - .split(';') - .filter((style: string) => style.split(':')[0] && style.split(':')[1]) - .map((style: string) => [ - style - .split(':')[0] - .trim() - .replace(/-./g, (c: string) => c.substr(1).toUpperCase()), - style.split(':').slice(1).join(':').trim(), - ]) - .reduce( - (styleObj: {}, style: string[]) => ({ - ...styleObj, - [style[0]]: style[1], - }), - {} - ); - - /** - * Navigate to the Security Hosts page - */ - const navigateToSecurityHostsPage = async () => { - await pageObjects.common.navigateToUrlWithBrowserHistory('security', '/hosts/AllHosts'); - await pageObjects.header.waitUntilLoadingHasFinished(); - }; - - /** - * Finds a table and returns the data in a nested array with row 0 is the headers if they exist. - * It uses euiTableCellContent to avoid polluting the array data with the euiTableRowCell__mobileHeader data. - * @param dataTestSubj - * @param element - * @returns Promise - */ - const getEndpointEventResolverNodeData = async (dataTestSubj: string, element: string) => { - await testSubjects.exists(dataTestSubj); - const Elements = await testSubjects.findAll(dataTestSubj); - const $ = []; - for (const value of Elements) { - $.push(await value.getAttribute(element)); - } - return $; - }; - - /** - * Gets a array of not parsed styles and returns the Array of parsed styles. - * @returns Promise - */ - const parseStyles = async () => { - const tableData = await getEndpointEventResolverNodeData('resolver:node', 'style'); - const styles: DataStyle[] = []; - for (let i = 1; i < tableData.length; i++) { - const eachStyle = parseStyle(tableData[i]); - styles.push({ - top: eachStyle.top ?? '', - height: eachStyle.height ?? '', - left: eachStyle.left ?? '', - width: eachStyle.width ?? '', - }); - } - return styles; - }; - /** - * Deletes DataStreams from Index Management. - */ - const deleteDataStreams = async () => { - await deleteEventsStream(getService); - await deleteAlertsStream(getService); - await deletePolicyStream(getService); - await deleteMetadataStream(getService); - await deleteTelemetryStream(getService); - }; - - /** - * execute Query And Open Resolver - */ - const executeQueryAndOpenResolver = async (query: string) => { - await navigateToEventsPanel(); - await queryBar.setQuery(query); - await queryBar.submitQuery(); - await testSubjects.click('full-screen'); - await testSubjects.click('investigate-in-resolver-button'); - }; - - return { - navigateToProcessListInPanel, - findNodePills, - clickNodeLinkInPanel, - findVisibleNodeIDs, - clickZoomOut, - navigateToEventsPanel, - navigateToSecurityHostsPage, - parseStyles, - deleteDataStreams, - executeQueryAndOpenResolver, - }; -} diff --git a/x-pack/test/security_solution_endpoint/page_objects/index.ts b/x-pack/test/security_solution_endpoint/page_objects/index.ts index 44c4bb21787a4..961e5ae44716d 100644 --- a/x-pack/test/security_solution_endpoint/page_objects/index.ts +++ b/x-pack/test/security_solution_endpoint/page_objects/index.ts @@ -11,7 +11,6 @@ import { EndpointPolicyPageProvider } from './policy_page'; import { TrustedAppsPageProvider } from './trusted_apps_page'; import { EndpointPageUtils } from './page_utils'; import { IngestManagerCreatePackagePolicy } from './ingest_manager_create_package_policy_page'; -import { SecurityHostsPageProvider } from './hosts_page'; import { FleetIntegrations } from './fleet_integrations_page'; export const pageObjects = { @@ -21,6 +20,5 @@ export const pageObjects = { trustedApps: TrustedAppsPageProvider, endpointPageUtils: EndpointPageUtils, ingestManagerCreatePackagePolicy: IngestManagerCreatePackagePolicy, - hosts: SecurityHostsPageProvider, fleetIntegrations: FleetIntegrations, };