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.
[RAM][SECURITYSOLUTION][ALERTS] - Integrate per-action frequency UI i…
…n security solution (elastic#154534)
- Loading branch information
Showing
27 changed files
with
200 additions
and
284 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
* 2.0. | ||
*/ | ||
|
||
import type { RuleActionArray } from '@kbn/securitysolution-io-ts-alerting-types'; | ||
import { ROLES } from '../../../common/test'; | ||
|
||
import { | ||
|
@@ -15,11 +16,14 @@ import { | |
import { actionFormSelector } from '../../screens/common/rule_actions'; | ||
|
||
import { cleanKibana, deleteAlertsAndRules, deleteConnectors } from '../../tasks/common'; | ||
import type { RuleActionFrequency } from '../../tasks/common/rule_actions'; | ||
import { | ||
addSlackRuleAction, | ||
assertSlackRuleAction, | ||
addEmailConnectorAndRuleAction, | ||
assertEmailRuleAction, | ||
assertSelectedActionFrequency, | ||
pickActionFrequency, | ||
} from '../../tasks/common/rule_actions'; | ||
import { | ||
waitForRulesTableToBeLoaded, | ||
|
@@ -32,10 +36,8 @@ import { | |
submitBulkEditForm, | ||
checkOverwriteRuleActionsCheckbox, | ||
openBulkEditRuleActionsForm, | ||
pickActionFrequency, | ||
openBulkActionsMenu, | ||
} from '../../tasks/rules_bulk_edit'; | ||
import { assertSelectedActionFrequency } from '../../tasks/edit_rule'; | ||
import { login, visitWithoutDateRange } from '../../tasks/login'; | ||
import { esArchiverResetKibana } from '../../tasks/es_archiver'; | ||
|
||
|
@@ -74,14 +76,19 @@ describe('Detection rules, bulk edit of rule actions', () => { | |
esArchiverResetKibana(); | ||
|
||
createSlackConnector().then(({ body }) => { | ||
const actions = [ | ||
const actions: RuleActionArray = [ | ||
{ | ||
id: body.id, | ||
action_type_id: '.slack', | ||
group: 'default', | ||
params: { | ||
message: expectedExistingSlackMessage, | ||
}, | ||
frequency: { | ||
summary: true, | ||
throttle: null, | ||
notifyWhen: 'onActiveAlert', | ||
}, | ||
}, | ||
]; | ||
|
||
|
@@ -119,7 +126,11 @@ describe('Detection rules, bulk edit of rule actions', () => { | |
}); | ||
|
||
it('Add a rule action to rules (existing connector)', () => { | ||
const expectedActionFrequency = 'Daily'; | ||
const expectedActionFrequency: RuleActionFrequency = { | ||
customFrequency: 'Custom frequency', | ||
throttle: 1, | ||
throttleUnit: 'd', | ||
}; | ||
|
||
loadPrebuiltDetectionRulesFromHeaderBtn(); | ||
|
||
|
@@ -130,33 +141,35 @@ describe('Detection rules, bulk edit of rule actions', () => { | |
// ensure rule actions info callout displayed on the form | ||
cy.get(RULES_BULK_EDIT_ACTIONS_INFO).should('be.visible'); | ||
|
||
pickActionFrequency(expectedActionFrequency); | ||
addSlackRuleAction(expectedSlackMessage); | ||
pickActionFrequency(expectedActionFrequency); | ||
|
||
submitBulkEditForm(); | ||
waitForBulkEditActionToFinish({ updatedCount: expectedNumberOfRulesToBeEdited }); | ||
|
||
// check if rule has been updated | ||
goToEditRuleActionsSettingsOf(ruleNameToAssert); | ||
|
||
assertSelectedActionFrequency(expectedActionFrequency); | ||
assertSelectedActionFrequency(expectedActionFrequency, 1); | ||
assertSlackRuleAction(expectedExistingSlackMessage, 0); | ||
assertSlackRuleAction(expectedSlackMessage, 1); | ||
// ensure there is no third action | ||
cy.get(actionFormSelector(2)).should('not.exist'); | ||
}); | ||
|
||
it('Overwrite rule actions in rules', () => { | ||
const expectedActionFrequency = 'On each rule execution'; | ||
const expectedActionFrequency: RuleActionFrequency = { | ||
customFrequency: 'Per rule run', | ||
}; | ||
|
||
loadPrebuiltDetectionRulesFromHeaderBtn(); | ||
|
||
// select both custom and prebuilt rules | ||
selectNumberOfRules(expectedNumberOfRulesToBeEdited); | ||
openBulkEditRuleActionsForm(); | ||
|
||
pickActionFrequency(expectedActionFrequency); | ||
addSlackRuleAction(expectedSlackMessage); | ||
pickActionFrequency(expectedActionFrequency); | ||
|
||
// check overwrite box, ensure warning is displayed | ||
checkOverwriteRuleActionsCheckbox(); | ||
|
@@ -177,23 +190,27 @@ describe('Detection rules, bulk edit of rule actions', () => { | |
}); | ||
|
||
it('Add a rule action to rules (new connector)', () => { | ||
const expectedActionFrequency = 'Hourly'; | ||
const expectedActionFrequency: RuleActionFrequency = { | ||
customFrequency: 'Custom frequency', | ||
throttle: 2, | ||
throttleUnit: 'h', | ||
}; | ||
const expectedEmail = '[email protected]'; | ||
const expectedSubject = 'Subject'; | ||
|
||
selectNumberOfRules(expectedNumberOfCustomRulesToBeEdited); | ||
openBulkEditRuleActionsForm(); | ||
|
||
pickActionFrequency(expectedActionFrequency); | ||
addEmailConnectorAndRuleAction(expectedEmail, expectedSubject); | ||
pickActionFrequency(expectedActionFrequency); | ||
|
||
submitBulkEditForm(); | ||
waitForBulkEditActionToFinish({ updatedCount: expectedNumberOfCustomRulesToBeEdited }); | ||
|
||
// check if rule has been updated | ||
goToEditRuleActionsSettingsOf(ruleNameToAssert); | ||
|
||
assertSelectedActionFrequency(expectedActionFrequency); | ||
assertSelectedActionFrequency(expectedActionFrequency, 1); | ||
assertEmailRuleAction(expectedEmail, expectedSubject); | ||
}); | ||
}); | ||
|
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 |
---|---|---|
|
@@ -19,10 +19,13 @@ import { | |
RULE_SWITCH, | ||
SEVERITY, | ||
} from '../../screens/alerts_detection_rules'; | ||
import { | ||
ACTIONS_NOTIFY_WHEN_BUTTON, | ||
ACTIONS_SUMMARY_BUTTON, | ||
} from '../../screens/common/rule_actions'; | ||
import { | ||
ABOUT_CONTINUE_BTN, | ||
ABOUT_EDIT_BUTTON, | ||
ACTIONS_THROTTLE_INPUT, | ||
CUSTOM_QUERY_INPUT, | ||
DEFINE_CONTINUE_BUTTON, | ||
DEFINE_EDIT_BUTTON, | ||
|
@@ -401,12 +404,11 @@ describe('Custom query rules', () => { | |
|
||
goToActionsStepTab(); | ||
|
||
cy.get(ACTIONS_THROTTLE_INPUT).invoke('val').should('eql', 'no_actions'); | ||
|
||
cy.get(ACTIONS_THROTTLE_INPUT).select('Weekly'); | ||
|
||
addEmailConnectorAndRuleAction('[email protected]', 'Subject'); | ||
|
||
cy.get(ACTIONS_SUMMARY_BUTTON).should('have.text', 'Summary of alerts'); | ||
cy.get(ACTIONS_NOTIFY_WHEN_BUTTON).should('have.text', 'Per rule run'); | ||
|
||
goToAboutStepTab(); | ||
cy.get(TAGS_CLEAR_BUTTON).click({ force: true }); | ||
fillAboutRule(getEditedRule()); | ||
|
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
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.