From 928e4f0d3babf6bc9618a675d8af82727dce2742 Mon Sep 17 00:00:00 2001 From: Lisa Cawley Date: Wed, 10 Jan 2024 10:40:27 -0800 Subject: [PATCH] [Cases] Automate serverless security screenshots (#174556) --- .buildkite/ftr_configs.yml | 1 + .../security/config.screenshots.ts | 18 ++++ .../security/screenshot_creation/index.ts | 14 +++ .../response_ops_docs/cases/index.ts | 20 ++++ .../response_ops_docs/cases/list_view.ts | 96 +++++++++++++++++++ .../response_ops_docs/cases/testfile.png | 0 .../response_ops_docs/index.ts | 30 ++++++ 7 files changed, 179 insertions(+) create mode 100644 x-pack/test_serverless/functional/test_suites/security/config.screenshots.ts create mode 100644 x-pack/test_serverless/functional/test_suites/security/screenshot_creation/index.ts create mode 100644 x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/index.ts create mode 100644 x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/list_view.ts create mode 100644 x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/testfile.png create mode 100644 x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/index.ts diff --git a/.buildkite/ftr_configs.yml b/.buildkite/ftr_configs.yml index 17a357c71640b..cc574b7a74c85 100644 --- a/.buildkite/ftr_configs.yml +++ b/.buildkite/ftr_configs.yml @@ -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 diff --git a/x-pack/test_serverless/functional/test_suites/security/config.screenshots.ts b/x-pack/test_serverless/functional/test_suites/security/config.screenshots.ts new file mode 100644 index 0000000000000..92a46e01b0e4f --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/config.screenshots.ts @@ -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'], +}); diff --git a/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/index.ts b/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/index.ts new file mode 100644 index 0000000000000..ca0d8ab0c191d --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/index.ts @@ -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')); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/index.ts b/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/index.ts new file mode 100644 index 0000000000000..c2a17b8e8e82d --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/index.ts @@ -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')); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/list_view.ts b/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/list_view.ts new file mode 100644 index 0000000000000..7103bae64f984 --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/list_view.ts @@ -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); + }); + }); +} diff --git a/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/testfile.png b/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/cases/testfile.png new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/index.ts b/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/index.ts new file mode 100644 index 0000000000000..6e11aad1dab1c --- /dev/null +++ b/x-pack/test_serverless/functional/test_suites/security/screenshot_creation/response_ops_docs/index.ts @@ -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')); + }); +}