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

[Security Solutions][Case] Settings per case per connector #77327

Merged
merged 175 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from 137 commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
4d4eebd
Init registry
cnasikas Sep 14, 2020
0e11f14
Init setting registration
cnasikas Sep 14, 2020
926e06f
Create and use case settings context
cnasikas Sep 14, 2020
587b70e
Create jira settings
cnasikas Sep 15, 2020
c9a310d
Convert from context to hook
cnasikas Sep 15, 2020
5527613
Fields at the creation page
cnasikas Sep 15, 2020
b5f9db3
Add fields to cases savedObject
cnasikas Sep 16, 2020
3b078ce
Improve types
cnasikas Sep 17, 2020
4da7da2
Change configuration savedObject
cnasikas Sep 17, 2020
a95e56d
Change connector definition
cnasikas Sep 17, 2020
265bf64
Move helpers to utils
cnasikas Sep 18, 2020
fa34784
Improve configuration types
cnasikas Sep 18, 2020
3f9a41d
Create cases with fields
cnasikas Sep 18, 2020
865c14e
Improve urls
cnasikas Sep 18, 2020
78656e4
Connectors at case view page
cnasikas Sep 18, 2020
3aa378f
Settings on case view page
cnasikas Sep 18, 2020
4067125
Create resilient settings
cnasikas Sep 18, 2020
1496183
Register servicenow
cnasikas Sep 21, 2020
2d391fc
Improve creation page
cnasikas Sep 22, 2020
f30141f
Refactor user actions to support fields
cnasikas Sep 22, 2020
f7db047
Push to services
cnasikas Sep 23, 2020
1b22c2e
Convert fields to array in ES
cnasikas Sep 24, 2020
0cd0bf8
Push all fields for cases
cnasikas Sep 24, 2020
bab41d5
Fix types
cnasikas Sep 24, 2020
78d698d
Init registry
cnasikas Sep 14, 2020
eeab1a0
Init setting registration
cnasikas Sep 14, 2020
1ce6dad
Create and use case settings context
cnasikas Sep 14, 2020
175ae43
Create jira settings
cnasikas Sep 15, 2020
f772e78
Convert from context to hook
cnasikas Sep 15, 2020
7c8ce98
Fields at the creation page
cnasikas Sep 15, 2020
5108e2a
Add fields to cases savedObject
cnasikas Sep 16, 2020
319c6b4
Improve types
cnasikas Sep 17, 2020
ed4553d
Change configuration savedObject
cnasikas Sep 17, 2020
09bb006
Change connector definition
cnasikas Sep 17, 2020
f9dcf37
Move helpers to utils
cnasikas Sep 18, 2020
07abeba
Improve configuration types
cnasikas Sep 18, 2020
66ee5e5
Create cases with fields
cnasikas Sep 18, 2020
a666c3c
Improve urls
cnasikas Sep 18, 2020
bfc5d14
Connectors at case view page
cnasikas Sep 18, 2020
759c516
Settings on case view page
cnasikas Sep 18, 2020
5aac3ab
Create resilient settings
cnasikas Sep 18, 2020
350688e
Register servicenow
cnasikas Sep 21, 2020
c0f149a
Improve creation page
cnasikas Sep 22, 2020
56bc9bd
Refactor user actions to support fields
cnasikas Sep 22, 2020
994c92f
Push to services
cnasikas Sep 23, 2020
eb0c328
Convert fields to array in ES
cnasikas Sep 24, 2020
6754469
Push all fields for cases
cnasikas Sep 24, 2020
9b83809
Fix types
cnasikas Sep 24, 2020
0fd87a5
Edit connector with pencil
cnasikas Sep 24, 2020
dad5ef1
[Backend] Fix and improve tests
cnasikas Sep 28, 2020
30401ef
Reset fields when changing connector
cnasikas Sep 28, 2020
50e4efe
Set default severity code
cnasikas Sep 28, 2020
f169223
Add end to end migration tests
cnasikas Sep 28, 2020
3307588
Add fields to connector configuration
cnasikas Sep 28, 2020
059a78e
Show connector name from connectors if not presented
cnasikas Sep 28, 2020
0ab7dfa
SO improvements
cnasikas Sep 28, 2020
0cf155b
Do not default fields
cnasikas Sep 28, 2020
1572a78
Show pushe button and arrows when changing fields
cnasikas Sep 28, 2020
99fd713
add strict type for fields
XavierM Sep 28, 2020
f66b506
Merge branch 'cases_settings' of github.com:cnasikas/kibana into case…
XavierM Sep 28, 2020
56fb71e
Init registry
cnasikas Sep 14, 2020
edad928
Init setting registration
cnasikas Sep 14, 2020
14a637a
Create and use case settings context
cnasikas Sep 14, 2020
76260b6
Create jira settings
cnasikas Sep 15, 2020
6f6f83d
Convert from context to hook
cnasikas Sep 15, 2020
79a91bb
Fields at the creation page
cnasikas Sep 15, 2020
afb41b5
Add fields to cases savedObject
cnasikas Sep 16, 2020
c0a8eeb
Improve types
cnasikas Sep 17, 2020
a58bbc6
Change configuration savedObject
cnasikas Sep 17, 2020
5e74032
Change connector definition
cnasikas Sep 17, 2020
6133749
Move helpers to utils
cnasikas Sep 18, 2020
edbcdaa
Improve configuration types
cnasikas Sep 18, 2020
20c6538
Create cases with fields
cnasikas Sep 18, 2020
3610818
Improve urls
cnasikas Sep 18, 2020
69ab96b
Connectors at case view page
cnasikas Sep 18, 2020
d162548
Settings on case view page
cnasikas Sep 18, 2020
22f1b3b
Create resilient settings
cnasikas Sep 18, 2020
c759baa
Register servicenow
cnasikas Sep 21, 2020
1481f66
Improve creation page
cnasikas Sep 22, 2020
423f46d
Refactor user actions to support fields
cnasikas Sep 22, 2020
ac4c549
Push to services
cnasikas Sep 23, 2020
ac1c6cb
Convert fields to array in ES
cnasikas Sep 24, 2020
59f2c55
Push all fields for cases
cnasikas Sep 24, 2020
d151ee1
Fix types
cnasikas Sep 24, 2020
e953780
Edit connector with pencil
cnasikas Sep 24, 2020
95d300c
[Backend] Fix and improve tests
cnasikas Sep 28, 2020
15e8b5f
Reset fields when changing connector
cnasikas Sep 28, 2020
a56eca2
Set default severity code
cnasikas Sep 28, 2020
9b3aae4
Add end to end migration tests
cnasikas Sep 28, 2020
0259a3d
Add fields to connector configuration
cnasikas Sep 28, 2020
84bd846
Show connector name from connectors if not presented
cnasikas Sep 28, 2020
7477586
SO improvements
cnasikas Sep 28, 2020
0826456
Do not default fields
cnasikas Sep 28, 2020
d455785
Show pushe button and arrows when changing fields
cnasikas Sep 28, 2020
779fd8c
Merge branch 'master' into cases_settings
stephmilovic Sep 28, 2020
7393ad1
type redos
stephmilovic Sep 29, 2020
e0fbe3b
Fix connector to tests
cnasikas Sep 29, 2020
2dcc0a8
even better types
stephmilovic Sep 29, 2020
28d42a1
Merge branch 'cases_settings' of github.com:cnasikas/kibana into case…
stephmilovic Sep 29, 2020
e36c070
stricter and stricter
stephmilovic Sep 29, 2020
202cfda
calling it a day
stephmilovic Sep 29, 2020
45dcce4
Fix servicenow type
cnasikas Sep 30, 2020
739af31
Improve connector types
cnasikas Sep 30, 2020
d2d56d2
Improve types
cnasikas Sep 30, 2020
137cfbd
Improve configuration tests
cnasikas Sep 30, 2020
bc7be04
fix types
XavierM Sep 30, 2020
9d8913c
Add tests for settings
cnasikas Sep 30, 2020
a7be67e
fix case view tests
stephmilovic Sep 30, 2020
ecfa63e
Merge branch 'cases_settings' of github.com:cnasikas/kibana into case…
stephmilovic Sep 30, 2020
f62408e
jest fixing
stephmilovic Sep 30, 2020
8a12e84
fixed case tests
stephmilovic Sep 30, 2020
b2765af
Merge branch 'master' into cases_settings
cnasikas Oct 1, 2020
62af60c
Add sub-task parent
cnasikas Oct 1, 2020
603e01f
Migrate fields to null
cnasikas Oct 1, 2020
d1d6346
Migrate user actions
cnasikas Oct 1, 2020
ac40065
Set empty fields to null
cnasikas Oct 1, 2020
4d5c0ba
Merge branch 'master' into cases_settings
cnasikas Oct 1, 2020
57a2a17
Improve migrations
cnasikas Oct 1, 2020
ce523a8
Add jira api test
cnasikas Oct 1, 2020
b2ba3c5
Fix integration tests
cnasikas Oct 1, 2020
f5ce05e
create tests
stephmilovic Oct 1, 2020
5e80f53
Merge branch 'cases_settings' of github.com:cnasikas/kibana into case…
stephmilovic Oct 1, 2020
f89c8fd
Improve user actions integration tests
cnasikas Oct 1, 2020
892427f
Fix types
cnasikas Oct 1, 2020
d848336
need to fix
stephmilovic Oct 1, 2020
8185eac
bug fixing
stephmilovic Oct 2, 2020
4894d14
resolve conflicts
stephmilovic Oct 2, 2020
5daa339
still more fix
stephmilovic Oct 2, 2020
564ee35
Fix configuration page header
cnasikas Oct 2, 2020
fad4d06
Improve showing fields on case view page
cnasikas Oct 2, 2020
8925049
Fix types
cnasikas Oct 2, 2020
0da48b3
Fix tests
cnasikas Oct 2, 2020
ac812d7
Fix translations
cnasikas Oct 2, 2020
735bade
Fix actions integration tests
cnasikas Oct 2, 2020
c531304
Fix types
cnasikas Oct 2, 2020
f1193c4
Fix actions integration test
cnasikas Oct 2, 2020
64f5f31
Fix bug with configuration
cnasikas Oct 2, 2020
bdae660
Fix cases api tests
cnasikas Oct 2, 2020
dc546f7
dynamic/static fix
stephmilovic Oct 2, 2020
528d9e0
static/dynamic fields
stephmilovic Oct 2, 2020
8a10c4e
Merge branch 'cases_settings' of github.com:cnasikas/kibana into case…
stephmilovic Oct 2, 2020
1a13aff
rm unused file
stephmilovic Oct 2, 2020
e7e7668
rm useEffect from edit_connector and jira/fields
stephmilovic Oct 3, 2020
eea1e06
Fix test
cnasikas Oct 5, 2020
3997500
Fix utils test
cnasikas Oct 5, 2020
363d433
Fix skipped test
cnasikas Oct 5, 2020
d422356
Remove useEffects from resilient
cnasikas Oct 5, 2020
0936b4e
Display spinner when loading fields
cnasikas Oct 5, 2020
cd8f855
Merge branch 'master' into cases_settings
kibanamachine Oct 5, 2020
149cba9
pair review with christos on BE
XavierM Oct 5, 2020
ea60187
Show no connector label
cnasikas Oct 5, 2020
10b168f
remove more useEffect
stephmilovic Oct 5, 2020
9e73d96
Merge branch 'cases_settings' of github.com:cnasikas/kibana into case…
stephmilovic Oct 5, 2020
082f728
rename bleepblorp
stephmilovic Oct 5, 2020
7b2bc7f
Fix patch configure integration test
cnasikas Oct 5, 2020
9382261
one more fix
stephmilovic Oct 5, 2020
e45392e
Merge branch 'cases_settings' of github.com:cnasikas/kibana into case…
stephmilovic Oct 5, 2020
4dfb5d3
fix
stephmilovic Oct 5, 2020
f31e0a2
Fix patch configure unit test
cnasikas Oct 5, 2020
fdf1066
fix conflict
stephmilovic Oct 5, 2020
f0aafba
Merge branch 'cases_settings' of github.com:cnasikas/kibana into case…
cnasikas Oct 5, 2020
a7ef2e4
one more fix
stephmilovic Oct 5, 2020
ce900a1
Merge branch 'cases_settings' of github.com:cnasikas/kibana into case…
stephmilovic Oct 5, 2020
e56b354
fix tests
stephmilovic Oct 5, 2020
11520b7
Merge branch 'master' into cases_settings
cnasikas Oct 5, 2020
5865db1
fix jira fields bug
stephmilovic Oct 5, 2020
8ffeec8
Merge branch 'cases_settings' of github.com:cnasikas/kibana into case…
stephmilovic Oct 5, 2020
4262a0f
fixing usememo to usecallback
stephmilovic Oct 6, 2020
0e2ce36
Remove css
cnasikas Oct 6, 2020
6204df7
Improve settings structure
cnasikas Oct 6, 2020
e8c8f4e
Improve useGetIssueTypes test
cnasikas Oct 6, 2020
b87113d
Improvements
cnasikas Oct 6, 2020
d700222
Convert registry to class
cnasikas Oct 6, 2020
24bfbc6
pair review with christos fixing few bugs
XavierM Oct 6, 2020
ad024db
Pass fields to external service
cnasikas Oct 6, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ describe('api', () => {

expect(externalService.createIncident).toHaveBeenCalledWith({
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
description:
'Incident description (created at 2020-04-27T10:59:46.202Z by Elastic User)',
summary: 'Incident title (created at 2020-04-27T10:59:46.202Z by Elastic User)',
Expand Down Expand Up @@ -233,6 +237,10 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
description:
'Incident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
Expand Down Expand Up @@ -443,6 +451,10 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
description:
'description from jira \r\nIncident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
Expand Down Expand Up @@ -480,6 +492,10 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
description:
'description from jira \r\nIncident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
},
Expand Down Expand Up @@ -516,6 +532,10 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
summary:
'title from jira \r\nIncident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
description:
Expand Down Expand Up @@ -553,7 +573,12 @@ describe('api', () => {
});
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {},
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
},
});
});

