From 92831591184f176fcb39d824f3d3c1f3a81402e0 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 5 Apr 2022 13:32:34 -0400 Subject: [PATCH] [Security Solution][Admin][Policy] Clean up Policy list (#129139) (#129492) (cherry picked from commit a9e6f0aed0c03d55839dda611bdd75b133f24435) Co-authored-by: Candace Park <56409205+parkiino@users.noreply.github.com> --- .../components/management_empty_state.tsx | 9 ++--- .../use_bulk_delete_artifact.test.tsx | 2 +- .../use_bulk_update_artifact.test.tsx | 2 +- .../artifacts/use_create_artifact.test.tsx | 2 +- .../artifacts/use_delete_artifact.test.tsx | 2 +- .../hooks/artifacts/use_get_artifact.test.tsx | 2 +- .../artifacts/use_list_artifact.test.tsx | 2 +- .../artifacts/use_summary_artifact.test.tsx | 2 +- .../artifacts/use_update_artifact.test.tsx | 2 +- .../hooks/{artifacts => }/test_utils.tsx | 4 +-- .../store/endpoint_pagination.test.ts | 2 +- .../endpoint_hosts/store/middleware.test.ts | 2 +- .../pages/endpoint_hosts/store/middleware.ts | 2 +- .../store/mock_endpoint_result_list.ts | 2 +- .../pages/endpoint_hosts/view/index.test.tsx | 4 +-- .../pages/endpoint_hosts/view/index.tsx | 5 ++- .../view/components/flyout/index.test.tsx | 2 +- .../view/components/form/index.test.tsx | 2 +- .../view/event_filters_list_page.test.tsx | 2 +- .../view/components/form.test.tsx | 2 +- .../view/components/form_flyout.test.tsx | 2 +- .../host_isolation_exceptions_list.test.tsx | 2 +- .../middleware/policy_settings_middleware.ts | 2 +- .../pages/policy/store/test_mock_utils.ts | 5 ++- .../pages/policy/view/policy_list.test.tsx | 36 +++++++++++++++++-- .../pages/policy/view/policy_list.tsx | 21 ++++++----- .../validate_trusted_app_http_request_body.ts | 2 +- .../services/policies/hooks.test.ts | 2 +- .../management/services/policies/hooks.ts | 5 +-- .../policies}/ingest.test.ts | 6 ++-- .../services => services/policies}/ingest.ts | 6 ++-- .../management/services/policies/policies.ts | 2 +- ...test_mock_utilts.ts => test_mock_utils.ts} | 0 33 files changed, 88 insertions(+), 57 deletions(-) rename x-pack/plugins/security_solution/public/management/hooks/{artifacts => }/test_utils.tsx (92%) rename x-pack/plugins/security_solution/public/management/{pages/policy/store/services => services/policies}/ingest.test.ts (90%) rename x-pack/plugins/security_solution/public/management/{pages/policy/store/services => services/policies}/ingest.ts (95%) rename x-pack/plugins/security_solution/public/management/services/policies/{test_mock_utilts.ts => test_mock_utils.ts} (100%) diff --git a/x-pack/plugins/security_solution/public/management/components/management_empty_state.tsx b/x-pack/plugins/security_solution/public/management/components/management_empty_state.tsx index b659cdd118837..80dd9e9563bb5 100644 --- a/x-pack/plugins/security_solution/public/management/components/management_empty_state.tsx +++ b/x-pack/plugins/security_solution/public/management/components/management_empty_state.tsx @@ -23,7 +23,6 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; -import styled from 'styled-components'; import onboardingLogo from '../images/security_administration_onboarding.svg'; import { useKibana } from '../../common/lib/kibana'; @@ -41,10 +40,6 @@ interface ManagementStep { children: JSX.Element; } -const StyledDiv = styled.div` - padding-left: 20%; -`; - const PolicyEmptyState = React.memo<{ loading: boolean; onActionClick: (event: MouseEvent) => void; @@ -53,7 +48,7 @@ const PolicyEmptyState = React.memo<{ }>(({ loading, onActionClick, actionDisabled, policyEntryPoint = false }) => { const docLinks = useKibana().services.docLinks; return ( - +
{loading ? ( @@ -128,7 +123,7 @@ const PolicyEmptyState = React.memo<{ )} - +
); }); diff --git a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_bulk_delete_artifact.test.tsx b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_bulk_delete_artifact.test.tsx index 152b2c3f0d690..a27a0e949835a 100644 --- a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_bulk_delete_artifact.test.tsx +++ b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_bulk_delete_artifact.test.tsx @@ -13,7 +13,7 @@ import { getFakeListDefinition, getFakeHttpService, renderMutation, -} from './test_utils'; +} from '../test_utils'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; import { act } from '@testing-library/react-hooks'; diff --git a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_bulk_update_artifact.test.tsx b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_bulk_update_artifact.test.tsx index a622eedb99f1e..7309979266e2c 100644 --- a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_bulk_update_artifact.test.tsx +++ b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_bulk_update_artifact.test.tsx @@ -13,7 +13,7 @@ import { getFakeListDefinition, getFakeHttpService, renderMutation, -} from './test_utils'; +} from '../test_utils'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; import { act } from '@testing-library/react-hooks'; diff --git a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_create_artifact.test.tsx b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_create_artifact.test.tsx index 89ce9ece8fa13..6bc703939bdf7 100644 --- a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_create_artifact.test.tsx +++ b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_create_artifact.test.tsx @@ -13,7 +13,7 @@ import { getFakeListDefinition, getFakeHttpService, renderMutation, -} from './test_utils'; +} from '../test_utils'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; import { act } from '@testing-library/react-hooks'; diff --git a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_delete_artifact.test.tsx b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_delete_artifact.test.tsx index bed3faf237b9f..c4195c3a63886 100644 --- a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_delete_artifact.test.tsx +++ b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_delete_artifact.test.tsx @@ -13,7 +13,7 @@ import { getFakeListDefinition, getFakeHttpService, renderMutation, -} from './test_utils'; +} from '../test_utils'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; import { act } from '@testing-library/react-hooks'; diff --git a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_get_artifact.test.tsx b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_get_artifact.test.tsx index 470f29b563f67..ad66381c8185a 100644 --- a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_get_artifact.test.tsx +++ b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_get_artifact.test.tsx @@ -13,7 +13,7 @@ import { getFakeListDefinition, getFakeHttpService, renderQuery, -} from './test_utils'; +} from '../test_utils'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; describe('Get artifact hook', () => { diff --git a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_list_artifact.test.tsx b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_list_artifact.test.tsx index 9ba0760961d7f..75387e3d01b1b 100644 --- a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_list_artifact.test.tsx +++ b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_list_artifact.test.tsx @@ -14,7 +14,7 @@ import { getFakeListDefinition, getFakeHttpService, renderQuery, -} from './test_utils'; +} from '../test_utils'; describe('List artifact hook', () => { let result: ReturnType; diff --git a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_summary_artifact.test.tsx b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_summary_artifact.test.tsx index 18c8f928660d9..32c14ece79a78 100644 --- a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_summary_artifact.test.tsx +++ b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_summary_artifact.test.tsx @@ -14,7 +14,7 @@ import { getFakeListDefinition, getFakeHttpService, renderQuery, -} from './test_utils'; +} from '../test_utils'; describe('Summary artifact hook', () => { let result: ReturnType; diff --git a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_update_artifact.test.tsx b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_update_artifact.test.tsx index c850648e3160a..3673114041552 100644 --- a/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_update_artifact.test.tsx +++ b/x-pack/plugins/security_solution/public/management/hooks/artifacts/use_update_artifact.test.tsx @@ -13,7 +13,7 @@ import { getFakeListDefinition, getFakeHttpService, renderMutation, -} from './test_utils'; +} from '../test_utils'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; import { act } from '@testing-library/react-hooks'; diff --git a/x-pack/plugins/security_solution/public/management/hooks/artifacts/test_utils.tsx b/x-pack/plugins/security_solution/public/management/hooks/test_utils.tsx similarity index 92% rename from x-pack/plugins/security_solution/public/management/hooks/artifacts/test_utils.tsx rename to x-pack/plugins/security_solution/public/management/hooks/test_utils.tsx index 2680d1a0ddd8e..7d7f999831363 100644 --- a/x-pack/plugins/security_solution/public/management/hooks/artifacts/test_utils.tsx +++ b/x-pack/plugins/security_solution/public/management/hooks/test_utils.tsx @@ -8,8 +8,8 @@ import React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { HttpSetup } from 'kibana/public'; import { CreateExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { coreMock } from '../../../../../../../src/core/public/mocks'; -import { ReactQueryClientProvider } from '../../../common/containers/query_client/query_client_provider'; +import { coreMock } from '../../../../../../src/core/public/mocks'; +import { ReactQueryClientProvider } from '../../common/containers/query_client/query_client_provider'; export const getFakeListId: () => string = () => 'FAKE_LIST_ID'; export const getFakeListDefinition: () => CreateExceptionListSchema = () => ({ diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/endpoint_pagination.test.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/endpoint_pagination.test.ts index 214fc220e04fb..969bac811e632 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/endpoint_pagination.test.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/endpoint_pagination.test.ts @@ -31,7 +31,7 @@ import { import { getEndpointListPath } from '../../../common/routing'; import { HOST_METADATA_LIST_ROUTE } from '../../../../../common/endpoint/constants'; -jest.mock('../../policy/store/services/ingest', () => ({ +jest.mock('../../../services/policies/ingest', () => ({ sendGetAgentPolicyList: () => Promise.resolve({ items: [] }), sendGetEndpointSecurityPackage: () => Promise.resolve({}), })); diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.test.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.test.ts index 7fc80bffd7c04..ab24e2a41a64e 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.test.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.test.ts @@ -49,7 +49,7 @@ import { HOST_METADATA_LIST_ROUTE, } from '../../../../../common/endpoint/constants'; -jest.mock('../../policy/store/services/ingest', () => ({ +jest.mock('../../../services/policies/ingest', () => ({ sendGetAgentConfigList: () => Promise.resolve({ items: [] }), sendGetAgentPolicyList: () => Promise.resolve({ items: [] }), sendGetEndpointSecurityPackage: () => Promise.resolve({ version: '1.1.1' }), diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts index 9d839be623920..2d433a4cdf8c5 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts @@ -46,7 +46,7 @@ import { sendGetAgentPolicyList, sendGetEndpointSecurityPackage, sendGetFleetAgentsWithEndpoint, -} from '../../policy/store/services/ingest'; +} from '../../../services/policies/ingest'; import { GetPolicyListResponse } from '../../policy/types'; import { AgentIdsPendingActions, diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/mock_endpoint_result_list.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/mock_endpoint_result_list.ts index 6a18bf5e16759..3c0d7163ef723 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/mock_endpoint_result_list.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/mock_endpoint_result_list.ts @@ -20,7 +20,7 @@ import { INGEST_API_EPM_PACKAGES, INGEST_API_PACKAGE_POLICIES, INGEST_API_FLEET_AGENTS, -} from '../../policy/store/services/ingest'; +} from '../../../services/policies/ingest'; import { GetAgentPoliciesResponse, GetAgentPoliciesResponseItem, diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx index 07a766f3fd768..9e86b0389c19d 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx @@ -69,8 +69,8 @@ jest.mock('@kbn/i18n-react', () => { }; }); jest.mock('../../../../common/components/link_to'); -jest.mock('../../policy/store/services/ingest', () => { - const originalModule = jest.requireActual('../../policy/store/services/ingest'); +jest.mock('../../../services/policies/ingest', () => { + const originalModule = jest.requireActual('../../../services/policies/ingest'); return { ...originalModule, sendGetEndpointSecurityPackage: () => Promise.resolve({}), diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx index c43c20a4bcae1..441f2502fa3f7 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx @@ -69,6 +69,7 @@ import { BackToExternalAppButtonProps, } from '../../../components/back_to_external_app_button/back_to_external_app_button'; import { DevConsole } from './dev_console'; +import { ManagementEmptyStateWrapper } from '../../../components/management_empty_state_wrapper'; const MAX_PAGINATED_ITEM = 9999; const TRANSFORM_URL = '/data/transform'; @@ -551,7 +552,9 @@ export const EndpointList = () => { ); } else { return ( - + + + ); } }, [ diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx index 5145e78bbd397..8ff68d266031a 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx @@ -14,7 +14,7 @@ import { } from '../../../../../../common/mock/endpoint'; import { MiddlewareActionSpyHelper } from '../../../../../../common/store/test_utils'; import { sendGetEndpointSpecificPackagePolicies } from '../../../../../services/policies/policies'; -import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../../../services/policies/test_mock_utilts'; +import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../../../services/policies/test_mock_utils'; import type { CreateExceptionListItemSchema, ExceptionListItemSchema, diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.test.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.test.tsx index 96cdef21244d0..dc1721d2580e8 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.test.tsx @@ -20,7 +20,7 @@ import { createAppRootMockRenderer, } from '../../../../../../common/mock/endpoint'; import { EventFiltersListPageState } from '../../../types'; -import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../../../services/policies/test_mock_utilts'; +import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../../../services/policies/test_mock_utils'; import { GetPolicyListResponse } from '../../../../policy/types'; import userEvent from '@testing-library/user-event'; import { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.test.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.test.tsx index 5833c12be879f..ec0adf0c10a23 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.test.tsx @@ -13,7 +13,7 @@ import { EventFiltersListPage } from './event_filters_list_page'; import { eventFiltersListQueryHttpMock } from '../test_utils'; import { isFailedResourceState, isLoadedResourceState } from '../../../state'; import { sendGetEndpointSpecificPackagePolicies } from '../../../services/policies/policies'; -import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../services/policies/test_mock_utilts'; +import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../services/policies/test_mock_utils'; // Needed to mock the data services used by the ExceptionItem component jest.mock('../../../../common/lib/kibana'); diff --git a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.test.tsx b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.test.tsx index 0d04ee83a56e5..b9ffec3c8bc39 100644 --- a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.test.tsx @@ -16,7 +16,7 @@ import { AppContextTestRender, createAppRootMockRenderer, } from '../../../../../common/mock/endpoint'; -import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../../services/policies/test_mock_utilts'; +import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../../services/policies/test_mock_utils'; import { GetPolicyListResponse } from '../../../policy/types'; import { createEmptyHostIsolationException } from '../../utils'; import { HostIsolationExceptionsForm } from './form'; diff --git a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form_flyout.test.tsx b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form_flyout.test.tsx index e9735c6bad5ef..46ea59a802c49 100644 --- a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form_flyout.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form_flyout.test.tsx @@ -15,7 +15,7 @@ import { } from '../../../../../common/mock/endpoint'; import { getHostIsolationExceptionsListPath } from '../../../../common/routing'; import { sendGetEndpointSpecificPackagePolicies } from '../../../../services/policies/policies'; -import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../../services/policies/test_mock_utilts'; +import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../../services/policies/test_mock_utils'; import { createHostIsolationExceptionItem, getOneHostIsolationExceptionItem, diff --git a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.test.tsx b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.test.tsx index 57c8485c0eda6..e84dfeb336f1f 100644 --- a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.test.tsx @@ -14,7 +14,7 @@ import { EndpointPrivileges } from '../../../../../common/endpoint/types'; import { useUserPrivileges as _useUserPrivileges } from '../../../../common/components/user_privileges'; import { AppContextTestRender, createAppRootMockRenderer } from '../../../../common/mock/endpoint'; import { sendGetEndpointSpecificPackagePolicies } from '../../../services/policies/policies'; -import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../services/policies/test_mock_utilts'; +import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../services/policies/test_mock_utils'; import { getHostIsolationExceptionItems } from '../service'; import { HostIsolationExceptionsList } from './host_isolation_exceptions_list'; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware/policy_settings_middleware.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware/policy_settings_middleware.ts index 784565b5d8e1d..f90fdf1213581 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware/policy_settings_middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware/policy_settings_middleware.ts @@ -22,7 +22,7 @@ import { sendGetPackagePolicy, sendGetFleetAgentStatusForPolicy, sendPutPackagePolicy, -} from '../../services/ingest'; +} from '../../../../../services/policies/ingest'; import { NewPolicyData, PolicyData } from '../../../../../../../common/endpoint/types'; import { getPolicyDataForUpdate } from '../../../../../../../common/endpoint/service/policy'; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/test_mock_utils.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/test_mock_utils.ts index 785ba6f066ffb..bfd4637a1f416 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/test_mock_utils.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/test_mock_utils.ts @@ -5,7 +5,10 @@ * 2.0. */ -import { INGEST_API_EPM_PACKAGES, INGEST_API_PACKAGE_POLICIES } from './services/ingest'; +import { + INGEST_API_EPM_PACKAGES, + INGEST_API_PACKAGE_POLICIES, +} from '../../../services/policies/ingest'; import { EndpointDocGenerator } from '../../../../../common/endpoint/generate_data'; import { GetPolicyListResponse } from '../types'; import { GetPackagesResponse } from '../../../../../../fleet/common'; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.test.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.test.tsx index 025c36261d120..482fe0ba064bd 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.test.tsx @@ -9,15 +9,15 @@ import React from 'react'; import { act, waitFor, fireEvent } from '@testing-library/react'; import { AppContextTestRender, createAppRootMockRenderer } from '../../../../common/mock/endpoint'; import { sendGetEndpointSpecificPackagePolicies } from '../../../services/policies/policies'; -import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../services/policies/test_mock_utilts'; +import { sendGetEndpointSpecificPackagePoliciesMock } from '../../../services/policies/test_mock_utils'; import { PolicyList } from './policy_list'; -import { sendGetAgentPolicyList } from '../store/services/ingest'; +import { sendGetAgentPolicyList } from '../../../services/policies/ingest'; import { GetPolicyListResponse } from '../types'; import { getEndpointListPath, getPoliciesPath } from '../../../common/routing'; import { APP_UI_ID } from '../../../../../common/constants'; jest.mock('../../../services/policies/policies'); -jest.mock('../store/services/ingest'); +jest.mock('../../../services/policies/ingest'); const getPackagePolicies = sendGetEndpointSpecificPackagePolicies as jest.Mock; @@ -39,6 +39,36 @@ describe('When on the policy list page', () => { jest.clearAllMocks(); }); + describe('and there are no policies', () => { + beforeEach(async () => { + getPackagePolicies.mockImplementation(() => + sendGetEndpointSpecificPackagePoliciesMock({ + page: 1, + perPage: 20, + count: 0, + }) + ); + render(); + await waitFor(() => { + expect(getPackagePolicies).toHaveBeenCalled(); + }); + }); + afterEach(() => { + getPackagePolicies.mockReset(); + }); + it('should show the empty page', () => { + expect(renderResult.getByTestId('emptyPolicyTable')).toBeTruthy(); + }); + it('should show instruction text and a button to add the Endpoint Security integration', () => { + expect( + renderResult.findByText( + 'From this page, you’ll be able to view and manage the Endpoint Security Integration policies in your environment running Endpoint Security.' + ) + ).toBeTruthy(); + expect(renderResult.getByTestId('onboardingStartButton')).toBeTruthy(); + }); + }); + describe('and data exists', () => { let policies: GetPolicyListResponse; beforeEach(async () => { diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx index ad0c7fb287976..44649936c490a 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx @@ -32,11 +32,12 @@ import { import { AgentPolicy } from '../../../../../../fleet/common'; import { PolicyEmptyState } from '../../../components/management_empty_state'; import { useNavigateToAppEventHandler } from '../../../../common/hooks/endpoint/use_navigate_to_app_event_handler'; -import { CreatePackagePolicyRouteState } from '../../../../../../fleet/public'; +import { CreatePackagePolicyRouteState, pagePathGetters } from '../../../../../../fleet/public'; import { APP_UI_ID } from '../../../../../common/constants'; import { getPoliciesPath } from '../../../common/routing'; import { useAppUrl, useToasts } from '../../../../common/lib/kibana'; import { PolicyEndpointCount } from './components/policy_endpoint_count'; +import { ManagementEmptyStateWrapper } from '../../../components/management_empty_state_wrapper'; export const PolicyList = memo(() => { const { pagination, pageSizeOptions, setPagination } = useUrlPagination(); @@ -122,9 +123,9 @@ export const PolicyList = memo(() => { const handleCreatePolicyClick = useNavigateToAppEventHandler( 'fleet', { - path: `/integrations/${ - endpointPackageInfo ? `/endpoint-${endpointPackageInfo?.version}` : '' - }/add-integration`, + path: pagePathGetters.add_integration_to_policy({ + pkgkey: endpointPackageInfo ? `/endpoint-${endpointPackageInfo?.version}` : '', + })[1], state: { onCancelNavigateTo: [ APP_UI_ID, @@ -316,11 +317,13 @@ export const PolicyList = memo(() => { /> ) : ( - + + + )} ); diff --git a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/service/validate_trusted_app_http_request_body.ts b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/service/validate_trusted_app_http_request_body.ts index e0a5adac67494..60568594c7784 100644 --- a/x-pack/plugins/security_solution/public/management/pages/trusted_apps/service/validate_trusted_app_http_request_body.ts +++ b/x-pack/plugins/security_solution/public/management/pages/trusted_apps/service/validate_trusted_app_http_request_body.ts @@ -11,7 +11,7 @@ import { PutTrustedAppUpdateRequest, } from '../../../../../common/endpoint/types'; import { HttpRequestValidationError } from './errors'; -import { sendGetAgentPolicyList } from '../../policy/store/services/ingest'; +import { sendGetAgentPolicyList } from '../../../services/policies/ingest'; import { AGENT_POLICY_SAVED_OBJECT_TYPE } from '../../../../../../fleet/common'; /** diff --git a/x-pack/plugins/security_solution/public/management/services/policies/hooks.test.ts b/x-pack/plugins/security_solution/public/management/services/policies/hooks.test.ts index 2b01366d8306e..aa7b50c69ed56 100644 --- a/x-pack/plugins/security_solution/public/management/services/policies/hooks.test.ts +++ b/x-pack/plugins/security_solution/public/management/services/policies/hooks.test.ts @@ -7,7 +7,7 @@ import { useGetEndpointSecurityPackage } from './hooks'; import { HttpFetchError, HttpSetup } from 'kibana/public'; -import { getFakeHttpService, renderQuery } from '../../hooks/artifacts/test_utils'; +import { getFakeHttpService, renderQuery } from '../../hooks/test_utils'; import { EndpointDocGenerator } from '../../../../common/endpoint/generate_data'; import { UseQueryOptions } from 'react-query'; import { GetPackagesResponse } from '../../../../../fleet/common'; diff --git a/x-pack/plugins/security_solution/public/management/services/policies/hooks.ts b/x-pack/plugins/security_solution/public/management/services/policies/hooks.ts index 7b8ce6a86b148..649dd39e38da6 100644 --- a/x-pack/plugins/security_solution/public/management/services/policies/hooks.ts +++ b/x-pack/plugins/security_solution/public/management/services/policies/hooks.ts @@ -13,10 +13,7 @@ import { } from '../../../../../fleet/common'; import { useHttp } from '../../../common/lib/kibana'; import { MANAGEMENT_DEFAULT_PAGE_SIZE } from '../../common/constants'; -import { - sendGetAgentPolicyList, - sendGetEndpointSecurityPackage, -} from '../../pages/policy/store/services/ingest'; +import { sendGetAgentPolicyList, sendGetEndpointSecurityPackage } from './ingest'; import { GetPolicyListResponse } from '../../pages/policy/types'; import { sendGetEndpointSpecificPackagePolicies } from './policies'; import { ServerApiError } from '../../../common/types'; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/services/ingest.test.ts b/x-pack/plugins/security_solution/public/management/services/policies/ingest.test.ts similarity index 90% rename from x-pack/plugins/security_solution/public/management/pages/policy/store/services/ingest.test.ts rename to x-pack/plugins/security_solution/public/management/services/policies/ingest.test.ts index ef66c948e1127..bd34f7c14e22a 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/services/ingest.test.ts +++ b/x-pack/plugins/security_solution/public/management/services/policies/ingest.test.ts @@ -10,9 +10,9 @@ import { sendGetPackagePolicy, sendGetEndpointSecurityPackage, } from './ingest'; -import { httpServiceMock } from '../../../../../../../../../src/core/public/mocks'; -import { EPM_API_ROUTES, PACKAGE_POLICY_API_ROOT } from '../../../../../../../fleet/common'; -import { policyListApiPathHandlers } from '../test_mock_utils'; +import { httpServiceMock } from '../../../../../../../src/core/public/mocks'; +import { EPM_API_ROUTES, PACKAGE_POLICY_API_ROOT } from '../../../../../fleet/common'; +import { policyListApiPathHandlers } from '../../pages/policy/store/test_mock_utils'; describe('ingest service', () => { let http: ReturnType; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/services/ingest.ts b/x-pack/plugins/security_solution/public/management/services/policies/ingest.ts similarity index 95% rename from x-pack/plugins/security_solution/public/management/pages/policy/store/services/ingest.ts rename to x-pack/plugins/security_solution/public/management/services/policies/ingest.ts index 651d5840116f0..0863682357aca 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/services/ingest.ts +++ b/x-pack/plugins/security_solution/public/management/services/policies/ingest.ts @@ -14,9 +14,9 @@ import { GetPackagesResponse, GetAgentPoliciesRequest, GetAgentPoliciesResponse, -} from '../../../../../../../fleet/common'; -import { GetPolicyResponse, UpdatePolicyResponse } from '../../types'; -import { NewPolicyData } from '../../../../../../common/endpoint/types'; +} from '../../../../../fleet/common'; +import { NewPolicyData } from '../../../../common/endpoint/types'; +import { GetPolicyResponse, UpdatePolicyResponse } from '../../pages/policy/types'; const INGEST_API_ROOT = `/api/fleet`; export const INGEST_API_PACKAGE_POLICIES = `${INGEST_API_ROOT}/package_policies`; diff --git a/x-pack/plugins/security_solution/public/management/services/policies/policies.ts b/x-pack/plugins/security_solution/public/management/services/policies/policies.ts index 2cd71fb26655a..219bf7698baaa 100644 --- a/x-pack/plugins/security_solution/public/management/services/policies/policies.ts +++ b/x-pack/plugins/security_solution/public/management/services/policies/policies.ts @@ -10,8 +10,8 @@ import { GetPackagePoliciesRequest, PACKAGE_POLICY_SAVED_OBJECT_TYPE, } from '../../../../../fleet/common'; -import { INGEST_API_PACKAGE_POLICIES } from '../../pages/policy/store/services/ingest'; import { GetPolicyListResponse } from '../../pages/policy/types'; +import { INGEST_API_PACKAGE_POLICIES } from './ingest'; /** * Retrieves a list of endpoint specific package policies (those created with a `package.name` of diff --git a/x-pack/plugins/security_solution/public/management/services/policies/test_mock_utilts.ts b/x-pack/plugins/security_solution/public/management/services/policies/test_mock_utils.ts similarity index 100% rename from x-pack/plugins/security_solution/public/management/services/policies/test_mock_utilts.ts rename to x-pack/plugins/security_solution/public/management/services/policies/test_mock_utils.ts