Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cases] Case action: Handle closed cases #172709

Merged
merged 70 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
0e1bfb0
Register the case action
cnasikas Oct 9, 2023
4777f9c
Register the cases oracle
cnasikas Oct 9, 2023
65a88fa
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Oct 9, 2023
eeb35a6
Calculate the hash of the record ID
cnasikas Oct 9, 2023
649dea9
Merge branch 'register_case_action' of github.com:cnasikas/kibana int…
cnasikas Oct 10, 2023
4491476
Get oracle record
cnasikas Oct 10, 2023
f4a81a1
Rename folder
cnasikas Oct 11, 2023
5822d73
Sort grouping definition
cnasikas Oct 11, 2023
df77537
Increase counter
cnasikas Oct 11, 2023
9955239
Change grouping to record
cnasikas Oct 12, 2023
58bc3d6
Make the rule ID optional in the key
cnasikas Oct 12, 2023
581819a
Better types
cnasikas Oct 13, 2023
449a1b7
Add version when updating
cnasikas Oct 13, 2023
c210a0c
Improve types
cnasikas Oct 13, 2023
c802637
Fix tests
cnasikas Oct 13, 2023
b249032
Merge branch 'case_action' into register_case_action
cnasikas Oct 16, 2023
c120c97
Add model version and improve mapping
cnasikas Oct 16, 2023
043a9fe
Fix tests
cnasikas Oct 16, 2023
a9db13f
Fix mapping test
cnasikas Oct 16, 2023
32af9e3
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Oct 16, 2023
90acabf
Merge branch 'case_action' into register_case_action
cnasikas Oct 18, 2023
b7605b7
Merge branch 'register_case_action' of github.com:cnasikas/kibana int…
cnasikas Oct 18, 2023
7b27008
Define connector params initial schema
cnasikas Oct 17, 2023
13fd013
Bulk get records
cnasikas Oct 17, 2023
69a8778
Group alerts and bulk get oracle records
cnasikas Oct 17, 2023
e5c73a3
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 18, 2023
1ba6117
Bulk create records
cnasikas Oct 18, 2023
bf8a32d
Merge branch 'ca_part_2' of github.com:cnasikas/kibana into ca_part_2
cnasikas Oct 18, 2023
c6982a5
Add TODOs
cnasikas Oct 19, 2023
f184a08
Move bulkGetOrCreateOracleRecords logic to the connector
cnasikas Oct 20, 2023
40f865e
Generate case ids
cnasikas Oct 20, 2023
f70bf1e
Get service with a factory
cnasikas Oct 21, 2023
04805ac
Fix docs
cnasikas Oct 21, 2023
a3d47e6
Merge branch 'main' into saf_get_instance
cnasikas Oct 21, 2023
3988644
Merge branch 'saf_get_instance' into ca_part_2
cnasikas Oct 21, 2023
af1b8ae
Pass the cases client to the case connector
cnasikas Oct 21, 2023
4c6f5ae
Attach alerts to a case
cnasikas Oct 23, 2023
a7f1ba1
Merge branch 'case_action' into register_case_action
cnasikas Oct 23, 2023
a283b93
Merge branch 'register_case_action' into ca_part_2
cnasikas Oct 23, 2023
8fd2a84
Merge branch 'case_action' into ca_part_2
cnasikas Nov 8, 2023
13012eb
Merge branch 'case_action' into ca_part_2
cnasikas Nov 8, 2023
c8e82e5
Bulk create non existing cases
cnasikas Nov 8, 2023
1ead049
Improve the case request
cnasikas Nov 10, 2023
b31c167
Small improvements
cnasikas Nov 10, 2023
2621c7d
Add time window to schema
cnasikas Nov 10, 2023
ab42f16
Merge branch 'case_action' into ca_time_window
cnasikas Nov 15, 2023
ad14c3f
Merge branch 'case_action' into ca_time_window
cnasikas Nov 22, 2023
5d340aa
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 22, 2023
b20ef53
Upsert oracle records
cnasikas Nov 23, 2023
b3806ef
Increase the counter when the time window has passed
cnasikas Nov 29, 2023
27209ac
Merge branch 'case_action' into ca_time_window
cnasikas Nov 29, 2023
346735b
Merge branch 'ca_time_window' of github.com:cnasikas/kibana into ca_t…
cnasikas Nov 29, 2023
7e5989e
Add more tests
cnasikas Nov 29, 2023
2a44c29
Add reopenClosedCases to params
cnasikas Dec 1, 2023
0c0d572
Rename cases client method
cnasikas Dec 1, 2023
432a4dc
Reopen closed cases
cnasikas Dec 1, 2023
e5ed0dd
Fix issue with concat
cnasikas Dec 4, 2023
70f153d
Merge branch 'case_action' into ca_reopen_cases
cnasikas Dec 6, 2023
1c9fd6f
Open new cases when the cases are closed
cnasikas Dec 6, 2023
a24f562
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Dec 6, 2023
48f107c
Add more tests about the time window validation
cnasikas Dec 7, 2023
e545acf
Move handling the time window outside of upserting oracle records
cnasikas Dec 7, 2023
9eca674
Merge branch 'ca_reopen_cases' of github.com:cnasikas/kibana into ca_…
cnasikas Dec 7, 2023
b5fecef
Merge branch 'case_action' into ca_time_window
cnasikas Dec 8, 2023
81ab220
Fix bug with Regex
cnasikas Dec 8, 2023
003c285
Merge branch 'ca_time_window' into ca_reopen_cases
cnasikas Dec 8, 2023
1a6636a
Merge branch 'case_action' into ca_reopen_cases
cnasikas Dec 8, 2023
8148339
Merge branch 'case_action' into ca_reopen_cases
cnasikas Dec 20, 2023
db6ede3
PR feedback
cnasikas Dec 20, 2023
7e8d801
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Dec 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
306 changes: 251 additions & 55 deletions packages/kbn-check-mappings-update-cli/current_fields.json
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier messed up with the file. This PR will merged into a feature branch.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '../../../common/constants';
import { mockCases } from '../../mocks';
import { createCasesClientMock, createCasesClientMockArgs } from '../mocks';
import { update } from './update';
import { bulkUpdate } from './bulk_update';

