Skip to content

Commit

Permalink
[SECURITY SOLUTION][INGEST] Task/endpoint list tests (elastic#69419)
Browse files Browse the repository at this point in the history
endpoint func tests for endpoint details to ingest, edit datasource to policy, bug fix for security link
  • Loading branch information
parkiino committed Jun 25, 2020
1 parent 8bc04a9 commit 9b9e322
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => {
};

return (
<CreateDatasourcePageLayout {...layoutProps}>
<CreateDatasourcePageLayout {...layoutProps} data-test-subj="editDataSource">
{isLoadingData ? (
<Loading />
) : loadingError || !agentConfig || !packageInfo ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
<EuiSpacer size="m" />
<EuiBasicTable<Agent>
className="fleet__agentList__table"
data-test-subj="fleetAgentListTable"
loading={isLoading && agentsRequest.isInitialRequest}
hasActions={true}
noItemsMessage={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ export const ConfigureEndpointDatasource = memo<CustomConfigureDatasourceContent
<p>
{from === 'edit' ? (
<LinkToApp
appId="securitySolution"
data-test-subj="editLinkToPolicyDetails"
appId="securitySolution:management"
appPath={policyUrl}
href={`${services.application.getUrlForApp('securitySolution')}${policyUrl}`}
// Cannot use formalUrl here since the code is called in Ingest, which does not use redux
href={`${services.application.getUrlForApp(
'securitySolution:management'
)}${policyUrl}`}
>
<FormattedMessage
id="xpack.securitySolution.endpoint.ingestManager.editDatasource.stepConfigure"
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import { InfraOpsSourceConfigurationProvider } from './infraops_source_configuration';
import { InfraLogSourceConfigurationProvider } from './infra_log_source_configuration';
import { MachineLearningProvider } from './ml';
import { IngestManagerProvider } from './ingest_manager';
import { IngestManagerProvider } from '../../common/services/ingest_manager';
import { ResolverGeneratorProvider } from './resolver';
import { TransformProvider } from './transform';

Expand Down
2 changes: 2 additions & 0 deletions x-pack/test/common/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
*/

import { services as kibanaCommonServices } from '../../../../test/common/services';
import { services as kibanaApiIntegrationServices } from '../../../../test/api_integration/services';

import { SpacesServiceProvider } from './spaces';

export const services = {
...kibanaCommonServices,
supertest: kibanaApiIntegrationServices.supertest,

spaces: SpacesServiceProvider,
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
import { deleteMetadataStream } from '../../../api_integration/apis/endpoint/data_stream_helper';

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['common', 'endpoint', 'header', 'endpointPageUtils']);
Expand All @@ -17,11 +18,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
this.tags('ciGroup7');
const sleep = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
before(async () => {
await esArchiver.load('endpoint/metadata/api_feature');
await esArchiver.load('endpoint/metadata/api_feature', { useCreate: true });
await pageObjects.endpoint.navigateToEndpointList();
});

it('finds title', async () => {
it('finds page title', async () => {
const title = await testSubjects.getVisibleText('pageViewHeaderLeftTitle');
expect(title).to.equal('Endpoints');
});
Expand Down Expand Up @@ -77,54 +78,61 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
expect(tableData).to.eql(expectedData);
});

it('no details flyout when endpoint page displayed', async () => {
it('does not show the details flyout initially', async () => {
await testSubjects.missingOrFail('hostDetailsFlyout');
});

it('display details flyout when the hostname is clicked on', async () => {
await (await testSubjects.find('hostnameCellLink')).click();
await testSubjects.existOrFail('hostDetailsUpperList');
await testSubjects.existOrFail('hostDetailsLowerList');
});
describe('when the hostname is clicked on,', () => {
it('display the details flyout', async () => {
await (await testSubjects.find('hostnameCellLink')).click();
await testSubjects.existOrFail('hostDetailsUpperList');
await testSubjects.existOrFail('hostDetailsLowerList');
});

it('update details flyout when new hostname is clicked on', async () => {
// display flyout for the first host in the list
await (await testSubjects.findAll('hostnameCellLink'))[0].click();
await testSubjects.existOrFail('hostDetailsFlyoutTitle');
const hostDetailTitle0 = await testSubjects.getVisibleText('hostDetailsFlyoutTitle');
// select the 2nd host in the host list
await (await testSubjects.findAll('hostnameCellLink'))[1].click();
await pageObjects.endpoint.waitForVisibleTextToChange(
'hostDetailsFlyoutTitle',
hostDetailTitle0
);
const hostDetailTitle1 = await testSubjects.getVisibleText('hostDetailsFlyoutTitle');
expect(hostDetailTitle1).to.not.eql(hostDetailTitle0);
});
it('updates the details flyout when a new hostname is selected from the list', async () => {
// display flyout for the first host in the list
await (await testSubjects.findAll('hostnameCellLink'))[0].click();
await testSubjects.existOrFail('hostDetailsFlyoutTitle');
const hostDetailTitle0 = await testSubjects.getVisibleText('hostDetailsFlyoutTitle');
// select the 2nd host in the host list
await (await testSubjects.findAll('hostnameCellLink'))[1].click();
await pageObjects.endpoint.waitForVisibleTextToChange(
'hostDetailsFlyoutTitle',
hostDetailTitle0
);
const hostDetailTitle1 = await testSubjects.getVisibleText('hostDetailsFlyoutTitle');
expect(hostDetailTitle1).to.not.eql(hostDetailTitle0);
});

it('has the same flyout info when the same hostname is selected', async () => {
// display flyout for the first host in the list
await (await testSubjects.findAll('hostnameCellLink'))[1].click();
await testSubjects.existOrFail('hostDetailsFlyoutTitle');
const hostDetailTitleInitial = await testSubjects.getVisibleText('hostDetailsFlyoutTitle');
// select the same host in the host list
await (await testSubjects.findAll('hostnameCellLink'))[1].click();
await sleep(500); // give page time to refresh and verify it did not change
const hostDetailTitleNew = await testSubjects.getVisibleText('hostDetailsFlyoutTitle');
expect(hostDetailTitleNew).to.equal(hostDetailTitleInitial);
});

it('details flyout remains the same when current hostname is clicked on', async () => {
// display flyout for the first host in the list
await (await testSubjects.findAll('hostnameCellLink'))[1].click();
await testSubjects.existOrFail('hostDetailsFlyoutTitle');
const hostDetailTitleInitial = await testSubjects.getVisibleText('hostDetailsFlyoutTitle');
// select the same host in the host list
await (await testSubjects.findAll('hostnameCellLink'))[1].click();
await sleep(500); // give page time to refresh and verify it did not change
const hostDetailTitleNew = await testSubjects.getVisibleText('hostDetailsFlyoutTitle');
expect(hostDetailTitleNew).to.equal(hostDetailTitleInitial);
it('navigates to ingest fleet when the Reassign Policy link is clicked', async () => {
await (await testSubjects.find('hostDetailsLinkToIngest')).click();
await testSubjects.existOrFail('fleetAgentListTable');
});
});

describe('no data', () => {
describe('when there is no data,', () => {
before(async () => {
// clear out the data and reload the page
await esArchiver.unload('endpoint/metadata/api_feature');
await deleteMetadataStream(getService);
await pageObjects.endpoint.navigateToEndpointList();
});
after(async () => {
// reload the data so the other tests continue to pass
await esArchiver.load('endpoint/metadata/api_feature');
await esArchiver.load('endpoint/metadata/api_feature', { useCreate: true });
});
it('displays no items found when empty', async () => {
it('displays No items found when empty', async () => {
// get the endpoint list table data and verify message
const [, [noItemsFoundMessage]] = await pageObjects.endpointPageUtils.tableData(
'hostListTable'
Expand Down Expand Up @@ -166,7 +174,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
'Windows 10',
'',
'0',
'00000000-0000-0000-0000-000000000000',
'Default',
'Unknown',
'10.101.149.262606:a000:ffc0:39:11ef:37b9:3371:578c',
'rezzani-7.example.com',
Expand All @@ -175,7 +183,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
});
after(async () => {
await esArchiver.unload('endpoint/metadata/api_feature');
await deleteMetadataStream(getService);
});
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import { FtrProviderContext } from '../../ftr_provider_context';
import { PolicyTestResourceInfo } from '../../services/endpoint_policy';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const pageObjects = getPageObjects(['common', 'endpoint', 'policy', 'endpointPageUtils']);
const pageObjects = getPageObjects([
'common',
'endpoint',
'policy',
'endpointPageUtils',
'ingestManagerCreateDatasource',
]);
const testSubjects = getService('testSubjects');
const policyTestResources = getService('policyTestResources');

Expand Down Expand Up @@ -185,5 +191,38 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
});
});
});

describe('when on Ingest Configurations Edit Datasource page', async () => {
let policyInfo: PolicyTestResourceInfo;
beforeEach(async () => {
// Create a policy and navigate to Ingest app
policyInfo = await policyTestResources.createPolicy();
await pageObjects.ingestManagerCreateDatasource.navigateToAgentConfigEditDatasource(
policyInfo.agentConfig.id,
policyInfo.datasource.id
);
});
afterEach(async () => {
if (policyInfo) {
await policyInfo.cleanup();
}
});
it('should show a link to Policy Details', async () => {
await testSubjects.existOrFail('editLinkToPolicyDetails');
});
it('should navigate to Policy Details when the link is clicked', async () => {
const linkToPolicy = await testSubjects.find('editLinkToPolicyDetails');
await linkToPolicy.click();
await pageObjects.policy.ensureIsOnDetailsPage();
});
it('should allow the user to navigate, edit and save Policy Details', async () => {
await (await testSubjects.find('editLinkToPolicyDetails')).click();
await pageObjects.policy.ensureIsOnDetailsPage();
await pageObjects.endpointPageUtils.clickOnEuiCheckbox('policyWindowsEvent_dns');
await pageObjects.policy.confirmAndSave();

await testSubjects.existOrFail('policyDetailsSuccessMessage');
});
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

import { FtrProviderContext } from '../ftr_provider_context';

export function IngestManagerCreateDatasource({ getService }: FtrProviderContext) {
export function IngestManagerCreateDatasource({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const find = getService('find');
const pageObjects = getPageObjects(['common']);

return {
/**
* Validates that the page shown is the Datasource Craete Page
* Validates that the page shown is the Datasource Create Page
*/
async ensureOnCreatePageOrFail() {
await testSubjects.existOrFail('createDataSource_header');
Expand Down Expand Up @@ -75,5 +76,22 @@ export function IngestManagerCreateDatasource({ getService }: FtrProviderContext
async waitForSaveSuccessNotification() {
await testSubjects.existOrFail('datasourceCreateSuccessToast');
},

/**
* Validates that the page shown is the Datasource Edit Page
*/
async ensureOnEditPageOrFail() {
await testSubjects.existOrFail('editDataSource_header');
},

/**
* Navigates to the Ingest Agent configuration Edit Datasource page
*/
async navigateToAgentConfigEditDatasource(agentConfigId: string, datasourceId: string) {
await pageObjects.common.navigateToApp('ingestManager', {
hash: `/configs/${agentConfigId}/edit-datasource/${datasourceId}`,
});
await this.ensureOnEditPageOrFail();
},
};
}
2 changes: 2 additions & 0 deletions x-pack/test/security_solution_endpoint/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

import { services as xPackFunctionalServices } from '../../functional/services';
import { EndpointPolicyTestResourcesProvider } from './endpoint_policy';
import { IngestManagerProvider } from '../../common/services/ingest_manager';

export const services = {
...xPackFunctionalServices,
policyTestResources: EndpointPolicyTestResourcesProvider,
ingestManager: IngestManagerProvider,
};

0 comments on commit 9b9e322

Please sign in to comment.