|
5 | 5 | * 2.0. |
6 | 6 | */ |
7 | 7 |
|
8 | | -import { RULE_NAME } from '../screens/alerts_detection_rules'; |
9 | | - |
| 8 | +import { ALERT_DETAILS_CELLS, SERVER_SIDE_EVENT_COUNT } from '../screens/alerts_detection_rules'; |
10 | 9 | import { |
11 | | - goToManageAlertsDetectionRules, |
12 | | - waitForAlertsIndexToBeCreated, |
13 | | - waitForAlertsPanelToBeLoaded, |
14 | | -} from '../tasks/alerts'; |
15 | | -import { waitForRulesTableToBeLoaded } from '../tasks/alerts_detection_rules'; |
16 | | -import { loginAndWaitForPageWithoutDateRange } from '../tasks/login'; |
17 | | - |
18 | | -import { ALERTS_URL } from '../urls/navigation'; |
19 | | - |
20 | | -describe('After an upgrade, the cusom query rule', () => { |
21 | | - it('Displays the rule', function () { |
22 | | - loginAndWaitForPageWithoutDateRange(ALERTS_URL); |
23 | | - waitForAlertsPanelToBeLoaded(); |
24 | | - waitForAlertsIndexToBeCreated(); |
25 | | - goToManageAlertsDetectionRules(); |
| 10 | + ADDITIONAL_LOOK_BACK_DETAILS, |
| 11 | + ABOUT_DETAILS, |
| 12 | + ABOUT_RULE_DESCRIPTION, |
| 13 | + CUSTOM_QUERY_DETAILS, |
| 14 | + DEFINITION_DETAILS, |
| 15 | + getDetails, |
| 16 | + INDEX_PATTERNS_DETAILS, |
| 17 | + RISK_SCORE_DETAILS, |
| 18 | + RULE_NAME_HEADER, |
| 19 | + RULE_TYPE_DETAILS, |
| 20 | + RUNS_EVERY_DETAILS, |
| 21 | + SCHEDULE_DETAILS, |
| 22 | + SEVERITY_DETAILS, |
| 23 | + TIMELINE_TEMPLATE_DETAILS, |
| 24 | +} from '../screens/rule_details'; |
| 25 | + |
| 26 | +import { waitForPageToBeLoaded } from '../tasks/common'; |
| 27 | +import { waitForRulesTableToBeLoaded, goToRuleDetails } from '../tasks/alerts_detection_rules'; |
| 28 | +import { loginAndWaitForPage } from '../tasks/login'; |
| 29 | + |
| 30 | +import { DETECTIONS_RULE_MANAGEMENT_URL } from '../urls/navigation'; |
| 31 | + |
| 32 | +const EXPECTED_NUMBER_OF_ALERTS = '1'; |
| 33 | + |
| 34 | +const alert = { |
| 35 | + rule: 'Custom query rule for upgrade', |
| 36 | + severity: 'low', |
| 37 | + riskScore: '7', |
| 38 | + reason: |
| 39 | + 'file event with process test, file The file to test, by Security Solution on security-solution.local created low alert Custom query rule for upgrade.', |
| 40 | + hostName: 'security-solution.local', |
| 41 | + username: 'test', |
| 42 | + processName: 'The file to test', |
| 43 | + fileName: 'The file to test', |
| 44 | + sourceIp: '127.0.0.1', |
| 45 | + destinationIp: '127.0.0.2', |
| 46 | +}; |
| 47 | + |
| 48 | +const rule = { |
| 49 | + customQuery: '*:*', |
| 50 | + name: 'Custom query rule for upgrade', |
| 51 | + description: 'My description', |
| 52 | + index: ['auditbeat-*'], |
| 53 | + severity: 'Low', |
| 54 | + riskScore: '7', |
| 55 | + timelineTemplate: 'none', |
| 56 | + runsEvery: '10s', |
| 57 | + lookBack: '179999990s', |
| 58 | + timeline: 'None', |
| 59 | +}; |
| 60 | + |
| 61 | +describe('After an upgrade, the custom query rule', () => { |
| 62 | + before(() => { |
| 63 | + loginAndWaitForPage(DETECTIONS_RULE_MANAGEMENT_URL); |
26 | 64 | waitForRulesTableToBeLoaded(); |
27 | | - cy.get(RULE_NAME).should('have.text', 'Custom query rule for upgrade'); |
| 65 | + goToRuleDetails(); |
| 66 | + waitForPageToBeLoaded(); |
| 67 | + }); |
| 68 | + |
| 69 | + it('Has the expected alerts number', () => { |
| 70 | + cy.get(SERVER_SIDE_EVENT_COUNT).contains(EXPECTED_NUMBER_OF_ALERTS); |
| 71 | + }); |
| 72 | + |
| 73 | + it('Displays the rule details', () => { |
| 74 | + cy.get(RULE_NAME_HEADER).should('contain', `${rule.name}`); |
| 75 | + cy.get(ABOUT_RULE_DESCRIPTION).should('have.text', rule.description); |
| 76 | + cy.get(ABOUT_DETAILS).within(() => { |
| 77 | + getDetails(SEVERITY_DETAILS).should('have.text', rule.severity); |
| 78 | + getDetails(RISK_SCORE_DETAILS).should('have.text', rule.riskScore); |
| 79 | + }); |
| 80 | + cy.get(DEFINITION_DETAILS).within(() => { |
| 81 | + getDetails(INDEX_PATTERNS_DETAILS).should('have.text', rule.index.join('')); |
| 82 | + getDetails(CUSTOM_QUERY_DETAILS).should('have.text', rule.customQuery); |
| 83 | + getDetails(RULE_TYPE_DETAILS).should('have.text', 'Query'); |
| 84 | + getDetails(TIMELINE_TEMPLATE_DETAILS).should('have.text', rule.timeline); |
| 85 | + }); |
| 86 | + cy.get(SCHEDULE_DETAILS).within(() => { |
| 87 | + getDetails(RUNS_EVERY_DETAILS).should('have.text', rule.runsEvery); |
| 88 | + getDetails(ADDITIONAL_LOOK_BACK_DETAILS).should('have.text', rule.lookBack); |
| 89 | + }); |
| 90 | + }); |
| 91 | + |
| 92 | + it('Displays the alert details', () => { |
| 93 | + cy.get(ALERT_DETAILS_CELLS).first().focus(); |
| 94 | + cy.get(ALERT_DETAILS_CELLS).first().type('{rightarrow}'); |
| 95 | + cy.get(ALERT_DETAILS_CELLS) |
| 96 | + .contains(alert.rule) |
| 97 | + .then(($el) => { |
| 98 | + cy.wrap($el).type('{rightarrow}'); |
| 99 | + }); |
| 100 | + cy.get(ALERT_DETAILS_CELLS) |
| 101 | + .contains(alert.severity) |
| 102 | + .then(($el) => { |
| 103 | + cy.wrap($el).type('{rightarrow}'); |
| 104 | + }); |
| 105 | + cy.get(ALERT_DETAILS_CELLS) |
| 106 | + .contains(alert.riskScore) |
| 107 | + .then(($el) => { |
| 108 | + cy.wrap($el).type('{rightarrow}'); |
| 109 | + }); |
| 110 | + cy.get(ALERT_DETAILS_CELLS) |
| 111 | + .contains(alert.reason) |
| 112 | + .then(($el) => { |
| 113 | + cy.wrap($el).type('{rightarrow}'); |
| 114 | + }); |
| 115 | + cy.get(ALERT_DETAILS_CELLS) |
| 116 | + .contains(alert.hostName) |
| 117 | + .then(($el) => { |
| 118 | + cy.wrap($el).type('{rightarrow}'); |
| 119 | + }); |
| 120 | + cy.get(ALERT_DETAILS_CELLS) |
| 121 | + .contains(alert.username) |
| 122 | + .then(($el) => { |
| 123 | + cy.wrap($el).type('{rightarrow}'); |
| 124 | + }); |
| 125 | + cy.get(ALERT_DETAILS_CELLS) |
| 126 | + .contains(alert.processName) |
| 127 | + .then(($el) => { |
| 128 | + cy.wrap($el).type('{rightarrow}'); |
| 129 | + }); |
| 130 | + cy.get(ALERT_DETAILS_CELLS) |
| 131 | + .contains(alert.fileName) |
| 132 | + .then(($el) => { |
| 133 | + cy.wrap($el).type('{rightarrow}'); |
| 134 | + }); |
| 135 | + cy.get(ALERT_DETAILS_CELLS) |
| 136 | + .contains(alert.sourceIp) |
| 137 | + .then(($el) => { |
| 138 | + cy.wrap($el).type('{rightarrow}'); |
| 139 | + }); |
| 140 | + cy.get(ALERT_DETAILS_CELLS).contains(alert.destinationIp); |
28 | 141 | }); |
29 | 142 | }); |
0 commit comments