Skip to content

Commit

Permalink
[Security Solution][Resolver] Fixing resolver functional tests (#85647)…
Browse files Browse the repository at this point in the history
… (#85956)

* Fixing resolver functional tests

* Import the animation constant

* Only check specific nodes instead of all the ones in view

* Removing check for link text

* updating test description

* Adding comments
# Conflicts:
#	x-pack/test/security_solution_endpoint/apps/endpoint/resolver.ts
#	x-pack/test/security_solution_endpoint/page_objects/hosts_page.ts

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
jonathan-buttner and kibanamachine authored Dec 15, 2020
1 parent e968d2b commit 0657dda
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* eslint-disable react/display-name */

import React, { memo, useMemo, Fragment } from 'react';
import React, { memo, useMemo, Fragment, HTMLAttributes } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiSpacer, EuiText, EuiDescriptionList, EuiTextColor, EuiTitle } from '@elastic/eui';
Expand Down Expand Up @@ -246,14 +246,20 @@ function EventDetailBreadcrumbs({
panelParameters: { nodeID, eventCategory: breadcrumbEventCategory },
});
const breadcrumbs = useMemo(() => {
const crumbs = [
const crumbs: Array<
{
text: JSX.Element | string;
'data-test-subj'?: string;
} & HTMLAttributes<HTMLAnchorElement>
> = [
{
text: i18n.translate(
'xpack.securitySolution.endpoint.resolver.panel.relatedEventDetail.events',
{
defaultMessage: 'Events',
}
),
'data-test-subj': 'resolver:event-detail:breadcrumbs:node-list-link',
...nodesLinkNavProps,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ const NodeEventsInCategoryBreadcrumbs = memo(function ({
defaultMessage: 'Events',
}
),
'data-test-subj': 'resolver:node-events-in-category:breadcrumbs:node-list-link',
...nodesLinkNavProps,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,11 @@ export const ColumnHeadersComponent = ({
}
className={fullScreen ? FULL_SCREEN_TOGGLED_CLASS_NAME : ''}
color={fullScreen ? 'ghost' : 'primary'}
data-test-subj="full-screen"
data-test-subj={
// a full screen button gets created for timeline and for the host page
// this sets the data-test-subj for each case so that tests can differentiate between them
timelineId === TimelineId.active ? 'full-screen-active' : 'full-screen'
}
iconType="fullScreen"
onClick={toggleFullScreen}
/>
Expand Down
149 changes: 58 additions & 91 deletions x-pack/test/security_solution_endpoint/apps/endpoint/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const esArchiver = getService('esArchiver');
const browser = getService('browser');
const queryBar = getService('queryBar');

// FLAKY: https://github.com/elastic/kibana/issues/85085
describe.skip('Endpoint Event Resolver', function () {
describe('Endpoint Event Resolver', function () {
before(async () => {
await pageObjects.hosts.navigateToSecurityHostsPage();
await pageObjects.common.dismissBanner();
Expand All @@ -28,7 +26,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
before(async () => {
await esArchiver.load('empty_kibana');
await esArchiver.load('endpoint/resolver_tree/functions', { useCreate: true });
await pageObjects.hosts.navigateToEventsPanel();
await pageObjects.hosts.executeQueryAndOpenResolver('event.dataset : endpoint.events.file');
});
after(async () => {
Expand Down Expand Up @@ -194,104 +191,74 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
}
await (await testSubjects.find('resolver:graph-controls:zoom-in')).click();
});

it('Check Related Events for event.file Node', async () => {
const expectedData = [
'17 authentication',
'1 registry',
'17 session',
'8 file',
'1 registry',
];
await pageObjects.hosts.runNodeEvents(expectedData);
});
});

describe('Resolver Tree events', function () {
const expectedData = [
'17 authentication',
'1 registry',
'17 session',
'80 registry',
'8 network',
'60 registry',
];
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<string>) => {
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/events', { useCreate: true });
await queryBar.setQuery('');
await queryBar.submitQuery();
await esArchiver.load('endpoint/resolver_tree/alert_events', { useCreate: true });
});
after(async () => {
await pageObjects.hosts.deleteDataStreams();
});

it('Check Related Events for event.process Node', async () => {
await pageObjects.hosts.navigateToEventsPanel();
await pageObjects.hosts.executeQueryAndOpenResolver(
'event.dataset : endpoint.events.process'
);
await pageObjects.hosts.runNodeEvents(expectedData);
});

it('Check Related Events for event.security Node', async () => {
await pageObjects.hosts.navigateToEventsPanel();
await pageObjects.hosts.executeQueryAndOpenResolver(
'event.dataset : endpoint.events.security'
);
await pageObjects.hosts.runNodeEvents(expectedData);
});

it('Check Related Events for event.registry Node', async () => {
await pageObjects.hosts.navigateToEventsPanel();
await pageObjects.hosts.executeQueryAndOpenResolver(
'event.dataset : endpoint.events.registry'
);
await pageObjects.hosts.runNodeEvents(expectedData);
});

it('Check Related Events for event.network Node', async () => {
await pageObjects.hosts.navigateToEventsPanel();
await pageObjects.hosts.executeQueryAndOpenResolver(
'event.dataset : endpoint.events.network'
);
await pageObjects.hosts.runNodeEvents(expectedData);
});
describe('endpoint.alerts filter', () => {
before(async () => {
await pageObjects.hosts.executeQueryAndOpenResolver('event.dataset : endpoint.alerts');
await pageObjects.hosts.clickZoomOut();
await browser.setWindowSize(2100, 1500);
});

it('Check Related Events for event.library Node', async () => {
await esArchiver.load('empty_kibana');
await esArchiver.load('endpoint/resolver_tree/library_events', { useCreate: true });
await queryBar.setQuery('');
await queryBar.submitQuery();
const expectedLibraryData = ['329 network', '1 library', '1 library'];
await pageObjects.hosts.navigateToEventsPanel();
await pageObjects.hosts.executeQueryAndOpenResolver(
'event.dataset : endpoint.events.library'
);
await pageObjects.hosts.runNodeEvents(expectedLibraryData);
});
it('has the correct pill text', async () => {
const expectedData: Map<string, Set<string>> = 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(),
],
]);

it('Check Related Events for event.alert Node', async () => {
await esArchiver.load('empty_kibana');
await esArchiver.load('endpoint/resolver_tree/alert_events', { useCreate: true });
await queryBar.setQuery('');
await queryBar.submitQuery();
const expectedAlertData = [
'1 library',
'157 file',
'520 registry',
'3 file',
'5 library',
'5 library',
];
await pageObjects.hosts.navigateToEventsPanel();
await pageObjects.hosts.executeQueryAndOpenResolver('event.dataset : endpoint.alerts');
await (await testSubjects.find('resolver:graph-controls:zoom-out')).click();
await browser.setWindowSize(2100, 1500);
for (let i = 0; i < 3; i++) {
await (await testSubjects.find('resolver:graph-controls:east-button')).click();
}
await pageObjects.hosts.runNodeEvents(expectedAlertData);
for (const [id, expectedPills] of expectedData.entries()) {
// center the node in the view
await pageObjects.hosts.clickNodeLinkInPanel(id);
await verifyPills(id, expectedPills);
}
});
});
});
});
Expand Down
Loading

0 comments on commit 0657dda

Please sign in to comment.