Skip to content

Commit

Permalink
[8.x] [ResponseOps][Cases]Allow users to push to external service whe…
Browse files Browse the repository at this point in the history
…n the case is closed (#198146) (#199428)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps][Cases]Allow users to push to external service when the
case is closed (#198146)](#198146)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Georgiana-Andreea
Onoleață","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-08T09:32:11Z","message":"[ResponseOps][Cases]Allow
users to push to external service when the case is closed
(#198146)\n\nCloses
https://github.com/elastic/kibana/issues/192552\r\n\r\n##
Summary\r\n\r\n- Removed the restriction that didn't allow user to push
a closed case\r\nto an external
service.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/82c49524-5685-40c0-b025-d6b38ab4e056\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Antonio
<[email protected]>","sha":"cc6ffef06c30134dafcd40946659d41a38f63d56","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["enhancement","release_note:skip","Team:ResponseOps","v9.0.0","backport:prev-minor","v8.17.0"],"title":"[ResponseOps][Cases]Allow
users to push to external service when the case is
closed","number":198146,"url":"https://github.com/elastic/kibana/pull/198146","mergeCommit":{"message":"[ResponseOps][Cases]Allow
users to push to external service when the case is closed
(#198146)\n\nCloses
https://github.com/elastic/kibana/issues/192552\r\n\r\n##
Summary\r\n\r\n- Removed the restriction that didn't allow user to push
a closed case\r\nto an external
service.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/82c49524-5685-40c0-b025-d6b38ab4e056\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Antonio
<[email protected]>","sha":"cc6ffef06c30134dafcd40946659d41a38f63d56"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198146","number":198146,"mergeCommit":{"message":"[ResponseOps][Cases]Allow
users to push to external service when the case is closed
(#198146)\n\nCloses
https://github.com/elastic/kibana/issues/192552\r\n\r\n##
Summary\r\n\r\n- Removed the restriction that didn't allow user to push
a closed case\r\nto an external
service.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/82c49524-5685-40c0-b025-d6b38ab4e056\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>\r\nCo-authored-by:
Antonio
<[email protected]>","sha":"cc6ffef06c30134dafcd40946659d41a38f63d56"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Georgiana-Andreea Onoleață <[email protected]>
  • Loading branch information
kibanamachine and georgianaonoleata1904 authored Nov 8, 2024
1 parent 418281b commit beb7cfa
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { usePushToService } from '.';
import { noPushCasesPermissions, readCasesPermissions, TestProviders } from '../../common/mock';
import { usePostPushToService } from '../../containers/use_post_push_to_service';
import { actionLicenses } from '../../containers/mock';
import { CLOSED_CASE_PUSH_ERROR_ID } from './callout/types';
import { useGetActionLicense } from '../../containers/use_get_action_license';
import { getCaseConnectorsMockResponse } from '../../common/mock/connectors';
import { useRefreshCaseViewPage } from '../case_view/use_on_refresh_case_view_page';
Expand Down Expand Up @@ -182,27 +181,6 @@ describe('usePushToService', () => {
expect(result.current.hasErrorMessages).toBe(true);
});

it('Displays message when case is closed', async () => {
const { result } = renderHook<
React.PropsWithChildren<UsePushToService>,
ReturnUsePushToService
>(
() =>
usePushToService({
...defaultArgs,
caseStatus: CaseStatuses.closed,
}),
{
wrapper: ({ children }) => <TestProviders> {children}</TestProviders>,
}
);

const errorsMsg = result.current.errorsMsg;
expect(errorsMsg).toHaveLength(1);
expect(errorsMsg[0].id).toEqual(CLOSED_CASE_PUSH_ERROR_ID);
expect(result.current.hasErrorMessages).toBe(true);
});

it('should not call pushCaseToExternalService when the selected connector is none', async () => {
const { result } = renderHook<
React.PropsWithChildren<UsePushToService>,
Expand Down Expand Up @@ -460,7 +438,7 @@ describe('usePushToService', () => {
const { result } = renderHook<
React.PropsWithChildren<UsePushToService>,
ReturnUsePushToService
>(() => usePushToService({ ...defaultArgs, caseStatus: CaseStatuses.closed }), {
>(() => usePushToService({ ...defaultArgs, isValidConnector: false }), {
wrapper: ({ children }) => <TestProviders> {children}</TestProviders>,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import {
getKibanaConfigError,
getConnectorMissingInfo,
getDeletedConnectorError,
getCaseClosedInfo,
} from './helpers';
import type { CaseConnector } from '../../../common/types/domain';
import { CaseStatuses } from '../../../common/types/domain';
import type { ErrorMessage } from './callout/types';
import { useRefreshCaseViewPage } from '../case_view/use_on_refresh_case_view_page';
import { useGetActionLicense } from '../../containers/use_get_action_license';
Expand Down Expand Up @@ -44,7 +42,6 @@ export interface ReturnUsePushToService {

export const usePushToService = ({
caseId,
caseStatus,
caseConnectors,
connector,
isValidConnector,
Expand Down Expand Up @@ -108,14 +105,9 @@ export const usePushToService = ({
return [getDeletedConnectorError()];
}

if (caseStatus === CaseStatuses.closed) {
return [getCaseClosedInfo()];
}

return errors;
}, [
actionLicense,
caseStatus,
connector.id,
hasLicenseError,
isValidConnector,
Expand Down
6 changes: 0 additions & 6 deletions x-pack/plugins/cases/server/client/cases/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ export const push = async (
operation: Operations.pushCase,
});

if (theCase?.status === CaseStatuses.closed) {
throw Boom.conflict(
`The ${theCase.title} case is closed. Pushing a closed case is not allowed.`
);
}

const alertsInfo = getAlertInfoFromComments(theCase?.comments);
const alerts = await getAlerts(alertsInfo, clientArgs);
const profiles = await getProfiles(theCase, securityStartPlugin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ export default ({ getService }: FtrProviderContext): void => {
});
});

it('unhappy path = 409s when case is closed', async () => {
it('should push a closed case', async () => {
const { postedCase, connector } = await createCaseWithConnector({
supertest,
serviceNowSimulatorURL,
Expand All @@ -511,7 +511,7 @@ export default ({ getService }: FtrProviderContext): void => {
supertest,
caseId: postedCase.id,
connectorId: connector.id,
expectedHttpCode: 409,
expectedHttpCode: 200,
});
});

Expand Down

0 comments on commit beb7cfa

Please sign in to comment.