[ResponseOps][Cases]Allow users to push to external service when the case is closed (#198146)

Closes https://github.com/elastic/kibana/issues/192552

## Summary

- Removed the restriction that didn't allow user to push a closed case
to an external service.


https://github.com/user-attachments/assets/82c49524-5685-40c0-b025-d6b38ab4e056

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Antonio <antonio.coelho@elastic.co>
This commit is contained in:
Georgiana-Andreea Onoleață 2024-11-08 11:32:11 +02:00 committed by GitHub
parent 2ba6560d0d
commit cc6ffef06c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 3 additions and 39 deletions

View file

@ -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';
@ -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>,
@ -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>,
});

View file

@ -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';
@ -44,7 +42,6 @@ export interface ReturnUsePushToService {
export const usePushToService = ({
caseId,
caseStatus,
caseConnectors,
connector,
isValidConnector,
@ -108,14 +105,9 @@ export const usePushToService = ({
return [getDeletedConnectorError()];
}
if (caseStatus === CaseStatuses.closed) {
return [getCaseClosedInfo()];
}
return errors;
}, [
actionLicense,
caseStatus,
connector.id,
hasLicenseError,
isValidConnector,

View file

@ -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);

View file

@ -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,
@ -511,7 +511,7 @@ export default ({ getService }: FtrProviderContext): void => {
supertest,
caseId: postedCase.id,
connectorId: connector.id,
expectedHttpCode: 409,
expectedHttpCode: 200,
});
});