-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Functional Test for Resolver fix (#77116) * Final I hope check in for Resolver fix * Fix click * Fix click * Fix click * revert to select the first event * Gzip Data file * removed not zipped file * striped Data file and gziped * removed commented out delete indices * Added query bar to select correct events * removed commented out delete indices * removed commented out delete indices * removed commented out delete indices * removed commented out delete indices Co-authored-by: Elastic Machine <[email protected]> * Update resolver.ts Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
ac81b19
commit 9cb0068
Showing
7 changed files
with
318 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+3.41 KB
x-pack/test/functional/es_archives/endpoint/resolver_tree/data.json.gz
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 197 additions & 0 deletions
197
x-pack/test/security_solution_endpoint/apps/endpoint/resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
/* | ||
* 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 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 queryBar = getService('queryBar'); | ||
|
||
describe('Endpoint Event Resolver', function () { | ||
before(async () => { | ||
await esArchiver.load('endpoint/resolver_tree', { useCreate: true }); | ||
await pageObjects.hosts.navigateToSecurityHostsPage(); | ||
const fromTime = 'Jan 1, 2018 @ 00:00:00.000'; | ||
const toTime = 'now'; | ||
await pageObjects.timePicker.setAbsoluteRange(fromTime, toTime); | ||
await queryBar.setQuery('event.dataset : endpoint.events.file'); | ||
await queryBar.submitQuery(); | ||
await (await testSubjects.find('draggable-content-host.name')).click(); | ||
await testSubjects.existOrFail('header-page-title'); | ||
await (await testSubjects.find('navigation-events')).click(); | ||
await testSubjects.existOrFail('events-viewer-panel'); | ||
await testSubjects.exists('investigate-in-resolver-button', { timeout: 4000 }); | ||
await (await testSubjects.findAll('investigate-in-resolver-button'))[0].click(); | ||
}); | ||
|
||
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(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
x-pack/test/security_solution_endpoint/page_objects/hosts_page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../ftr_provider_context'; | ||
import { deleteEventsStream } from '../../security_solution_endpoint_api_int/apis/data_stream_helper'; | ||
import { deleteAlertsStream } from '../../security_solution_endpoint_api_int/apis/data_stream_helper'; | ||
import { deleteMetadataStream } from '../../security_solution_endpoint_api_int/apis/data_stream_helper'; | ||
import { deletePolicyStream } from '../../security_solution_endpoint_api_int/apis/data_stream_helper'; | ||
import { 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'); | ||
|
||
/** | ||
* @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], | ||
}), | ||
{} | ||
); | ||
return { | ||
/** | ||
* Navigate to the Security Hosts page | ||
*/ | ||
async navigateToSecurityHostsPage() { | ||
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 poluting the array data with the euiTableRowCell__mobileHeader data. | ||
* @param dataTestSubj | ||
* @param element | ||
* @returns Promise<string[][]> | ||
*/ | ||
async getEndpointEventResolverNodeData(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<string[][]> | ||
*/ | ||
async parseStyles() { | ||
const tableData = await this.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. | ||
*/ | ||
async deleteDataStreams() { | ||
await deleteEventsStream(getService); | ||
await deleteAlertsStream(getService); | ||
await deletePolicyStream(getService); | ||
await deleteMetadataStream(getService); | ||
await deleteTelemetryStream(getService); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters