Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cloud Security] Add sanity UI tests for ESS deployments #187328

Merged
merged 20 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c7aa20c
add benchmark tests
gurevichdmitry Jul 2, 2024
77512ce
Merge branch 'main' into dg-sanity-ui-tests
gurevichdmitry Jul 2, 2024
16707bc
add findings tests
gurevichdmitry Jul 2, 2024
1427e01
Merge branch 'dg-sanity-ui-tests' of github.com:gurevichdmitry/kibana…
gurevichdmitry Jul 2, 2024
bd84919
Merge branch 'main' into dg-sanity-ui-tests
gurevichdmitry Jul 2, 2024
993692a
add findings paging and sorting tests
gurevichdmitry Jul 3, 2024
beca53f
Merge branch 'dg-sanity-ui-tests' of github.com:gurevichdmitry/kibana…
gurevichdmitry Jul 3, 2024
d0a4c77
Merge branch 'main' into dg-sanity-ui-tests
gurevichdmitry Jul 3, 2024
010e466
add csp dashboard page tests
gurevichdmitry Jul 4, 2024
1efe00b
Merge branch 'main' into dg-sanity-ui-tests
gurevichdmitry Jul 4, 2024
baf01ad
Merge branch 'dg-sanity-ui-tests' of github.com:gurevichdmitry/kibana…
gurevichdmitry Jul 4, 2024
9376e6f
Merge branch 'main' into dg-sanity-ui-tests
gurevichdmitry Jul 4, 2024
5cba2f6
add csp dashboard page link navigation tests
gurevichdmitry Jul 8, 2024
2da4d2c
Merge branch 'dg-sanity-ui-tests' of github.com:gurevichdmitry/kibana…
gurevichdmitry Jul 8, 2024
7c3e4eb
Merge branch 'main' into dg-sanity-ui-tests
gurevichdmitry Jul 8, 2024
2b67ba0
remove comments
gurevichdmitry Jul 8, 2024
d49e666
fix review comments
gurevichdmitry Jul 8, 2024
dc44e4e
Merge branch 'main' into dg-sanity-ui-tests
gurevichdmitry Jul 8, 2024
deb8026
Merge branch 'main' into dg-sanity-ui-tests
gurevichdmitry Jul 9, 2024
fe9d162
Merge branch 'main' into dg-sanity-ui-tests
gurevichdmitry Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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 expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['common', 'benchmark']);

