forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.x] [Security Solution][Case] Attach alerts to cases: Tests (elasti…
…c#86305) (elastic#87860) Co-authored-by: Steph Milovic <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Steph Milovic <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
1969109
commit 68e367d
Showing
58 changed files
with
3,554 additions
and
586 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
x-pack/plugins/case/server/client/alerts/update_status.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CaseStatuses } from '../../../common/api'; | ||
import { createMockSavedObjectsRepository } from '../../routes/api/__fixtures__'; | ||
import { createCaseClientWithMockSavedObjectsClient } from '../mocks'; | ||
|
||
describe('updateAlertsStatus', () => { | ||
describe('happy path', () => { | ||
test('it update the status of the alert correctly', async () => { | ||
const savedObjectsClient = createMockSavedObjectsRepository(); | ||
|
||
const caseClient = await createCaseClientWithMockSavedObjectsClient({ savedObjectsClient }); | ||
await caseClient.client.updateAlertsStatus({ | ||
ids: ['alert-id-1'], | ||
status: CaseStatuses.closed, | ||
}); | ||
|
||
expect(caseClient.services.alertsService.updateAlertsStatus).toHaveBeenCalledWith({ | ||
ids: ['alert-id-1'], | ||
index: '.siem-signals', | ||
request: {}, | ||
status: CaseStatuses.closed, | ||
}); | ||
}); | ||
|
||
describe('unhappy path', () => { | ||
test('it throws when missing securitySolutionClient', async () => { | ||
expect.assertions(3); | ||
|
||
const savedObjectsClient = createMockSavedObjectsRepository(); | ||
|
||
const caseClient = await createCaseClientWithMockSavedObjectsClient({ | ||
savedObjectsClient, | ||
omitFromContext: ['securitySolution'], | ||
}); | ||
caseClient.client | ||
.updateAlertsStatus({ | ||
ids: ['alert-id-1'], | ||
status: CaseStatuses.closed, | ||
}) | ||
.catch((e) => { | ||
expect(e).not.toBeNull(); | ||
expect(e.isBoom).toBe(true); | ||
expect(e.output.statusCode).toBe(404); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.