describe('update', () => {
const cases = {
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('update', () => {
});

it('notifies an assignee', async () => {
await update(cases, clientArgs, casesClientMock);
await bulkUpdate(cases, clientArgs, casesClientMock);

expect(clientArgs.services.notificationService.bulkNotifyAssignees).toHaveBeenCalledWith([
{
Expand All @@ -72,7 +72,7 @@ describe('update', () => {
expect.assertions(2);

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('update', () => {
],
});

await expect(update(cases, clientArgs, casesClientMock)).rejects.toThrow(
await expect(bulkUpdate(cases, clientArgs, casesClientMock)).rejects.toThrow(
'Failed to update case, ids: [{"id":"mock-id-1","version":"WzAsMV0="}]: Error: All update fields are identical to current version.'
);

Expand All @@ -130,7 +130,7 @@ describe('update', () => {
],
});

await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('update', () => {
saved_objects: [{ ...mockCases[0], attributes: { assignees: [{ uid: '1' }] } }],
});

await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('update', () => {
],
});

await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('update', () => {
],
});

await update(
await bulkUpdate(
{
cases: [
{
Expand All @@ -273,7 +273,7 @@ describe('update', () => {

it('should throw an error when an invalid field is included in the request payload', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -297,7 +297,7 @@ describe('update', () => {
const assignees = Array(MAX_ASSIGNEES_PER_CASE + 1).fill({ uid: 'foo' });

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -337,7 +337,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -355,7 +355,7 @@ describe('update', () => {

it('does not update the category if the length is too long', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -375,7 +375,7 @@ describe('update', () => {

it('throws error if category is just an empty string', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -395,7 +395,7 @@ describe('update', () => {

it('throws error if category is a string with empty characters', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -414,7 +414,7 @@ describe('update', () => {
});

it('should trim category', async () => {
await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -471,7 +471,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -489,7 +489,7 @@ describe('update', () => {

it('throws error if the title is too long', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -510,7 +510,7 @@ describe('update', () => {

it('throws error if title is just an empty string', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -530,7 +530,7 @@ describe('update', () => {

it('throws error if title is a string with empty characters', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -549,7 +549,7 @@ describe('update', () => {
});

it('should trim title', async () => {
await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -606,7 +606,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -628,7 +628,7 @@ describe('update', () => {
.toString();

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -648,7 +648,7 @@ describe('update', () => {

it('throws error if description is just an empty string', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -668,7 +668,7 @@ describe('update', () => {

it('throws error if description is a string with empty characters', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -687,7 +687,7 @@ describe('update', () => {
});

it('should trim description', async () => {
await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -888,7 +888,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -910,7 +910,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -930,7 +930,7 @@ describe('update', () => {
const tags = Array(MAX_TAGS_PER_CASE + 1).fill('foo');

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -954,7 +954,7 @@ describe('update', () => {
.toString();

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -974,7 +974,7 @@ describe('update', () => {

it('throws error if tag is empty string', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -994,7 +994,7 @@ describe('update', () => {

it('throws error if tag is a string with empty characters', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -1013,7 +1013,7 @@ describe('update', () => {
});

it('should trim tags', async () => {
await update(
await bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1104,7 +1104,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1154,7 +1154,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1205,7 +1205,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -1225,7 +1225,7 @@ describe('update', () => {

it('throws with duplicated customFields keys', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1256,7 +1256,7 @@ describe('update', () => {

it('throws when customFields keys are not present in configuration', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1287,7 +1287,7 @@ describe('update', () => {

it('throws error when custom fields are missing', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand All @@ -1313,7 +1313,7 @@ describe('update', () => {

it('throws when the customField types dont match the configuration', async () => {
await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1355,7 +1355,7 @@ describe('update', () => {

it(`throws an error when trying to update more than ${MAX_CASES_TO_UPDATE} cases`, async () => {
await expect(
update(
bulkUpdate(
{
cases: Array(MAX_CASES_TO_UPDATE + 1).fill({
id: mockCases[0].id,
Expand All @@ -1373,7 +1373,7 @@ describe('update', () => {

it('throws an error when trying to update zero cases', async () => {
await expect(
update(
bulkUpdate(
{
cases: [],
},
Expand Down Expand Up @@ -1416,7 +1416,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1445,7 +1445,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down Expand Up @@ -1478,7 +1478,7 @@ describe('update', () => {
});

await expect(
update(
bulkUpdate(
{
cases: [
{
Expand Down
Loading
Loading