forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SIEM] Adds Cypress 'Exports custom rule' test (elastic#64099) (elast…
…ic#65233) * changes default browser download folder * adds 'exportRuleAction' data-test-subj attribute * implements 'Exports a custom rule' test * changes headless browser to chrome * updates path * updates 'EXPECTED_RULE_FILE_PATH' * gives time to the file to be downloaded * adds downloads folder * updates download directory * updates paths * captures API call to check the content of the file * removes browser launch hook since is not needed anymore Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
02ddfda
commit 9f02c06
Showing
8 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
x-pack/plugins/siem/cypress/integration/signal_detection_rules_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,46 @@ | ||
/* | ||
* 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 { | ||
goToManageSignalDetectionRules, | ||
waitForSignalsIndexToBeCreated, | ||
waitForSignalsPanelToBeLoaded, | ||
} from '../tasks/detections'; | ||
import { esArchiverLoad, esArchiverUnload } from '../tasks/es_archiver'; | ||
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; | ||
import { exportFirstRule } from '../tasks/signal_detection_rules'; | ||
|
||
import { DETECTIONS } from '../urls/navigation'; | ||
|
||
const EXPECTED_EXPORTED_RULE_FILE_PATH = 'cypress/test_files/expected_rules_export.ndjson'; | ||
|
||
describe('Export rules', () => { | ||
before(() => { | ||
esArchiverLoad('custom_rules'); | ||
cy.server(); | ||
cy.route( | ||
'POST', | ||
'**api/detection_engine/rules/_export?exclude_export_details=false&file_name=rules_export.ndjson*' | ||
).as('export'); | ||
}); | ||
|
||
after(() => { | ||
esArchiverUnload('custom_rules'); | ||
}); | ||
|
||
it('Exports a custom rule', () => { | ||
loginAndWaitForPageWithoutDateRange(DETECTIONS); | ||
waitForSignalsPanelToBeLoaded(); | ||
waitForSignalsIndexToBeCreated(); | ||
goToManageSignalDetectionRules(); | ||
exportFirstRule(); | ||
cy.wait('@export').then(xhr => { | ||
cy.readFile(EXPECTED_EXPORTED_RULE_FILE_PATH).then($expectedExportedJson => { | ||
cy.wrap(xhr.responseBody).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
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
2 changes: 2 additions & 0 deletions
2
x-pack/plugins/siem/cypress/test_files/expected_rules_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,2 @@ | ||
{"actions":[],"created_at":"2020-03-26T10:09:07.569Z","updated_at":"2020-03-26T10:09:08.021Z","created_by":"elastic","description":"Rule 1","enabled":true,"false_positives":[],"filters":[],"from":"now-360s","id":"49db5bd1-bdd5-4821-be26-bb70a815dedb","immutable":false,"index":["apm-*-transaction*","auditbeat-*","endgame-*","filebeat-*","packetbeat-*","winlogbeat-*"],"interval":"5m","rule_id":"0cea4194-03f2-4072-b281-d31b72221d9d","language":"kuery","output_index":".siem-signals-default","max_signals":100,"risk_score":50,"name":"Rule 1","query":"host.name:*","references":[],"meta":{"from":"1m","throttle":"no_actions"},"severity":"low","updated_by":"elastic","tags":["rule1"],"to":"now","type":"query","threat":[],"throttle":"no_actions","version":1} | ||
{"exported_count":1,"missing_rules":[],"missing_rules_count":0} |
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