Expand Down Expand Up @@ -587,6 +612,10 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
},
});
Expand Down Expand Up @@ -622,6 +651,10 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
description:
'Incident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
Expand Down Expand Up @@ -659,6 +692,10 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
description:
'Incident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
},
Expand Down Expand Up @@ -695,6 +732,10 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
summary:
'title from jira \r\nIncident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
description:
Expand Down Expand Up @@ -733,6 +774,10 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
labels: ['kibana', 'elastic'],
priority: 'High',
issueType: '10006',
parent: null,
summary:
'title from jira \r\nIncident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
},
Expand Down
16 changes: 15 additions & 1 deletion x-pack/plugins/actions/server/builtin_action_types/jira/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,25 @@ const pushToServiceHandler = async ({
defaultPipes,
});

incident = transformFields<PushToServiceApiParams, ExternalServiceParams, Incident>({
const transformedFields = transformFields<
PushToServiceApiParams,
ExternalServiceParams,
Incident
>({
params,
fields,
currentIncident,
});

const { priority, labels, issueType, parent } = params;
incident = {
summary: transformedFields.summary,
description: transformedFields.description,
priority,
labels,
issueType,
parent,
};
} else {
const { title, description, priority, labels, issueType, parent } = params;
incident = { summary: title, description, priority, labels, issueType, parent };
Expand Down
34 changes: 24 additions & 10 deletions x-pack/plugins/actions/server/builtin_action_types/jira/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,21 @@ export const createExternalService = (
return fields;
};

const createErrorMessage = (errors: ResponseError) => {
const createErrorMessage = (errorResponse: ResponseError | null | undefined): string => {
if (errorResponse == null) {
return '';
}

const { errorMessages, errors } = errorResponse;

if (errors == null) {
return '';
}

if (Array.isArray(errorMessages) && errorMessages.length > 0) {
return `${errorMessages.join(', ')}`;
}

return Object.entries(errors).reduce((errorMessage, [, value]) => {
const msg = errorMessage.length > 0 ? `${errorMessage} ${value}` : value;
return msg;
Expand Down Expand Up @@ -154,7 +168,7 @@ export const createExternalService = (
i18n.NAME,
`Unable to get incident with id ${id}. Error: ${
error.message
} Reason: ${createErrorMessage(error.response?.data?.errors ?? {})}`
} Reason: ${createErrorMessage(error.response?.data)}`
)
);
}
Expand Down Expand Up @@ -207,7 +221,7 @@ export const createExternalService = (
getErrorMessage(
i18n.NAME,
`Unable to create incident. Error: ${error.message}. Reason: ${createErrorMessage(
error.response?.data?.errors ?? {}
error.response?.data
)}`
)
);
Expand Down Expand Up @@ -249,7 +263,7 @@ export const createExternalService = (
i18n.NAME,
`Unable to update incident with id ${incidentId}. Error: ${
error.message
}. Reason: ${createErrorMessage(error.response?.data?.errors ?? {})}`
}. Reason: ${createErrorMessage(error.response?.data)}`
)
);
}
Expand Down Expand Up @@ -280,7 +294,7 @@ export const createExternalService = (
i18n.NAME,
`Unable to create comment at incident with id ${incidentId}. Error: ${
error.message
}. Reason: ${createErrorMessage(error.response?.data?.errors ?? {})}`
}. Reason: ${createErrorMessage(error.response?.data)}`
)
);
}
Expand All @@ -302,7 +316,7 @@ export const createExternalService = (
getErrorMessage(
i18n.NAME,
`Unable to get capabilities. Error: ${error.message}. Reason: ${createErrorMessage(
error.response?.data?.errors ?? {}
error.response?.data
)}`
)
);
Expand Down Expand Up @@ -342,7 +356,7 @@ export const createExternalService = (
getErrorMessage(
i18n.NAME,
`Unable to get issue types. Error: ${error.message}. Reason: ${createErrorMessage(
error.response?.data?.errors ?? {}
error.response?.data
)}`
)
);
Expand Down Expand Up @@ -388,7 +402,7 @@ export const createExternalService = (
getErrorMessage(
i18n.NAME,
`Unable to get fields. Error: ${error.message}. Reason: ${createErrorMessage(
error.response?.data?.errors ?? {}
error.response?.data
)}`
)
);
Expand All @@ -415,7 +429,7 @@ export const createExternalService = (
getErrorMessage(
i18n.NAME,
`Unable to get issues. Error: ${error.message}. Reason: ${createErrorMessage(
error.response?.data?.errors ?? {}
error.response?.data
)}`
)
);
Expand All @@ -439,7 +453,7 @@ export const createExternalService = (
getErrorMessage(
i18n.NAME,
`Unable to get issue with id ${id}. Error: ${error.message}. Reason: ${createErrorMessage(
error.response?.data?.errors ?? {}
error.response?.data
)}`
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,6 @@ export interface Fields {
[key: string]: string | string[] | { name: string } | { key: string } | { id: string };
}
export interface ResponseError {
[k: string]: string;
errorMessages: string[] | null | undefined;
errors: { [k: string]: string } | null | undefined;
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ describe('api', () => {

expect(externalService.createIncident).toHaveBeenCalledWith({
incident: {
incidentTypes: [1001],
severityCode: 6,
description:
'Incident description (created at 2020-06-03T15:09:13.606Z by Elastic User)',
name: 'Incident title (created at 2020-06-03T15:09:13.606Z by Elastic User)',
Expand Down Expand Up @@ -175,6 +177,8 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
incidentTypes: [1001],
severityCode: 6,
description:
'Incident description (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
name: 'Incident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
Expand Down Expand Up @@ -298,6 +302,8 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
incidentTypes: [1001],
severityCode: 6,
name: 'Incident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
description:
'description from ibm resilient \r\nIncident description (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
Expand Down Expand Up @@ -335,6 +341,8 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
incidentTypes: [1001],
severityCode: 6,
description:
'description from ibm resilient \r\nIncident description (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
},
Expand Down Expand Up @@ -371,6 +379,8 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
incidentTypes: [1001],
severityCode: 6,
name:
'title from ibm resilient \r\nIncident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
description:
Expand Down Expand Up @@ -408,7 +418,10 @@ describe('api', () => {
});
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {},
incident: {
incidentTypes: [1001],
severityCode: 6,
},
});
});

Expand Down Expand Up @@ -442,6 +455,8 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
incidentTypes: [1001],
severityCode: 6,
name: 'Incident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
},
});
Expand Down Expand Up @@ -477,6 +492,8 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
incidentTypes: [1001],
severityCode: 6,
name: 'Incident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
description:
'Incident description (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
Expand Down Expand Up @@ -514,6 +531,8 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
incidentTypes: [1001],
severityCode: 6,
description:
'Incident description (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
},
Expand Down Expand Up @@ -550,6 +569,8 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
incidentTypes: [1001],
severityCode: 6,
name:
'title from ibm resilient \r\nIncident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
description:
Expand Down Expand Up @@ -588,6 +609,8 @@ describe('api', () => {
expect(externalService.updateIncident).toHaveBeenCalledWith({
incidentId: 'incident-3',
incident: {
incidentTypes: [1001],
severityCode: 6,
name:
'title from ibm resilient \r\nIncident title (updated at 2020-06-03T15:09:13.606Z by Elastic User)',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,23 @@ const pushToServiceHandler = async ({
defaultPipes,
});

incident = transformFields<PushToServiceApiParams, ExternalServiceParams, Incident>({
const transformedFields = transformFields<
PushToServiceApiParams,
ExternalServiceParams,
Incident
>({
params,
fields,
currentIncident,
});

const { incidentTypes, severityCode } = params;
incident = {
name: transformedFields.name,
description: transformedFields.description,
incidentTypes,
severityCode,
};
} else {
const { title, description, incidentTypes, severityCode } = params;
incident = { name: title, description, incidentTypes, severityCode };
Expand Down
Loading