-
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.
- Loading branch information
1 parent
26aed8d
commit 3c9d4a4
Showing
12 changed files
with
169 additions
and
3 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules.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,50 @@ | ||
/* | ||
* 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 { ELASTIC_RULES_BTN, RULES_TABLE, RULES_ROW } from '../screens/signal_detection_rules'; | ||
|
||
import { | ||
changeToThreeHundredRowsPerPage, | ||
loadPrebuiltDetectionRules, | ||
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded, | ||
waitForPrebuiltDetectionRulesToBeLoaded, | ||
waitForRulesToBeLoaded, | ||
} from '../tasks/signal_detection_rules'; | ||
import { | ||
goToManageSignalDetectionRules, | ||
waitForSignalsIndexToBeCreated, | ||
waitForSignalsPanelToBeLoaded, | ||
} from '../tasks/detections'; | ||
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; | ||
|
||
import { DETECTIONS } from '../urls/navigation'; | ||
|
||
describe('Signal detection rules', () => { | ||
before(() => { | ||
loginAndWaitForPageWithoutDateRange(DETECTIONS); | ||
}); | ||
it('Loads prebuilt rules', () => { | ||
waitForSignalsPanelToBeLoaded(); | ||
waitForSignalsIndexToBeCreated(); | ||
goToManageSignalDetectionRules(); | ||
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded(); | ||
loadPrebuiltDetectionRules(); | ||
waitForPrebuiltDetectionRulesToBeLoaded(); | ||
|
||
const expectedElasticRulesBtnText = 'Elastic rules (92)'; | ||
cy.get(ELASTIC_RULES_BTN) | ||
.invoke('text') | ||
.should('eql', expectedElasticRulesBtnText); | ||
|
||
changeToThreeHundredRowsPerPage(); | ||
waitForRulesToBeLoaded(); | ||
|
||
const expectedNumberOfRules = 92; | ||
cy.get(RULES_TABLE).then($table => { | ||
cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules); | ||
}); | ||
}); | ||
}); |
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,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const LOADING_SIGNALS_PANEL = '[data-test-subj="loading-signals-panel"]'; | ||
|
||
export const MANAGE_SIGNAL_DETECTION_RULES_BTN = '[data-test-subj="manage-signal-detection-rules"]'; |
22 changes: 22 additions & 0 deletions
22
x-pack/legacy/plugins/siem/cypress/screens/signal_detection_rules.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,22 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const ELASTIC_RULES_BTN = '[data-test-subj="show-elastic-rules-filter-button"]'; | ||
|
||
export const LOAD_PREBUILT_RULES_BTN = '[data-test-subj="load-prebuilt-rules"]'; | ||
|
||
export const LOADING_INITIAL_PREBUILT_RULES_TABLE = | ||
'[data-test-subj="initialLoadingPanelAllRulesTable"]'; | ||
|
||
export const LOADING_SPINNER = '[data-test-subj="loading-spinner"]'; | ||
|
||
export const PAGINATION_POPOVER_BTN = '[data-test-subj="tablePaginationPopoverButton"]'; | ||
|
||
export const RULES_TABLE = '[data-test-subj="rules-table"]'; | ||
|
||
export const RULES_ROW = '.euiTableRow'; | ||
|
||
export const THREE_HUNDRED_ROWS = '[data-test-subj="tablePagination-300-rows"]'; |
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,32 @@ | ||
/* | ||
* 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 { LOADING_SIGNALS_PANEL, MANAGE_SIGNAL_DETECTION_RULES_BTN } from '../screens/detections'; | ||
|
||
export const goToManageSignalDetectionRules = () => { | ||
cy.get(MANAGE_SIGNAL_DETECTION_RULES_BTN) | ||
.should('exist') | ||
.click({ force: true }); | ||
}; | ||
|
||
export const waitForSignalsIndexToBeCreated = () => { | ||
for (let i = 0; i < 60; i++) { | ||
i = cy | ||
.request({ url: '/api/detection_engine/index', failOnStatusCode: false }) | ||
.then(response => { | ||
if (response.status === 200) { | ||
return 60; | ||
} else { | ||
cy.wait(1000); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
export const waitForSignalsPanelToBeLoaded = () => { | ||
cy.get(LOADING_SIGNALS_PANEL).should('exist'); | ||
cy.get(LOADING_SIGNALS_PANEL).should('not.exist'); | ||
}; |
40 changes: 40 additions & 0 deletions
40
x-pack/legacy/plugins/siem/cypress/tasks/signal_detection_rules.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,40 @@ | ||
/* | ||
* 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 { | ||
LOAD_PREBUILT_RULES_BTN, | ||
LOADING_INITIAL_PREBUILT_RULES_TABLE, | ||
LOADING_SPINNER, | ||
PAGINATION_POPOVER_BTN, | ||
RULES_TABLE, | ||
THREE_HUNDRED_ROWS, | ||
} from '../screens/signal_detection_rules'; | ||
|
||
export const changeToThreeHundredRowsPerPage = () => { | ||
cy.get(PAGINATION_POPOVER_BTN).click({ force: true }); | ||
cy.get(THREE_HUNDRED_ROWS).click(); | ||
}; | ||
|
||
export const loadPrebuiltDetectionRules = () => { | ||
cy.get(LOAD_PREBUILT_RULES_BTN) | ||
.should('exist') | ||
.click({ force: true }); | ||
}; | ||
|
||
export const waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded = () => { | ||
cy.get(LOADING_INITIAL_PREBUILT_RULES_TABLE).should('exist'); | ||
cy.get(LOADING_INITIAL_PREBUILT_RULES_TABLE).should('not.exist'); | ||
}; | ||
|
||
export const waitForPrebuiltDetectionRulesToBeLoaded = () => { | ||
cy.get(LOAD_PREBUILT_RULES_BTN).should('not.exist'); | ||
cy.get(RULES_TABLE).should('exist'); | ||
}; | ||
|
||
export const waitForRulesToBeLoaded = () => { | ||
cy.get(LOADING_SPINNER).should('exist'); | ||
cy.get(LOADING_SPINNER).should('not.exist'); | ||
}; |
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
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