Skip to content

Commit

Permalink
[Cases] Automate serverless security screenshots (elastic#174556)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl authored and delanni committed Jan 11, 2024
1 parent 2f74cd8 commit 928e4f0
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 0 deletions.
1 change: 1 addition & 0 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ enabled:
- x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group5.ts
- x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group6.ts
- x-pack/test_serverless/functional/test_suites/observability/config.screenshots.ts
- x-pack/test_serverless/functional/test_suites/security/config.screenshots.ts
- x-pack/test_serverless/functional/test_suites/search/config.ts
- x-pack/test_serverless/functional/test_suites/search/config.examples.ts
- x-pack/test_serverless/functional/test_suites/search/config.screenshots.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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 { createTestConfig } from '../../config.base';

export default createTestConfig({
serverlessProject: 'security',
testFiles: [require.resolve('./screenshot_creation')],
junit: {
reportName: 'Serverless Security Screenshot Creation',
},

esServerArgs: ['xpack.ml.ad.enabled=false', 'xpack.ml.dfa.enabled=false'],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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 { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('Screenshots - serverless security UI', function () {
loadTestFile(require.resolve('./response_ops_docs'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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 { FtrProviderContext } from '../../../../../ftr_provider_context';

export default function ({ loadTestFile, getService }: FtrProviderContext) {
const browser = getService('browser');

describe('security cases', function () {
before(async () => {
await browser.setWindowSize(1920, 1080);
});

loadTestFile(require.resolve('./list_view'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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 { SECURITY_SOLUTION_OWNER } from '@kbn/cases-plugin/common';
import { CaseSeverity } from '@kbn/cases-plugin/common/types/domain';
import { FtrProviderContext } from '../../../../../ftr_provider_context';
import { navigateToCasesApp } from '../../../../../../shared/lib/cases';

export default function ({ getPageObject, getPageObjects, getService }: FtrProviderContext) {
const cases = getService('cases');
const pageObjects = getPageObjects(['common', 'header', 'svlCommonPage']);
const svlCases = getService('svlCases');
const svlCommonScreenshots = getService('svlCommonScreenshots');
const screenshotDirectories = ['response_ops_docs', 'security_cases'];
const testSubjects = getService('testSubjects');
const owner = SECURITY_SOLUTION_OWNER;
let caseIdSuspiciousEmail: string;

describe('list view', function () {
before(async () => {
await svlCases.api.createCase(
svlCases.api.getPostCaseRequest(owner, {
title: 'Unusual processes identified',
tags: ['linux', 'os processes'],
description: 'Test.',
owner,
severity: CaseSeverity.HIGH,
})
);

const caseSuspiciousEmail = await svlCases.api.createCase(
svlCases.api.getPostCaseRequest(owner, {
title: 'Suspicious emails reported',
tags: ['email', 'phishing'],
description: 'Several employees have received suspicious emails from an unknown address.',
owner,
})
);
caseIdSuspiciousEmail = caseSuspiciousEmail.id;

await svlCases.api.createCase(
svlCases.api.getPostCaseRequest(owner, {
title: 'Malware investigation',
tags: ['malware'],
description: 'Test.',
owner,
severity: CaseSeverity.MEDIUM,
})
);
});

after(async () => {
await svlCases.api.deleteAllCaseItems();
await pageObjects.svlCommonPage.forceLogout();
});

beforeEach(async () => {
await pageObjects.svlCommonPage.login();
});

it('cases list screenshot', async () => {
await navigateToCasesApp(getPageObject, getService, owner);
await pageObjects.header.waitUntilLoadingHasFinished();
await svlCommonScreenshots.takeScreenshot('cases-home-page', screenshotDirectories);
});

it('case settings screenshot', async () => {
await navigateToCasesApp(getPageObject, getService, owner);
await testSubjects.click('configure-case-button');
await pageObjects.header.waitUntilLoadingHasFinished();
await svlCommonScreenshots.takeScreenshot('case-settings', screenshotDirectories);
});

it('case detail screenshot', async () => {
await pageObjects.common.navigateToUrlWithBrowserHistory(
'securitySolution',
`/cases/${caseIdSuspiciousEmail}`,
undefined
);
await pageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.existOrFail('case-view-title');
const collapseNav = await testSubjects.find('euiCollapsibleNavButton');
await collapseNav.click();
await svlCommonScreenshots.takeScreenshot('cases-ui-open', screenshotDirectories, 1400, 1024);
const filesTab = await testSubjects.find('case-view-tab-title-files');
await filesTab.click();
await cases.casesFilesTable.addFile(require.resolve('./testfile.png'));
await testSubjects.getVisibleText('cases-files-name-link');
await svlCommonScreenshots.takeScreenshot('cases-files', screenshotDirectories, 1400, 1024);
});
});
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 { FtrProviderContext } from '../../../../ftr_provider_context';

export default function ({ getService, loadTestFile }: FtrProviderContext) {
const browser = getService('browser');
const ml = getService('ml');

describe('response ops docs', function () {
this.tags(['responseOps']);

before(async () => {
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.testResources.disableKibanaAnnouncements();
await browser.setWindowSize(1920, 1080);
});

after(async () => {
await ml.testResources.resetKibanaTimeZone();
await ml.testResources.resetKibanaAnnouncements();
});

loadTestFile(require.resolve('./cases'));
});
}

0 comments on commit 928e4f0

Please sign in to comment.