-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cloud Posture] Dashboard initial FTR (#155163)
- Loading branch information
Showing
12 changed files
with
224 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
x-pack/test/cloud_security_posture_functional/page_objects/csp_dashboard_page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* 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'; | ||
|
||
// Defined in CSP plugin | ||
const LATEST_FINDINGS_INDEX = 'logs-cloud_security_posture.findings_latest-default'; | ||
|
||
export function CspDashboardPageProvider({ getService, getPageObjects }: FtrProviderContext) { | ||
const testSubjects = getService('testSubjects'); | ||
const PageObjects = getPageObjects(['common']); | ||
const retry = getService('retry'); | ||
const es = getService('es'); | ||
const supertest = getService('supertest'); | ||
const log = getService('log'); | ||
|
||
/** | ||
* required before indexing findings | ||
*/ | ||
const waitForPluginInitialized = (): Promise<void> => | ||
retry.try(async () => { | ||
log.debug('Check CSP plugin is initialized'); | ||
const response = await supertest | ||
.get('/internal/cloud_security_posture/status?check=init') | ||
.expect(200); | ||
expect(response.body).to.eql({ isPluginInitialized: true }); | ||
log.debug('CSP plugin is initialized'); | ||
}); | ||
|
||
const index = { | ||
remove: () => es.indices.delete({ index: LATEST_FINDINGS_INDEX, ignore_unavailable: true }), | ||
add: async <T>(findingsMock: T[]) => { | ||
await Promise.all( | ||
findingsMock.map((finding) => | ||
es.index({ | ||
index: LATEST_FINDINGS_INDEX, | ||
body: finding, | ||
}) | ||
) | ||
); | ||
}, | ||
}; | ||
|
||
const dashboard = { | ||
getDashboardPageHeader: () => testSubjects.find('cloud-posture-dashboard-page-header'), | ||
|
||
getDashboardTabs: async () => { | ||
const dashboardPageHeader = await dashboard.getDashboardPageHeader(); | ||
return await dashboardPageHeader.findByClassName('euiTabs'); | ||
}, | ||
|
||
getCloudTab: async () => { | ||
const tabs = await dashboard.getDashboardTabs(); | ||
return await tabs.findByXpath(`//span[text()="Cloud"]`); | ||
}, | ||
|
||
getKubernetesTab: async () => { | ||
const tabs = await dashboard.getDashboardTabs(); | ||
return await tabs.findByXpath(`//span[text()="Kubernetes"]`); | ||
}, | ||
|
||
clickTab: async (tab: 'Cloud' | 'Kubernetes') => { | ||
if (tab === 'Cloud') { | ||
const cloudTab = await dashboard.getCloudTab(); | ||
await cloudTab.click(); | ||
} | ||
if (tab === 'Kubernetes') { | ||
const k8sTab = await dashboard.getKubernetesTab(); | ||
await k8sTab.click(); | ||
} | ||
}, | ||
|
||
getIntegrationDashboardContainer: () => testSubjects.find('dashboard-container'), | ||
|
||
// Cloud Dashboard | ||
|
||
getCloudDashboard: async () => { | ||
await dashboard.clickTab('Cloud'); | ||
return await testSubjects.find('cloud-dashboard-container'); | ||
}, | ||
|
||
getCloudSummarySection: async () => { | ||
await dashboard.getCloudDashboard(); | ||
return await testSubjects.find('dashboard-summary-section'); | ||
}, | ||
|
||
getCloudComplianceScore: async () => { | ||
await dashboard.getCloudSummarySection(); | ||
return await testSubjects.find('dashboard-summary-section-compliance-score'); | ||
}, | ||
|
||
// Kubernetes Dashboard | ||
|
||
getKubernetesDashboard: async () => { | ||
await dashboard.clickTab('Kubernetes'); | ||
return await testSubjects.find('kubernetes-dashboard-container'); | ||
}, | ||
|
||
getKubernetesSummarySection: async () => { | ||
await dashboard.getKubernetesDashboard(); | ||
return await testSubjects.find('dashboard-summary-section'); | ||
}, | ||
|
||
getKubernetesComplianceScore: async () => { | ||
await dashboard.getKubernetesSummarySection(); | ||
return await testSubjects.find('dashboard-summary-section-compliance-score'); | ||
}, | ||
|
||
getKubernetesComplianceScore2: async () => { | ||
// await dashboard.getKubernetesSummarySection(); | ||
return await testSubjects.find('dashboard-summary-section-compliance-score'); | ||
}, | ||
}; | ||
|
||
const navigateToComplianceDashboardPage = async () => { | ||
await PageObjects.common.navigateToUrl( | ||
'securitySolution', // Defined in Security Solution plugin | ||
'cloud_security_posture/dashboard', | ||
{ shouldUseHashForSubUrl: false } | ||
); | ||
}; | ||
|
||
return { | ||
waitForPluginInitialized, | ||
navigateToComplianceDashboardPage, | ||
dashboard, | ||
index, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
x-pack/test/cloud_security_posture_functional/pages/compliance_dashboard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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 Chance from 'chance'; | ||
import type { FtrProviderContext } from '../ftr_provider_context'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function ({ getPageObjects, getService }: FtrProviderContext) { | ||
const retry = getService('retry'); | ||
const pageObjects = getPageObjects(['common', 'cloudPostureDashboard']); | ||
const chance = new Chance(); | ||
|
||
const data = [ | ||
{ | ||
'@timestamp': new Date().toISOString(), | ||
resource: { id: chance.guid(), name: `kubelet`, sub_type: 'lower case sub type' }, | ||
result: { evaluation: 'failed' }, | ||
rule: { | ||
name: 'Upper case rule name', | ||
section: 'Upper case section', | ||
benchmark: { | ||
id: 'cis_k8s', | ||
posture_type: 'kspm', | ||
}, | ||
}, | ||
cluster_id: 'Upper case cluster id', | ||
}, | ||
]; | ||
|
||
describe('Cloud Posture Dashboard Page', () => { | ||
let cspDashboard: typeof pageObjects.cloudPostureDashboard; | ||
let dashboard: typeof pageObjects.cloudPostureDashboard.dashboard; | ||
|
||
before(async () => { | ||
cspDashboard = pageObjects.cloudPostureDashboard; | ||
dashboard = pageObjects.cloudPostureDashboard.dashboard; | ||
await cspDashboard.waitForPluginInitialized(); | ||
|
||
await cspDashboard.index.add(data); | ||
await cspDashboard.navigateToComplianceDashboardPage(); | ||
await retry.waitFor( | ||
'Cloud posture integration dashboard to be displayed', | ||
async () => !!dashboard.getIntegrationDashboardContainer() | ||
); | ||
}); | ||
|
||
after(async () => { | ||
await cspDashboard.index.remove(); | ||
}); | ||
|
||
describe('Kubernetes Dashboard', () => { | ||
it('displays accurate summary compliance score', async () => { | ||
const scoreElement = await dashboard.getKubernetesComplianceScore(); | ||
|
||
expect((await scoreElement.getVisibleText()) === '0%').to.be(true); | ||
}); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.