Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Mar 18, 2020
1 parent 9e80e46 commit 237d7f8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const getExportTimelinesRequest = () =>
method: 'get',
path: TIMELINE_EXPORT_URL,
body: {
objects: ['f0e58720-57b6-11ea-b88d-3f1a31716be8', '890b8ae0-57df-11ea-a7c9-3976b7f1cb37'],
ids: ['f0e58720-57b6-11ea-b88d-3f1a31716be8', '890b8ae0-57df-11ea-a7c9-3976b7f1cb37'],
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('export timelines', () => {
const request = requestMock.create({
method: 'get',
path: TIMELINE_EXPORT_URL,
body: { id: ['someId'] },
body: { id: 'someId' },
});
const result = server.validate(request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const exportTimelinesRoute = (router: IRouter, config: LegacyServices['co
const siemResponse = buildSiemResponse(response);
const savedObjectsClient = context.core.savedObjects.client;
const exportSizeLimit = config().get<number>('savedObjects.maxImportExportSize');
if (request.body?.objects != null && request.body.objects.length > exportSizeLimit) {
if (request.body?.ids != null && request.body.ids.length > exportSizeLimit) {
return siemResponse.error({
statusCode: 400,
body: `Can't export more than ${exportSizeLimit} timelines`,
Expand Down
13 changes: 5 additions & 8 deletions x-pack/legacy/plugins/siem/server/lib/timeline/routes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,18 @@ const getTimelinesFromObjects = async (
savedObjectsClient: ExportTimelineSavedObjectsClient,
request: ExportTimelineRequest
): Promise<ExportedTimelines[]> => {
const timelines: TimelineSavedObject[] = await getTimelines(
savedObjectsClient,
request.body.objects
);
const timelines: TimelineSavedObject[] = await getTimelines(savedObjectsClient, request.body.ids);
// To Do for feature freeze
// if (timelines.length !== request.body.objects.length) {
// if (timelines.length !== request.body.ids.length) {
// //figure out which is missing to tell user
// }

const [notes, pinnedEventIds] = await Promise.all([
Promise.all(
request.body.objects.map(timelineId => getNotesByTimelineId(savedObjectsClient, timelineId))
request.body.ids.map(timelineId => getNotesByTimelineId(savedObjectsClient, timelineId))
),
Promise.all(
request.body.objects.map(timelineId =>
request.body.ids.map(timelineId =>
getPinnedEventsByTimelineId(savedObjectsClient, timelineId)
)
),
Expand All @@ -157,7 +154,7 @@ const getTimelinesFromObjects = async (
[]
);

const myResponse = request.body.objects.reduce<ExportedTimelines[]>((acc, timelineId) => {
const myResponse = request.body.ids.reduce<ExportedTimelines[]>((acc, timelineId) => {
const myTimeline = timelines.find(t => t.savedObjectId === timelineId);
if (myTimeline != null) {
const timelineNotes = myNotes.filter(n => n.timelineId === timelineId);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/siem/server/lib/timeline/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export interface AllTimelineSavedObject
extends runtimeTypes.TypeOf<typeof AllTimelineSavedObjectRuntimeType> {}

export interface ExportTimelineRequestParams {
body: { objects: string[] };
body: { ids: string[] };
query: {
file_name: string;
exclude_export_details: boolean;
Expand Down

0 comments on commit 237d7f8

Please sign in to comment.