-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SIEM] [Cases] External service selection per case #64775
Changes from all commits
74534fa
ab037ff
f803e30
6cc292c
f34c722
7fd93b2
ba3976c
8823b2d
7352699
85414df
9fcdc45
ea7390f
1ff3926
c6355d3
c8b6ff8
7747c54
8e092ec
f6ba967
b523948
03aca05
7f4fe94
b0ed184
0870ec4
18e1503
09c7cbf
6099f46
366b3ad
9c30d90
7607a8e
fc0183e
4a03422
6b58e7d
99fa0fb
bc8f155
a650476
fa4a3cf
576fc86
b4eba97
17e9f13
29230bb
92b1d00
3a954a1
5d2d2bc
bf31cf3
e224b59
e175cb6
b6a1641
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ export const mockCases: Array<SavedObject<CaseAttributes>> = [ | |
attributes: { | ||
closed_at: null, | ||
closed_by: null, | ||
connector_id: 'none', | ||
created_at: '2019-11-25T21:54:48.952Z', | ||
created_by: { | ||
full_name: 'elastic', | ||
|
@@ -46,6 +47,7 @@ export const mockCases: Array<SavedObject<CaseAttributes>> = [ | |
attributes: { | ||
closed_at: null, | ||
closed_by: null, | ||
connector_id: 'none', | ||
created_at: '2019-11-25T22:32:00.900Z', | ||
created_by: { | ||
full_name: 'elastic', | ||
|
@@ -74,6 +76,7 @@ export const mockCases: Array<SavedObject<CaseAttributes>> = [ | |
attributes: { | ||
closed_at: null, | ||
closed_by: null, | ||
connector_id: '123', | ||
created_at: '2019-11-25T22:32:17.947Z', | ||
created_by: { | ||
full_name: 'elastic', | ||
|
@@ -106,6 +109,7 @@ export const mockCases: Array<SavedObject<CaseAttributes>> = [ | |
email: '[email protected]', | ||
username: 'elastic', | ||
}, | ||
connector_id: '123', | ||
created_at: '2019-11-25T22:32:17.947Z', | ||
created_by: { | ||
full_name: 'elastic', | ||
|
@@ -130,6 +134,35 @@ export const mockCases: Array<SavedObject<CaseAttributes>> = [ | |
}, | ||
]; | ||
|
||
export const mockCaseNoConnectorId: SavedObject<Partial<CaseAttributes>> = { | ||
type: 'cases', | ||
id: 'mock-no-connector_id', | ||
attributes: { | ||
closed_at: null, | ||
closed_by: null, | ||
created_at: '2019-11-25T21:54:48.952Z', | ||
created_by: { | ||
full_name: 'elastic', | ||
email: '[email protected]', | ||
username: 'elastic', | ||
}, | ||
description: 'This is a brand new case of a bad meanie defacing data', | ||
external_service: null, | ||
title: 'Super Bad Security Issue', | ||
status: 'open', | ||
tags: ['defacement'], | ||
updated_at: '2019-11-25T21:54:48.952Z', | ||
updated_by: { | ||
full_name: 'elastic', | ||
email: '[email protected]', | ||
username: 'elastic', | ||
}, | ||
}, | ||
references: [], | ||
updated_at: '2019-11-25T21:54:48.952Z', | ||
version: 'WzAsMV0=', | ||
}; | ||
|
||
export const mockCasesErrorTriggerData = [ | ||
{ | ||
id: 'valid-id', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,9 @@ import { | |
} from '../__fixtures__'; | ||
import { initFindCasesApi } from './find_cases'; | ||
import { CASES_URL } from '../../../../common/constants'; | ||
import { mockCaseConfigure, mockCaseNoConnectorId } from '../__fixtures__/mock_saved_objects'; | ||
|
||
describe('GET all cases', () => { | ||
describe('FIND all cases', () => { | ||
let routeHandler: RequestHandler<any, any, any>; | ||
beforeAll(async () => { | ||
routeHandler = await createRoute(initFindCasesApi, 'get'); | ||
|
@@ -37,4 +38,53 @@ describe('GET all cases', () => { | |
expect(response.status).toEqual(200); | ||
expect(response.payload.cases).toHaveLength(4); | ||
}); | ||
it(`has proper connector id on cases with configured id`, async () => { | ||
const request = httpServerMock.createKibanaRequest({ | ||
path: `${CASES_URL}/_find`, | ||
method: 'get', | ||
}); | ||
|
||
const theContext = createRouteContext( | ||
createMockSavedObjectsRepository({ | ||
caseSavedObject: mockCases, | ||
}) | ||
); | ||
|
||
const response = await routeHandler(theContext, request, kibanaResponseFactory); | ||
expect(response.status).toEqual(200); | ||
expect(response.payload.cases[2].connector_id).toEqual('123'); | ||
}); | ||
it(`adds 'none' connector id to cases without when 3rd party unconfigured`, async () => { | ||
const request = httpServerMock.createKibanaRequest({ | ||
path: `${CASES_URL}/_find`, | ||
method: 'get', | ||
}); | ||
|
||
const theContext = createRouteContext( | ||
createMockSavedObjectsRepository({ | ||
caseSavedObject: [mockCaseNoConnectorId], | ||
}) | ||
); | ||
|
||
const response = await routeHandler(theContext, request, kibanaResponseFactory); | ||
expect(response.status).toEqual(200); | ||
expect(response.payload.cases[0].connector_id).toEqual('none'); | ||
}); | ||
it(`adds default connector id to cases without when 3rd party configured`, async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit -> we can get one more test to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I will apply to all the tests that applied if you agree There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the test should female sure we get the connector_id because the future is female |
||
const request = httpServerMock.createKibanaRequest({ | ||
path: `${CASES_URL}/_find`, | ||
method: 'get', | ||
}); | ||
|
||
const theContext = createRouteContext( | ||
createMockSavedObjectsRepository({ | ||
caseSavedObject: [mockCaseNoConnectorId], | ||
caseConfigureSavedObject: mockCaseConfigure, | ||
}) | ||
); | ||
|
||
const response = await routeHandler(theContext, request, kibanaResponseFactory); | ||
expect(response.status).toEqual(200); | ||
expect(response.payload.cases[0].connector_id).toEqual('123'); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit -> I think is better to describe the action as
connector
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we are really updating the connector_id field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd like to leave it. its updating the field
connector_id
, there is no fieldconnector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! I am not against it. For the sake of argument this is a verb that describes an action, not a field. So the user creates a comment, updates the description, updates the connector etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, maybe I did not do that correctly but the goal here was to be a field ;)