From 244443e7220b15a659da58f6b6ed971c1010f8e5 Mon Sep 17 00:00:00 2001 From: Marshall Main Date: Wed, 17 Jun 2020 19:04:24 -0400 Subject: [PATCH] fix more types --- .../common/endpoint/generate_data.test.ts | 8 +++++--- .../pages/endpoint_hosts/store/selectors.ts | 4 ++-- .../view/details/host_details.tsx | 6 +++--- .../pages/endpoint_hosts/view/index.test.tsx | 18 +++++++++--------- .../pages/endpoint_hosts/view/index.tsx | 4 ++-- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/security_solution/common/endpoint/generate_data.test.ts b/x-pack/plugins/security_solution/common/endpoint/generate_data.test.ts index 836a6a89be6e96..d7b653916970fa 100644 --- a/x-pack/plugins/security_solution/common/endpoint/generate_data.test.ts +++ b/x-pack/plugins/security_solution/common/endpoint/generate_data.test.ts @@ -57,10 +57,10 @@ describe('data generator', () => { const hostPolicyResponse = generator.generatePolicyResponse(timestamp); expect(hostPolicyResponse['@timestamp']).toEqual(timestamp); expect(hostPolicyResponse.event.created).toEqual(timestamp); - expect(hostPolicyResponse.endpoint).not.toBeNull(); + expect(hostPolicyResponse.Endpoint).not.toBeNull(); expect(hostPolicyResponse.agent).not.toBeNull(); expect(hostPolicyResponse.host).not.toBeNull(); - expect(hostPolicyResponse.endpoint.policy.applied).not.toBeNull(); + expect(hostPolicyResponse.Endpoint.policy.applied).not.toBeNull(); }); it('creates alert event documents', () => { @@ -364,7 +364,9 @@ describe('data generator', () => { it('creates full resolver tree', () => { const alertAncestors = 3; const generations = 2; - const events = [...generator.fullResolverTreeGenerator(alertAncestors, generations)]; + const events = [ + ...generator.fullResolverTreeGenerator({ ancestors: alertAncestors, generations }), + ]; const rootNode = buildResolverTree(events); const visitedEvents = countResolverEvents(rootNode, alertAncestors + generations); expect(visitedEvents).toEqual(events.length); diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/selectors.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/selectors.ts index 5e7cbc0ef58d34..20365b3fe100b9 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/selectors.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/selectors.ts @@ -41,7 +41,7 @@ export const detailsError = (state: Immutable) => state.detailsError; * Returns the full policy response from the endpoint after a user modifies a policy. */ const detailsPolicyAppliedResponse = (state: Immutable) => - state.policyResponse && state.policyResponse.endpoint.policy.applied; + state.policyResponse && state.policyResponse.Endpoint.policy.applied; /** * Returns the response configurations from the endpoint after a user modifies a policy. @@ -179,6 +179,6 @@ export const showView: (state: HostState) => 'policy_response' | 'details' = cre export const policyResponseStatus: (state: Immutable) => string = createSelector( (state) => state.policyResponse, (policyResponse) => { - return (policyResponse && policyResponse?.endpoint?.policy?.applied?.status) || ''; + return (policyResponse && policyResponse?.Endpoint?.policy?.applied?.status) || ''; } ); diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx index 8406ca655891c8..f31b54b93851f0 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx @@ -97,15 +97,15 @@ export const HostDetails = memo(({ details }: { details: HostMetadata }) => { return [ getManagementUrl({ name: 'policyDetails', - policyId: details.endpoint.policy.applied.id, + policyId: details.Endpoint.policy.applied.id, excludePrefix: true, }), getManagementUrl({ name: 'policyDetails', - policyId: details.endpoint.policy.applied.id, + policyId: details.Endpoint.policy.applied.id, }), ]; - }, [details.endpoint.policy.applied.id]); + }, [details.Endpoint.policy.applied.id]); const policyDetailsClickHandler = useNavigateByRouterEventHandler(policyDetailsRoutePath); 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 e0f797b1430551..1948c88a15a0ec 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 @@ -50,13 +50,13 @@ describe('when on the hosts page', () => { }); describe('when list data loads', () => { const generatedPolicyStatuses: Array< - HostInfo['metadata']['endpoint']['policy']['applied']['status'] + HostInfo['metadata']['Endpoint']['policy']['applied']['status'] > = []; let firstPolicyID: string; beforeEach(() => { reactTestingLibrary.act(() => { const hostListData = mockHostResultList({ total: 3 }); - firstPolicyID = hostListData.hosts[0].metadata.endpoint.policy.applied.id; + firstPolicyID = hostListData.hosts[0].metadata.Endpoint.policy.applied.id; [HostStatus.ERROR, HostStatus.ONLINE, HostStatus.OFFLINE].forEach((status, index) => { hostListData.hosts[index] = { metadata: hostListData.hosts[index].metadata, @@ -64,7 +64,7 @@ describe('when on the hosts page', () => { }; }); hostListData.hosts.forEach((item, index) => { - generatedPolicyStatuses[index] = item.metadata.endpoint.policy.applied.status; + generatedPolicyStatuses[index] = item.metadata.Endpoint.policy.applied.status; }); const action: AppAction = { type: 'serverReturnedHostList', @@ -160,9 +160,9 @@ describe('when on the hosts page', () => { overallStatus: HostPolicyResponseActionStatus = HostPolicyResponseActionStatus.success ) => { const policyResponse = docGenerator.generatePolicyResponse(); - policyResponse.endpoint.policy.applied.status = overallStatus; - policyResponse.endpoint.policy.applied.response.configurations.malware.status = overallStatus; - let downloadModelAction = policyResponse.endpoint.policy.applied.actions.find( + policyResponse.Endpoint.policy.applied.status = overallStatus; + policyResponse.Endpoint.policy.applied.response.configurations.malware.status = overallStatus; + let downloadModelAction = policyResponse.Endpoint.policy.applied.actions.find( (action) => action.name === 'download_model' ); @@ -172,7 +172,7 @@ describe('when on the hosts page', () => { message: 'Failed to apply a portion of the configuration (kernel)', status: overallStatus, }; - policyResponse.endpoint.policy.applied.actions.push(downloadModelAction); + policyResponse.Endpoint.policy.applied.actions.push(downloadModelAction); } if ( overallStatus === HostPolicyResponseActionStatus.failure || @@ -236,7 +236,7 @@ describe('when on the hosts page', () => { const policyDetailsLink = await renderResult.findByTestId('policyDetailsValue'); expect(policyDetailsLink).not.toBeNull(); expect(policyDetailsLink.getAttribute('href')).toEqual( - `#/management/policy/${hostDetails.metadata.endpoint.policy.applied.id}` + `#/management/policy/${hostDetails.metadata.Endpoint.policy.applied.id}` ); }); @@ -252,7 +252,7 @@ describe('when on the hosts page', () => { }); const changedUrlAction = await userChangedUrlChecker; expect(changedUrlAction.payload.pathname).toEqual( - `/management/policy/${hostDetails.metadata.endpoint.policy.applied.id}` + `/management/policy/${hostDetails.metadata.Endpoint.policy.applied.id}` ); }); 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 c67c29fbc73a90..76218af9801f29 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 @@ -160,7 +160,7 @@ export const HostList = () => { }), truncateText: true, // eslint-disable-next-line react/display-name - render: (policy: HostInfo['metadata']['endpoint']['policy']['applied']) => { + render: (policy: HostInfo['metadata']['Endpoint']['policy']['applied']) => { const toRoutePath = getManagementUrl({ name: 'policyDetails', policyId: policy.id, @@ -186,7 +186,7 @@ export const HostList = () => { defaultMessage: 'Policy Status', }), // eslint-disable-next-line react/display-name - render: (policy: HostInfo['metadata']['endpoint']['policy']['applied'], item: HostInfo) => { + render: (policy: HostInfo['metadata']['Endpoint']['policy']['applied'], item: HostInfo) => { const toRoutePath = getManagementUrl({ name: 'endpointPolicyResponse', selected_host: item.metadata.host.id,