Skip to content

Commit

Permalink
[Cloud Security] 3P Misconfiguration page empty state (#193051)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSh authored Sep 25, 2024
1 parent faeca17 commit 0212c69
Show file tree
Hide file tree
Showing 14 changed files with 6,257 additions and 136 deletions.
5,822 changes: 5,822 additions & 0 deletions x-pack/plugins/cloud_security_posture/public/assets/illustrations/clouds.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 { pagePathGetters } from '@kbn/fleet-plugin/public';
import { useKibana } from '../hooks/use_kibana';

export const useAdd3PIntegrationRoute = (pkgkey: string) => {
const { http } = useKibana().services;

const path = pagePathGetters
.add_integration_to_policy({
pkgkey,
})
.join('');

return http.basePath.prepend(path);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
CLOUD_SECURITY_POSTURE_BASE_PATH,
} from '@kbn/cloud-security-posture-common';
import { NAV_ITEMS_NAMES } from '@kbn/cloud-security-posture/constants/navigation';
import { CNVM_POLICY_TEMPLATE } from '../../../common/constants';
import type { CspBenchmarksPage, CspPage, CspPageNavigationItem } from './types';

const CSPM_DASHBOARD_TAB_NAME = 'Cloud';
Expand Down Expand Up @@ -71,4 +72,7 @@ export const cspIntegrationDocsNavigation = {
gcpGetStartedPath: `https://www.elastic.co/guide/en/security/current/cspm-get-started-gcp.html`,
azureGetStartedPath: `https://www.elastic.co/guide/en/security/current/cspm-get-started-azure.html`,
},
cnvm: {
overviewPath: `${ELASTIC_BASE_SHORT_URL}/${CNVM_POLICY_TEMPLATE}`,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,37 @@ import { renderWrapper } from '../../test/mock_server/mock_server_test_provider'
import { NoFindingsStates } from './no_findings_states';
import * as statusHandlers from '../../../server/routes/status/status.handlers.mock';
import * as benchmarksHandlers from '../../../server/routes/benchmarks/benchmarks.handlers.mock';
import { PACKAGE_NOT_INSTALLED_TEST_SUBJECT } from '../cloud_posture_page';
import { MemoryRouter, Route } from '@kbn/shared-ux-router';
import { THIRD_PARTY_INTEGRATIONS_NO_MISCONFIGURATIONS_FINDINGS_PROMPT } from '../test_subjects';

const server = setupMockServer();

const renderNoFindingsStates = (postureType: 'cspm' | 'kspm' = 'cspm') => {
return renderWrapper(<NoFindingsStates postureType={postureType} />);
const renderNoFindingsStates = (postureType: 'cspm' | 'kspm' = 'cspm', route = '/') => {
return renderWrapper(
<MemoryRouter initialEntries={[route]}>
<Route>
<NoFindingsStates postureType={postureType} />
</Route>
</MemoryRouter>
);
};

describe('NoFindingsStates', () => {
startMockServer(server);

it('shows integrations installation prompt with installation links when integration is not-installed', async () => {
server.use(statusHandlers.notInstalledHandler);
renderNoFindingsStates();
renderNoFindingsStates('cspm', '/app/security/cloud_security_posture/findings/configurations');
expect(screen.getByText(/loading/i)).toBeInTheDocument();

await waitFor(() => {
expect(screen.getByTestId(PACKAGE_NOT_INSTALLED_TEST_SUBJECT)).toBeInTheDocument();
});

await waitFor(() => {
expect(
screen.getByText(/detect security misconfigurations in your cloud infrastructure!/i)
screen.getByTestId(THIRD_PARTY_INTEGRATIONS_NO_MISCONFIGURATIONS_FINDINGS_PROMPT)
).toBeInTheDocument();
});

Expand All @@ -46,7 +59,33 @@ describe('NoFindingsStates', () => {
'/app/fleet/integrations/cloud_security_posture-1.9.0/add-integration/kspm'
);
});

await waitFor(() => {
expect(screen.getByRole('link', { name: /add wiz integration/i })).toHaveAttribute(
'href',
'/app/fleet/integrations/wiz/add-integration'
);
});
});

it('does not show 3P prompt on not supported pages', async () => {
// 3P support is currently determined by the page URL. in this test case we do not provide the required URL
server.use(statusHandlers.notInstalledHandler);
renderNoFindingsStates();

expect(screen.getByText(/loading/i)).toBeInTheDocument();

await waitFor(() => {
expect(screen.getByTestId(PACKAGE_NOT_INSTALLED_TEST_SUBJECT)).toBeInTheDocument();
});

await waitFor(() => {
expect(
screen.queryByTestId(THIRD_PARTY_INTEGRATIONS_NO_MISCONFIGURATIONS_FINDINGS_PROMPT)
).not.toBeInTheDocument();
});
});

it('shows install agent prompt with install agent link when status is not-deployed', async () => {
server.use(statusHandlers.notDeployedHandler);
server.use(benchmarksHandlers.cspmInstalledHandler);
Expand All @@ -64,6 +103,7 @@ describe('NoFindingsStates', () => {
);
});
});

it('shows install agent prompt with install agent link when status is not-deployed and postureType is KSPM', async () => {
server.use(statusHandlers.notDeployedHandler);
server.use(benchmarksHandlers.kspmInstalledHandler);
Expand All @@ -84,6 +124,7 @@ describe('NoFindingsStates', () => {
);
});
});

it('shows indexing message when status is indexing', async () => {
server.use(statusHandlers.indexingHandler);

Expand All @@ -100,6 +141,7 @@ describe('NoFindingsStates', () => {
)
).toBeInTheDocument();
});

it('shows timeout message when status is index-timeout', async () => {
server.use(statusHandlers.indexTimeoutHandler);

Expand All @@ -116,6 +158,7 @@ describe('NoFindingsStates', () => {
screen.getByText(/collecting findings is taking longer than expected/i)
).toBeInTheDocument();
});

it('shows unprivileged message when status is unprivileged', async () => {
server.use(statusHandlers.unprivilegedHandler);

Expand All @@ -137,6 +180,7 @@ describe('NoFindingsStates', () => {
).toBeInTheDocument();
});
});

it('renders empty container when the status does not match a no finding status', async () => {
server.use(statusHandlers.indexedHandler);

Expand Down
Loading

0 comments on commit 0212c69

Please sign in to comment.