From 093914aed8fbbb3f5ae616be208ff971c24a763b Mon Sep 17 00:00:00 2001
From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Date: Tue, 8 Oct 2024 05:34:20 +1100
Subject: [PATCH] [8.x] [Cloud Security] Adding unprivileged state to benchmark
page (#195172) (#195298)
# Backport
This will backport the following commits from `main` to `8.x`:
- [[Cloud Security] Adding unprivileged state to benchmark page
(#195172)](https://github.com/elastic/kibana/pull/195172)
### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)
Co-authored-by: Jordan <51442161+JordanSh@users.noreply.github.com>
---
.../pages/benchmarks/benchmarks.test.tsx | 22 +++++++++++++++++++
.../public/pages/benchmarks/benchmarks.tsx | 13 +++++++----
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.test.tsx b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.test.tsx
index e11095bb622f0..4e52484dffbea 100644
--- a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.test.tsx
+++ b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.test.tsx
@@ -18,6 +18,7 @@ import { useCspSetupStatusApi } from '@kbn/cloud-security-posture/src/hooks/use_
import { useCspIntegrationLink } from '../../common/navigation/use_csp_integration_link';
import { ERROR_STATE_TEST_SUBJECT } from './benchmarks_table';
import { useLicenseManagementLocatorApi } from '../../common/api/use_license_management_locator_api';
+import { NO_FINDINGS_STATUS_TEST_SUBJ } from '../../components/test_subjects';
jest.mock('./use_csp_benchmark_integrations');
jest.mock('@kbn/cloud-security-posture/src/hooks/use_csp_setup_status_api');
@@ -85,6 +86,27 @@ describe('', () => {
expect(screen.getByTestId(ERROR_STATE_TEST_SUBJECT)).toBeInTheDocument();
});
+ it('renders unprivileged state ', () => {
+ (useCspSetupStatusApi as jest.Mock).mockImplementation(() =>
+ createReactQueryResponse({
+ status: 'success',
+ data: {
+ cspm: { status: 'unprivileged' },
+ kspm: { status: 'unprivileged' },
+ },
+ })
+ );
+
+ renderBenchmarks(
+ createReactQueryResponse({
+ status: 'success',
+ data: { total: 1, items: [createCspBenchmarkIntegrationFixture()] },
+ })
+ );
+
+ expect(screen.getByTestId(NO_FINDINGS_STATUS_TEST_SUBJ.UNPRIVILEGED)).toBeInTheDocument();
+ });
+
it('renders the benchmarks table', () => {
renderBenchmarks(
createReactQueryResponse({
diff --git a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.tsx b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.tsx
index dd6b8ce45318b..e3e4efc0db371 100644
--- a/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.tsx
+++ b/x-pack/plugins/cloud_security_posture/public/pages/benchmarks/benchmarks.tsx
@@ -163,9 +163,14 @@ export const Benchmarks = () => {
const getSetupStatus = useCspSetupStatusApi({
refetchInterval: NO_FINDINGS_STATUS_REFRESH_INTERVAL_MS,
});
- const showConfigurationInstallPrompt =
- getSetupStatus.data?.kspm?.status === 'not-installed' &&
- getSetupStatus.data?.cspm?.status === 'not-installed';
+
+ const kspmStatus = getSetupStatus.data?.kspm?.status;
+ const cspmStatus = getSetupStatus.data?.cspm?.status;
+
+ const showNoFindingsStates =
+ (kspmStatus === 'not-installed' && cspmStatus === 'not-installed') ||
+ cspmStatus === 'unprivileged' ||
+ kspmStatus === 'unprivileged';
return (
@@ -182,7 +187,7 @@ export const Benchmarks = () => {
bottomBorder
/>
- {showConfigurationInstallPrompt ? (
+ {showNoFindingsStates ? (
) : (
<>