From d3d61d3482f410fec9ad42dbc9eb84c1a3ca33a0 Mon Sep 17 00:00:00 2001 From: Gloria Hornero Date: Tue, 30 Nov 2021 17:14:07 +0100 Subject: [PATCH] [Security Solution] Fix attach to case test (#119589) * updates the detections script in order to take into consideration the new alerts index * refactors and unskips attach to case test Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../detection_alerts/attach_to_case.spec.ts | 15 +++++++++------ .../security_solution/cypress/tasks/alerts.ts | 4 ++++ .../detections_admin/detections_role.json | 1 + .../roles_users/hunter/detections_role.json | 2 +- .../platform_engineer/detections_role.json | 2 +- .../roles_users/reader/detections_role.json | 3 ++- .../roles_users/rule_author/detections_role.json | 2 +- .../roles_users/soc_manager/detections_role.json | 2 +- .../roles_users/t1_analyst/detections_role.json | 2 +- .../roles_users/t2_analyst/detections_role.json | 2 +- 10 files changed, 22 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/security_solution/cypress/integration/detection_alerts/attach_to_case.spec.ts b/x-pack/plugins/security_solution/cypress/integration/detection_alerts/attach_to_case.spec.ts index e5b2c4eed3b00..d7a5ce6799230 100644 --- a/x-pack/plugins/security_solution/cypress/integration/detection_alerts/attach_to_case.spec.ts +++ b/x-pack/plugins/security_solution/cypress/integration/detection_alerts/attach_to_case.spec.ts @@ -8,7 +8,11 @@ import { getNewRule } from '../../objects/rule'; import { ROLES } from '../../../common/test'; -import { waitForAlertsIndexToBeCreated, waitForAlertsPanelToBeLoaded } from '../../tasks/alerts'; +import { + expandFirstAlertActions, + waitForAlertsIndexToBeCreated, + waitForAlertsPanelToBeLoaded, +} from '../../tasks/alerts'; import { createCustomRuleActivated } from '../../tasks/api_calls/rules'; import { cleanKibana } from '../../tasks/common'; import { waitForAlertsToPopulate } from '../../tasks/create_new_rule'; @@ -16,7 +20,7 @@ import { login, loginAndWaitForPage, waitForPageWithoutDateRange } from '../../t import { refreshPage } from '../../tasks/security_header'; import { ALERTS_URL } from '../../urls/navigation'; -import { ATTACH_ALERT_TO_CASE_BUTTON, TIMELINE_CONTEXT_MENU_BTN } from '../../screens/alerts'; +import { ATTACH_ALERT_TO_CASE_BUTTON } from '../../screens/alerts'; const loadDetectionsPage = (role: ROLES) => { waitForPageWithoutDateRange(ALERTS_URL, role); @@ -44,7 +48,7 @@ describe('Alerts timeline', () => { }); it('should not allow user with read only privileges to attach alerts to cases', () => { - cy.get(TIMELINE_CONTEXT_MENU_BTN).first().click({ force: true }); + expandFirstAlertActions(); cy.get(ATTACH_ALERT_TO_CASE_BUTTON).should('not.exist'); }); }); @@ -54,9 +58,8 @@ describe('Alerts timeline', () => { loadDetectionsPage(ROLES.platform_engineer); }); - // Skipping due to alerts not refreshing for platform_engineer despite being returned from API? - it.skip('should allow a user with crud privileges to attach alerts to cases', () => { - cy.get(TIMELINE_CONTEXT_MENU_BTN).first().click({ force: true }); + it('should allow a user with crud privileges to attach alerts to cases', () => { + expandFirstAlertActions(); cy.get(ATTACH_ALERT_TO_CASE_BUTTON).first().should('not.be.disabled'); }); }); diff --git a/x-pack/plugins/security_solution/cypress/tasks/alerts.ts b/x-pack/plugins/security_solution/cypress/tasks/alerts.ts index 56f3e6821f5f5..5cb39ea3e1b4d 100644 --- a/x-pack/plugins/security_solution/cypress/tasks/alerts.ts +++ b/x-pack/plugins/security_solution/cypress/tasks/alerts.ts @@ -60,6 +60,10 @@ export const closeAlerts = () => { .should('not.be.visible'); }; +export const expandFirstAlertActions = () => { + cy.get(TIMELINE_CONTEXT_MENU_BTN).first().click({ force: true }); +}; + export const expandFirstAlert = () => { cy.get(EXPAND_ALERT_BTN).should('exist'); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/detections_admin/detections_role.json b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/detections_admin/detections_role.json index e6fbef08d25ee..e0219dbc941a9 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/detections_admin/detections_role.json +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/detections_admin/detections_role.json @@ -5,6 +5,7 @@ { "names": [ ".siem-signals-*", + ".alerts-security*", ".lists*", ".items*", "apm-*-transaction*", diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/hunter/detections_role.json b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/hunter/detections_role.json index af12a2cb674d5..5f7d1091cdb36 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/hunter/detections_role.json +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/hunter/detections_role.json @@ -16,7 +16,7 @@ "privileges": ["read", "write"] }, { - "names": [".siem-signals-*"], + "names": [".alerts-security*", ".siem-signals-*"], "privileges": ["read", "write"] }, { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/platform_engineer/detections_role.json b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/platform_engineer/detections_role.json index 18effae645c42..bb26dec6decbb 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/platform_engineer/detections_role.json +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/platform_engineer/detections_role.json @@ -23,7 +23,7 @@ "privileges": ["all"] }, { - "names": [".siem-signals-*"], + "names": [".alerts-security*", ".siem-signals-*"], "privileges": ["all"] } ] diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/reader/detections_role.json b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/reader/detections_role.json index 8f9434d9a3623..e351227fb173e 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/reader/detections_role.json +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/reader/detections_role.json @@ -4,7 +4,8 @@ "indices": [ { "names" : [ - ".siem-signals*", + ".siem-signals-*", + ".alerts-security*", ".lists*", ".items*", "metrics-endpoint.metadata_current_*", diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/rule_author/detections_role.json b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/rule_author/detections_role.json index d6bee8ce9dc16..bf2d948519564 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/rule_author/detections_role.json +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/rule_author/detections_role.json @@ -18,7 +18,7 @@ "privileges": ["read", "write"] }, { - "names": [".siem-signals-*"], + "names": [".alerts-security*", ".siem-signals-*"], "privileges": ["read", "write", "maintenance", "view_index_metadata"] }, { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/soc_manager/detections_role.json b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/soc_manager/detections_role.json index 46f7ca1d0067d..36e811c5a7ac2 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/soc_manager/detections_role.json +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/soc_manager/detections_role.json @@ -18,7 +18,7 @@ "privileges": ["read", "write"] }, { - "names": [".siem-signals-*"], + "names": [".alerts-security*", ".siem-signals-*"], "privileges": ["read", "write", "manage"] }, { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/t1_analyst/detections_role.json b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/t1_analyst/detections_role.json index ea3bd7b97e3ca..bd7f211f16d93 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/t1_analyst/detections_role.json +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/t1_analyst/detections_role.json @@ -2,7 +2,7 @@ "elasticsearch": { "cluster": [], "indices": [ - { "names": [".siem-signals-*"], "privileges": ["read", "write", "maintenance"] }, + { "names": [".alerts-security*", ".siem-signals-*"], "privileges": ["read", "write", "maintenance"] }, { "names": [ "apm-*-transaction*", diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/t2_analyst/detections_role.json b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/t2_analyst/detections_role.json index 209e57eba2cfd..d97cd39a11421 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/t2_analyst/detections_role.json +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/scripts/roles_users/t2_analyst/detections_role.json @@ -2,7 +2,7 @@ "elasticsearch": { "cluster": [], "indices": [ - { "names": [".siem-signals-*"], "privileges": ["read", "write", "maintenance"] }, + { "names": [".alerts-security*", ".siem-signals-*"], "privileges": ["read", "write", "maintenance"] }, { "names": [ ".lists*",