describe('Benchmark Page - Sanity Tests', function () {
this.tags(['cloud_security_posture_ui_sanity']);
let benchmark: typeof pageObjects.benchmark;

before(async () => {
benchmark = pageObjects.benchmark;
await benchmark.navigateToBenchnmarkPage();
await benchmark.waitForPluginInitialized();
});

it('Benchmark table exists', async () => {
expect(await benchmark.benchmarkPage.doesBenchmarkTableExists());
});

it('Benchmarks count is more than 0', async () => {
const benchmarksRows = await benchmark.benchmarkPage.getBenchmarkTableRows();
expect(benchmarksRows.length).to.be.greaterThan(0);
});

it('For each benchmark, evaluation and complience are not empty', async () => {
const benchmarksRows = await benchmark.benchmarkPage.getBenchmarkTableRows();
for (const row of benchmarksRows) {
const benchmarkName = await benchmark.benchmarkPage.getCisNameCellData(row);
const evaluated = await benchmark.benchmarkPage.getEvaluatedCellData(row);
const compliance = await benchmark.benchmarkPage.getComplianceCellData(row);
expect(await evaluated).to.not.contain(
'Add',
gurevichdmitry marked this conversation as resolved.
Show resolved Hide resolved
`The ${benchmarkName} does not have evaluated data`
);
expect(await compliance).to.not.contain(
'No',
`The ${benchmarkName} does not have compliance data`
);
}
});
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*
* 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 expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default ({ getPageObjects, getService }: FtrProviderContext) => {
const retry = getService('retry');
const pageObjects = getPageObjects(['common', 'cloudPostureDashboard', 'header', 'findings']);

describe('Cloud Posture Dashboard Page - Sanity Tests', function () {
this.tags(['cloud_security_posture_ui_sanity']);
let cspDashboard: typeof pageObjects.cloudPostureDashboard;
let dashboard: typeof pageObjects.cloudPostureDashboard.dashboard;
let findings: typeof pageObjects.findings;
let TAB_TYPES: typeof pageObjects.cloudPostureDashboard.TAB_TYPES;

before(async () => {
cspDashboard = pageObjects.cloudPostureDashboard;
dashboard = pageObjects.cloudPostureDashboard.dashboard;
findings = pageObjects.findings;
TAB_TYPES = pageObjects.cloudPostureDashboard.TAB_TYPES;
await cspDashboard.waitForPluginInitialized();
await cspDashboard.navigateToComplianceDashboardPage();
await retry.waitFor(
'Cloud posture integration dashboard to be displayed',
async () => !!dashboard.getIntegrationDashboardContainer()
);
});

describe('Cloud Dashboard', () => {
it('displays compliance score greater than 40', async () => {
await pageObjects.header.waitUntilLoadingHasFinished();
const scoreElement = await dashboard.getCloudComplianceScore();
const score = parseInt((await scoreElement.getVisibleText()).replace('%', ''), 10);
expect(score).to.be.greaterThan(40);
});

it('displays all compliance scores', async () => {
const scoresElements = await dashboard.getAllCloudComplianceScores();
const scores: string[] = [];
for (const scoreElement of scoresElements) {
scores.push(await scoreElement.getVisibleText());
}
// 3 scores for each cloud provider + 1 summary score
expect(scores.length).to.be(4);
});

it('displays a number of resources evaluated greater than 1500', async () => {
const resourcesEvaluated = await dashboard.getCloudResourcesEvaluated();
const visibleText = await resourcesEvaluated.getVisibleText();
const resourcesEvaluatedCount = parseInt(visibleText.replace(/,/g, ''), 10);
expect(resourcesEvaluatedCount).greaterThan(1500);
});

it('Compliance By CIS sections have non empty values', async () => {
const complianceScoresChartPanel = await dashboard.getAllComplianceScoresByCisSection(
TAB_TYPES.CLOUD
);
expect(complianceScoresChartPanel.length).to.be.greaterThan(0);
for (const score of complianceScoresChartPanel) {
const scoreValue = await score.getVisibleText();
// Check if the score is a percentage
expect(scoreValue).to.match(/^\d+%$/);
}
});

it('Navigation to Findings page', async () => {
const findingsLinkCount = await dashboard.getFindingsLinksCount(TAB_TYPES.CLOUD);
for (let i = 0; i < findingsLinkCount; i++) {
const link = await dashboard.getFindingsLinkAtIndex(TAB_TYPES.CLOUD, i);
// for (const link of findingsLink) {
await link.click();
await pageObjects.header.waitUntilLoadingHasFinished();
const groupSelector = await findings.groupSelector();
await groupSelector.openDropDown();
await groupSelector.setValue('None');
expect(
await findings.createDataTableObject('latest_findings_table').getRowsCount()
).to.be.greaterThan(0);
await cspDashboard.navigateToComplianceDashboardPage();
await pageObjects.header.waitUntilLoadingHasFinished();
}
});
});

describe('Kubernetes Dashboard', () => {
it('displays compliance score greater than 80', async () => {
await pageObjects.header.waitUntilLoadingHasFinished();
const scoreElement = await dashboard.getKubernetesComplianceScore();
const score = parseInt((await scoreElement.getVisibleText()).replace('%', ''), 10);
expect(score).to.be.greaterThan(80);
});

it('displays a number of resources evaluated greater than 150', async () => {
const resourcesEvaluated = await dashboard.getKubernetesResourcesEvaluated();
const resourcesEvaluatedCount = parseInt(
(await resourcesEvaluated.getVisibleText()).replace(/,/g, ''),
10
);
expect(resourcesEvaluatedCount).greaterThan(150);
});

it('Compliance By CIS sections have non empty values', async () => {
const complianceScoresChartPanel = await dashboard.getAllComplianceScoresByCisSection(
'Kubernetes'
);
expect(complianceScoresChartPanel.length).to.be.greaterThan(0);
for (const score of complianceScoresChartPanel) {
const scoreValue = await score.getVisibleText();
// Check if the score is a percentage
expect(scoreValue).to.match(/^\d+%$/);
}
});

it('Navigation to Findings page', async () => {
const findingsLinkCount = await dashboard.getFindingsLinksCount(TAB_TYPES.KUBERNETES);
for (let i = 0; i < findingsLinkCount; i++) {
const link = await dashboard.getFindingsLinkAtIndex(TAB_TYPES.KUBERNETES, i);
await link.click();
await pageObjects.header.waitUntilLoadingHasFinished();
const groupSelector = await findings.groupSelector();
await groupSelector.openDropDown();
await groupSelector.setValue('None');
expect(
await findings.createDataTableObject('latest_findings_table').getRowsCount()
).to.be.greaterThan(0);
await cspDashboard.navigateToComplianceDashboardPage();
await pageObjects.header.waitUntilLoadingHasFinished();
await dashboard.getKubernetesDashboard();
}
});
});
});
};
Loading