Skip to content
3 changes: 3 additions & 0 deletions .buildkite/ftr_security_serverless_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ disabled:
# Playwright
- x-pack/solutions/security/test/security_solution_playwright/serverless_config.ts

# QA suites that are run out-of-band
- x-pack/solutions/security/test/serverless/functional/configs/config.cloud_security_posture.cloud.ts

# MKI only configs files
- x-pack/solutions/security/test/serverless/functional/configs/config.mki_only.ts

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 '@kbn/test-suites-xpack-platform/serverless/functional/config.base';
import { services } from '../services';
import { pageObjects } from '../page_objects';

export default createTestConfig({
serverlessProject: 'security',
pageObjects,
services,
junit: {
reportName: 'Serverless Security Cloud Security Functional Tests',
},

// load tests in the index file
testFiles: [require.resolve('../test_suites/ftr/cloud_security_posture/cloud_tests')],
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { SvlSecLandingPageProvider } from './svl_sec_landing_page';
import { CspSecurityCommonProvider } from './security_common';
import { CspDashboardPageProvider } from '../../../cloud_security_posture_functional/page_objects/csp_dashboard_page';
import { AddCisIntegrationFormPageProvider } from '../../../cloud_security_posture_functional/page_objects/add_cis_integration_form_page';
import { BenchmarkPagePageProvider } from '../../../cloud_security_posture_functional/page_objects/benchmark_page';
import { FindingsPageProvider } from '../../../cloud_security_posture_functional/page_objects/findings_page';

export const pageObjects = {
...svlPlatformPageObjects,
Expand All @@ -18,4 +20,6 @@ export const pageObjects = {
cloudPostureDashboard: CspDashboardPageProvider,
cisAddIntegration: AddCisIntegrationFormPageProvider,
cspSecurity: CspSecurityCommonProvider,
cspBenchmarkPage: BenchmarkPagePageProvider,
cspFindingsPage: FindingsPageProvider,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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 type { FtrProviderContext } from '../../../../ftr_provider_context';
export default function ({ getPageObjects }: FtrProviderContext) {
const pageObjects = getPageObjects([
'settings',
'common',
'svlCommonPage',
'header',
'cspBenchmarkPage',
]);

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

before(async () => {
benchmark = pageObjects.cspBenchmarkPage;
await pageObjects.svlCommonPage.loginWithRole('admin');
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 isEvaluationEmpty = await benchmark.benchmarkPage.isEvaluationEmpty(row);
const isComplianceEmpty = await benchmark.benchmarkPage.isComplianceEmpty(row);

expect(isEvaluationEmpty).to.eql(
false,
`The ${benchmarkName} does not have evaluated data`
);

expect(isComplianceEmpty).to.eql(
false,
`The ${benchmarkName} does not have compliance data`
);
}
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*
* 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 type { FtrProviderContext } from '../../../../ftr_provider_context';

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const retry = getService('retry');
const pageObjects = getPageObjects([
'common',
'cloudPostureDashboard',
'header',
'svlCommonPage',
'cspFindingsPage',
]);

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.cspFindingsPage;
let TAB_TYPES: typeof pageObjects.cloudPostureDashboard.TAB_TYPES;

before(async () => {
cspDashboard = pageObjects.cloudPostureDashboard;
dashboard = pageObjects.cloudPostureDashboard.dashboard;
findings = pageObjects.cspFindingsPage;
TAB_TYPES = pageObjects.cloudPostureDashboard.TAB_TYPES;
await pageObjects.svlCommonPage.loginWithRole('admin');
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);
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