-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Add tests for import / export timelines (#75537)
* add intergration test for install prebuilt timelines * add integration tests * add functional test for export timeline * clean up * asserts the content of the exported timeline * update selector * update selector * reuses the timeline id from the expected exported file Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Gloria Hornero <[email protected]>
- Loading branch information
1 parent
ec1c158
commit e7966e9
Showing
10 changed files
with
605 additions
and
4 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
x-pack/plugins/security_solution/cypress/integration/timelines_export.spec.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,41 @@ | ||
/* | ||
* 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 { exportTimeline, waitForTimelinesPanelToBeLoaded } from '../tasks/timeline'; | ||
import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver'; | ||
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; | ||
|
||
import { TIMELINES_URL } from '../urls/navigation'; | ||
|
||
const EXPECTED_EXPORTED_TIMELINE_PATH = 'cypress/test_files/expected_timelines_export.ndjson'; | ||
|
||
describe('Export timelines', () => { | ||
before(() => { | ||
esArchiverLoad('timeline'); | ||
cy.server(); | ||
cy.route('POST', '**api/timeline/_export?file_name=timelines_export.ndjson*').as('export'); | ||
}); | ||
|
||
after(() => { | ||
esArchiverUnload('timeline'); | ||
}); | ||
|
||
it('Exports a custom timeline', () => { | ||
loginAndWaitForPageWithoutDateRange(TIMELINES_URL); | ||
waitForTimelinesPanelToBeLoaded(); | ||
|
||
cy.readFile(EXPECTED_EXPORTED_TIMELINE_PATH).then(($expectedExportedJson) => { | ||
const parsedJson = JSON.parse($expectedExportedJson); | ||
const timelineId = parsedJson.savedObjectId; | ||
exportTimeline(timelineId); | ||
|
||
cy.wait('@export').then((response) => { | ||
cy.wrap(response.status).should('eql', 200); | ||
cy.wrap(response.xhr.responseText).should('eql', $expectedExportedJson); | ||
}); | ||
}); | ||
}); | ||
}); |
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
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
1 change: 1 addition & 0 deletions
1
x-pack/plugins/security_solution/cypress/test_files/expected_timelines_export.ndjson
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 @@ | ||
{"savedObjectId":"0162c130-78be-11ea-9718-118a926974a4","version":"WzcsMV0=","columns":[{"columnHeaderType":"not-filtered","id":"@timestamp"},{"columnHeaderType":"not-filtered","id":"message"},{"columnHeaderType":"not-filtered","id":"event.category"},{"columnHeaderType":"not-filtered","id":"event.action"},{"columnHeaderType":"not-filtered","id":"host.name"},{"columnHeaderType":"not-filtered","id":"source.ip"},{"columnHeaderType":"not-filtered","id":"destination.ip"},{"columnHeaderType":"not-filtered","id":"user.name"}],"created":1586256805054,"createdBy":"elastic","dataProviders":[],"dateRange":{"end":1586256837669,"start":1546343624710},"description":"description","eventType":"all","filters":[],"kqlMode":"filter","kqlQuery":{"filterQuery":{"kuery":{"expression":"host.name:*","kind":"kuery"},"serializedQuery":"{\"bool\":{\"should\":[{\"exists\":{\"field\":\"host.name\"}}],\"minimum_should_match\":1}}"}},"savedQueryId":null,"sort":{"columnId":"@timestamp","sortDirection":"desc"},"title":"SIEM test","updated":1586256839298,"updatedBy":"elastic","timelineType":"default","eventNotes":[],"globalNotes":[],"pinnedEventIds":[]} |
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
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
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.