Skip to content

Commit

Permalink
[Security Solution][Endpoint] Re-organize responder folder and hooks …
Browse files Browse the repository at this point in the history
…folder within endpoint management (#144277)

* re-organized the `endpoint_responder/` folder

* Rename `getEndpointResponseActionsConsoleCommands()`

* re-organize the hooks folder

* fix jest.mock() paths

* Update jest test snapshot
  • Loading branch information
paul-tavares authored Nov 1, 2022
1 parent 1acc9a4 commit 6f5b716
Show file tree
Hide file tree
Showing 49 changed files with 181 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { memo, useMemo } from 'react';
import { EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { endpointActionResponseCodes } from '../endpoint_responder/endpoint_action_response_codes';
import { endpointActionResponseCodes } from '../endpoint_responder/lib/endpoint_action_response_codes';
import type { ActionDetails, MaybeImmutable } from '../../../../common/endpoint/types';

interface EndpointActionFailureMessageProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import React, { memo, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { useSendGetFileRequest } from '../../hooks/endpoint/use_send_get_file_request';
import type { ResponseActionGetFileRequestBody } from '../../../../common/endpoint/schema/actions';
import { useConsoleActionSubmitter } from './hooks/use_console_action_submitter';
import type { ActionRequestComponentProps } from './types';
import { ResponseActionFileDownloadLink } from '../response_action_file_download_link';
import { useSendGetFileRequest } from '../../../hooks/response_actions/use_send_get_file_request';
import type { ResponseActionGetFileRequestBody } from '../../../../../common/endpoint/schema/actions';
import { useConsoleActionSubmitter } from '../hooks/use_console_action_submitter';
import type { ActionRequestComponentProps } from '../types';
import { ResponseActionFileDownloadLink } from '../../response_action_file_download_link';

export const GetFileActionResult = memo<
ActionRequestComponentProps<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import React, { memo, useMemo } from 'react';
import styled from 'styled-components';
import { EuiBasicTable } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useConsoleActionSubmitter } from './hooks/use_console_action_submitter';
import { useConsoleActionSubmitter } from '../hooks/use_console_action_submitter';
import type {
GetProcessesActionOutputContent,
ProcessesRequestBody,
} from '../../../../common/endpoint/types';
import { useSendGetEndpointProcessesRequest } from '../../hooks/endpoint/use_send_get_endpoint_processes_request';
import type { ActionRequestComponentProps } from './types';
} from '../../../../../common/endpoint/types';
import { useSendGetEndpointProcessesRequest } from '../../../hooks/response_actions/use_send_get_endpoint_processes_request';
import type { ActionRequestComponentProps } from '../types';

// @ts-expect-error TS2769
const StyledEuiBasicTable = styled(EuiBasicTable)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
* 2.0.
*/

import type { EndpointCapabilities } from '../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../common/endpoint/service/response_actions/constants';
import type { AppContextTestRender } from '../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../common/mock/endpoint';
import { responseActionsHttpMocks } from '../../../mocks/response_actions_http_mocks';
import type { EndpointCapabilities } from '../../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../../common/endpoint/service/response_actions/constants';
import type { AppContextTestRender } from '../../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint';
import { responseActionsHttpMocks } from '../../../../mocks/response_actions_http_mocks';
import {
ConsoleManagerTestComponent,
getConsoleManagerMockRenderResultQueriesAndActions,
} from '../../console/components/console_manager/mocks';
import { getEndpointResponseActionsConsoleCommands } from '..';
} from '../../../console/components/console_manager/mocks';
import { getEndpointConsoleCommands } from '../..';
import React from 'react';
import { enterConsoleCommand } from '../../console/mocks';
import { enterConsoleCommand } from '../../../console/mocks';
import { waitFor } from '@testing-library/react';
import { GET_FILE_ROUTE } from '../../../../../common/endpoint/constants';
import { getEndpointAuthzInitialStateMock } from '../../../../../common/endpoint/service/authz/mocks';
import type { EndpointPrivileges } from '../../../../../common/endpoint/types';
import { INSUFFICIENT_PRIVILEGES_FOR_COMMAND } from '../../../../common/translations';
import { GET_FILE_ROUTE } from '../../../../../../common/endpoint/constants';
import { getEndpointAuthzInitialStateMock } from '../../../../../../common/endpoint/service/authz/mocks';
import type { EndpointPrivileges } from '../../../../../../common/endpoint/types';
import { INSUFFICIENT_PRIVILEGES_FOR_COMMAND } from '../../../../../common/translations';
import type { HttpFetchOptionsWithPath } from '@kbn/core-http-browser';

jest.mock('../../../../common/components/user_privileges');
jest.mock('../../../../../common/components/user_privileges');

describe('When using get-file action from response actions console', () => {
let render: (
Expand All @@ -50,7 +50,7 @@ describe('When using get-file action from response actions console', () => {
return {
consoleProps: {
'data-test-subj': 'test',
commands: getEndpointResponseActionsConsoleCommands({
commands: getEndpointConsoleCommands({
endpointAgentId: 'a.b.c',
endpointCapabilities: [...capabilities],
endpointPrivileges,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
* 2.0.
*/

import type { AppContextTestRender } from '../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../common/mock/endpoint';
import type { AppContextTestRender } from '../../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint';
import {
ConsoleManagerTestComponent,
getConsoleManagerMockRenderResultQueriesAndActions,
} from '../../console/components/console_manager/mocks';
} from '../../../console/components/console_manager/mocks';
import React from 'react';
import { getEndpointResponseActionsConsoleCommands } from '../endpoint_response_actions_console_commands';
import { responseActionsHttpMocks } from '../../../mocks/response_actions_http_mocks';
import { enterConsoleCommand } from '../../console/mocks';
import { getEndpointConsoleCommands } from '../../lib/console_commands_definition';
import { responseActionsHttpMocks } from '../../../../mocks/response_actions_http_mocks';
import { enterConsoleCommand } from '../../../console/mocks';
import { waitFor } from '@testing-library/react';
import { getEndpointAuthzInitialState } from '../../../../../common/endpoint/service/authz';
import type { EndpointCapabilities } from '../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../common/endpoint/service/response_actions/constants';
import { getEndpointAuthzInitialState } from '../../../../../../common/endpoint/service/authz';
import type { EndpointCapabilities } from '../../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../../common/endpoint/service/response_actions/constants';

describe('When using processes action from response actions console', () => {
let render: (
Expand All @@ -42,7 +42,7 @@ describe('When using processes action from response actions console', () => {
return {
consoleProps: {
'data-test-subj': 'test',
commands: getEndpointResponseActionsConsoleCommands({
commands: getEndpointConsoleCommands({
endpointAgentId: 'a.b.c',
endpointCapabilities: [...capabilities],
endpointPrivileges: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
* 2.0.
*/

import type { AppContextTestRender } from '../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../common/mock/endpoint';
import type { AppContextTestRender } from '../../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint';
import {
ConsoleManagerTestComponent,
getConsoleManagerMockRenderResultQueriesAndActions,
} from '../../console/components/console_manager/mocks';
} from '../../../console/components/console_manager/mocks';
import React from 'react';
import { getEndpointResponseActionsConsoleCommands } from '../endpoint_response_actions_console_commands';
import { responseActionsHttpMocks } from '../../../mocks/response_actions_http_mocks';
import { enterConsoleCommand } from '../../console/mocks';
import { getEndpointConsoleCommands } from '../../lib/console_commands_definition';
import { responseActionsHttpMocks } from '../../../../mocks/response_actions_http_mocks';
import { enterConsoleCommand } from '../../../console/mocks';
import { waitFor } from '@testing-library/react';
import { getDeferred } from '../../../mocks/utils';
import { getEndpointAuthzInitialState } from '../../../../../common/endpoint/service/authz';
import type { EndpointCapabilities } from '../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../common/endpoint/service/response_actions/constants';
import { getDeferred } from '../../../../mocks/utils';
import { getEndpointAuthzInitialState } from '../../../../../../common/endpoint/service/authz';
import type { EndpointCapabilities } from '../../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../../common/endpoint/service/response_actions/constants';

describe('When using isolate action from response actions console', () => {
let render: (
Expand All @@ -43,7 +43,7 @@ describe('When using isolate action from response actions console', () => {
return {
consoleProps: {
'data-test-subj': 'test',
commands: getEndpointResponseActionsConsoleCommands({
commands: getEndpointConsoleCommands({
endpointAgentId: 'a.b.c',
endpointCapabilities: [...capabilities],
endpointPrivileges: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
* 2.0.
*/

import type { AppContextTestRender } from '../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../common/mock/endpoint';
import type { AppContextTestRender } from '../../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint';
import {
ConsoleManagerTestComponent,
getConsoleManagerMockRenderResultQueriesAndActions,
} from '../../console/components/console_manager/mocks';
} from '../../../console/components/console_manager/mocks';
import React from 'react';
import { getEndpointResponseActionsConsoleCommands } from '../endpoint_response_actions_console_commands';
import { enterConsoleCommand } from '../../console/mocks';
import { getEndpointConsoleCommands } from '../../lib/console_commands_definition';
import { enterConsoleCommand } from '../../../console/mocks';
import { waitFor } from '@testing-library/react';
import { responseActionsHttpMocks } from '../../../mocks/response_actions_http_mocks';
import { getEndpointAuthzInitialState } from '../../../../../common/endpoint/service/authz';
import type { EndpointCapabilities } from '../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../common/endpoint/service/response_actions/constants';
import { responseActionsHttpMocks } from '../../../../mocks/response_actions_http_mocks';
import { getEndpointAuthzInitialState } from '../../../../../../common/endpoint/service/authz';
import type { EndpointCapabilities } from '../../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../../common/endpoint/service/response_actions/constants';

describe('When using the kill-process action from response actions console', () => {
let render: (
Expand All @@ -42,7 +42,7 @@ describe('When using the kill-process action from response actions console', ()
return {
consoleProps: {
'data-test-subj': 'test',
commands: getEndpointResponseActionsConsoleCommands({
commands: getEndpointConsoleCommands({
endpointAgentId: 'a.b.c',
endpointCapabilities: [...capabilities],
endpointPrivileges: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
* 2.0.
*/

import type { AppContextTestRender } from '../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../common/mock/endpoint';
import type { AppContextTestRender } from '../../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint';
import {
ConsoleManagerTestComponent,
getConsoleManagerMockRenderResultQueriesAndActions,
} from '../../console/components/console_manager/mocks';
} from '../../../console/components/console_manager/mocks';
import React from 'react';
import { getEndpointResponseActionsConsoleCommands } from '../endpoint_response_actions_console_commands';
import { enterConsoleCommand } from '../../console/mocks';
import { getEndpointConsoleCommands } from '../../lib/console_commands_definition';
import { enterConsoleCommand } from '../../../console/mocks';
import { waitFor } from '@testing-library/react';
import { responseActionsHttpMocks } from '../../../mocks/response_actions_http_mocks';
import { getDeferred } from '../../../mocks/utils';
import { getEndpointAuthzInitialState } from '../../../../../common/endpoint/service/authz';
import type { EndpointCapabilities } from '../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../common/endpoint/service/response_actions/constants';
import { responseActionsHttpMocks } from '../../../../mocks/response_actions_http_mocks';
import { getDeferred } from '../../../../mocks/utils';
import { getEndpointAuthzInitialState } from '../../../../../../common/endpoint/service/authz';
import type { EndpointCapabilities } from '../../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../../common/endpoint/service/response_actions/constants';

describe('When using the release action from response actions console', () => {
let render: (
Expand All @@ -43,7 +43,7 @@ describe('When using the release action from response actions console', () => {
return {
consoleProps: {
'data-test-subj': 'test',
commands: getEndpointResponseActionsConsoleCommands({
commands: getEndpointConsoleCommands({
endpointAgentId: 'a.b.c',
endpointCapabilities: [...capabilities],
endpointPrivileges: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
* 2.0.
*/

import type { AppContextTestRender } from '../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../common/mock/endpoint';
import type { AppContextTestRender } from '../../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint';
import {
ConsoleManagerTestComponent,
getConsoleManagerMockRenderResultQueriesAndActions,
} from '../../console/components/console_manager/mocks';
} from '../../../console/components/console_manager/mocks';
import React from 'react';
import { getEndpointResponseActionsConsoleCommands } from '../endpoint_response_actions_console_commands';
import { enterConsoleCommand } from '../../console/mocks';
import { getEndpointConsoleCommands } from '../../lib/console_commands_definition';
import { enterConsoleCommand } from '../../../console/mocks';
import { waitFor } from '@testing-library/react';
import { responseActionsHttpMocks } from '../../../mocks/response_actions_http_mocks';
import { getEndpointAuthzInitialState } from '../../../../../common/endpoint/service/authz';
import type { EndpointCapabilities } from '../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../common/endpoint/service/response_actions/constants';
import { responseActionsHttpMocks } from '../../../../mocks/response_actions_http_mocks';
import { getEndpointAuthzInitialState } from '../../../../../../common/endpoint/service/authz';
import type { EndpointCapabilities } from '../../../../../../common/endpoint/service/response_actions/constants';
import { ENDPOINT_CAPABILITIES } from '../../../../../../common/endpoint/service/response_actions/constants';

describe('When using the suspend-process action from response actions console', () => {
let render: (
Expand All @@ -42,7 +42,7 @@ describe('When using the suspend-process action from response actions console',
return {
consoleProps: {
'data-test-subj': 'test',
commands: getEndpointResponseActionsConsoleCommands({
commands: getEndpointConsoleCommands({
endpointAgentId: 'a.b.c',
endpointCapabilities: [...capabilities],
endpointPrivileges: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import { memo, useMemo } from 'react';
import { useConsoleActionSubmitter } from './hooks/use_console_action_submitter';
import type { ActionRequestComponentProps } from './types';
import { useSendIsolateEndpointRequest } from '../../hooks/endpoint/use_send_isolate_endpoint_request';
import { useConsoleActionSubmitter } from '../hooks/use_console_action_submitter';
import type { ActionRequestComponentProps } from '../types';
import { useSendIsolateEndpointRequest } from '../../../hooks/response_actions/use_send_isolate_endpoint_request';

export const IsolateActionResult = memo<ActionRequestComponentProps>(
({ command, setStore, store, status, setStatus, ResultComponent }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

import { memo, useMemo } from 'react';
import type { KillOrSuspendProcessRequestBody } from '../../../../common/endpoint/types';
import { parsedPidOrEntityIdParameter } from './utils';
import { useSendKillProcessRequest } from '../../hooks/endpoint/use_send_kill_process_endpoint_request';
import type { ActionRequestComponentProps } from './types';
import { useConsoleActionSubmitter } from './hooks/use_console_action_submitter';
import type { KillOrSuspendProcessRequestBody } from '../../../../../common/endpoint/types';
import { parsedPidOrEntityIdParameter } from '../lib/utils';
import { useSendKillProcessRequest } from '../../../hooks/response_actions/use_send_kill_process_endpoint_request';
import type { ActionRequestComponentProps } from '../types';
import { useConsoleActionSubmitter } from '../hooks/use_console_action_submitter';

export const KillProcessActionResult = memo<
ActionRequestComponentProps<{ pid?: string[]; entityId?: string[] }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import { memo, useMemo } from 'react';
import type { ActionRequestComponentProps } from './types';
import { useSendReleaseEndpointRequest } from '../../hooks/endpoint/use_send_release_endpoint_request';
import { useConsoleActionSubmitter } from './hooks/use_console_action_submitter';
import type { ActionRequestComponentProps } from '../types';
import { useSendReleaseEndpointRequest } from '../../../hooks/response_actions/use_send_release_endpoint_request';
import { useConsoleActionSubmitter } from '../hooks/use_console_action_submitter';

export const ReleaseActionResult = memo<ActionRequestComponentProps>(
({ command, setStore, store, status, setStatus, ResultComponent }) => {
Expand Down
Loading

0 comments on commit 6f5b716

Please sign in to comment.