diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/rule_management/related_integrations/related_integrations.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/rule_management/related_integrations/related_integrations.cy.ts index fd1a57b19c894..dd25a6050575c 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/rule_management/related_integrations/related_integrations.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/detection_response/rule_management/related_integrations/related_integrations.cy.ts @@ -18,7 +18,7 @@ import { } from '../../../../screens/alerts_detection_rules'; import { installPrebuiltRuleAssets, - installAllPrebuiltRulesRequest, + installSpecificPrebuiltRulesRequest, SAMPLE_PREBUILT_RULE, } from '../../../../tasks/api_calls/prebuilt_rules'; import { cleanFleet } from '../../../../tasks/api_calls/fleet'; @@ -45,250 +45,244 @@ import { waitForPageToBeLoaded, } from '../../../../tasks/rule_details'; -// FLAKY: https://github.com/elastic/kibana/issues/173307 -// FLAKY: https://github.com/elastic/kibana/issues/173306 -describe.skip( - 'Related integrations', - { tags: ['@ess', '@serverless', '@brokenInServerlessQA'] }, - () => { - const DATA_STREAM_NAME = 'logs-related-integrations-test'; - const PREBUILT_RULE_NAME = 'Prebuilt rule with related integrations'; - const RULE_RELATED_INTEGRATIONS: IntegrationDefinition[] = [ - { - package: 'aws', - version: '1.17.0', - integration: 'cloudfront', - installed: true, - enabled: true, - }, - { - package: 'aws', - version: '1.17.0', - integration: 'cloudtrail', - installed: true, - enabled: false, - }, - { - package: 'aws', - version: '1.17.0', - integration: 'unknown', - installed: false, - enabled: false, - }, - { package: 'system', version: '1.17.0', installed: true, enabled: true }, - ]; - const PREBUILT_RULE = createRuleAssetSavedObject({ - name: PREBUILT_RULE_NAME, - index: [DATA_STREAM_NAME], - query: '*:*', - rule_id: 'rule_1', - related_integrations: RULE_RELATED_INTEGRATIONS.map((x) => omit(x, ['installed', 'enabled'])), - }); +describe('Related integrations', { tags: ['@ess', '@serverless', '@brokenInServerlessQA'] }, () => { + const DATA_STREAM_NAME = 'logs-related-integrations-test'; + const PREBUILT_RULE_NAME = 'Prebuilt rule with related integrations'; + const RULE_RELATED_INTEGRATIONS: IntegrationDefinition[] = [ + { + package: 'aws', + version: '1.17.0', + integration: 'cloudfront', + installed: true, + enabled: true, + }, + { + package: 'aws', + version: '1.17.0', + integration: 'cloudtrail', + installed: true, + enabled: false, + }, + { + package: 'aws', + version: '1.17.0', + integration: 'unknown', + installed: false, + enabled: false, + }, + { package: 'system', version: '1.17.0', installed: true, enabled: true }, + ]; + const PREBUILT_RULE = createRuleAssetSavedObject({ + name: PREBUILT_RULE_NAME, + index: [DATA_STREAM_NAME], + query: '*:*', + rule_id: 'rule_1', + related_integrations: RULE_RELATED_INTEGRATIONS.map((x) => omit(x, ['installed', 'enabled'])), + }); + + beforeEach(() => { + login(); + cleanFleet(); + deleteAlertsAndRules(); + addAndInstallPrebuiltRules([PREBUILT_RULE]); + }); + + describe('integrations not installed', () => { + describe('rules management table', () => { + beforeEach(() => { + visitRulesManagementTable(); + disableAutoRefresh(); + }); - beforeEach(() => { - login(); - cleanFleet(); - deleteAlertsAndRules(); - addAndInstallPrebuiltRules([PREBUILT_RULE]); - }); + it('should display a badge with the installed integrations', () => { + cy.get(INTEGRATIONS_POPOVER).should( + 'have.text', + `0/${RULE_RELATED_INTEGRATIONS.length} integrations` + ); + }); - describe('integrations not installed', () => { - describe('rules management table', () => { - beforeEach(() => { - visitRulesManagementTable(); - disableAutoRefresh(); - }); + it('should display a popover when clicking the badge with the installed integrations', () => { + openIntegrationsPopover(); - it('should display a badge with the installed integrations', () => { - cy.get(INTEGRATIONS_POPOVER).should( - 'have.text', - `0/${RULE_RELATED_INTEGRATIONS.length} integrations` - ); - }); + cy.get(INTEGRATIONS_POPOVER_TITLE).should( + 'have.text', + `[${RULE_RELATED_INTEGRATIONS.length}] Related integrations available` + ); + cy.get(INTEGRATION_LINK).should('have.length', RULE_RELATED_INTEGRATIONS.length); + cy.get(INTEGRATION_STATUS).should('have.length', RULE_RELATED_INTEGRATIONS.length); - it('should display a popover when clicking the badge with the installed integrations', () => { - openIntegrationsPopover(); - - cy.get(INTEGRATIONS_POPOVER_TITLE).should( - 'have.text', - `[${RULE_RELATED_INTEGRATIONS.length}] Related integrations available` - ); - cy.get(INTEGRATION_LINK).should('have.length', RULE_RELATED_INTEGRATIONS.length); - cy.get(INTEGRATION_STATUS).should('have.length', RULE_RELATED_INTEGRATIONS.length); - - RULE_RELATED_INTEGRATIONS.forEach((integration, index) => { - cy.get(INTEGRATION_LINK).eq(index).contains(getIntegrationName(integration), { - matchCase: false, - }); - cy.get(INTEGRATION_STATUS).eq(index).should('have.text', 'Not installed'); + RULE_RELATED_INTEGRATIONS.forEach((integration, index) => { + cy.get(INTEGRATION_LINK).eq(index).contains(getIntegrationName(integration), { + matchCase: false, }); + cy.get(INTEGRATION_STATUS).eq(index).should('have.text', 'Not installed'); }); }); + }); - describe('rule details', () => { - beforeEach(() => { - visitFirstInstalledPrebuiltRuleDetailsPage(); - }); + describe('rule details', () => { + beforeEach(() => { + visitFirstInstalledPrebuiltRuleDetailsPage(); + }); - it('should display the integrations in the definition section', () => { - cy.get(INTEGRATION_LINK).should('have.length', RULE_RELATED_INTEGRATIONS.length); - cy.get(INTEGRATION_STATUS).should('have.length', RULE_RELATED_INTEGRATIONS.length); + it('should display the integrations in the definition section', () => { + cy.get(INTEGRATION_LINK).should('have.length', RULE_RELATED_INTEGRATIONS.length); + cy.get(INTEGRATION_STATUS).should('have.length', RULE_RELATED_INTEGRATIONS.length); - RULE_RELATED_INTEGRATIONS.forEach((integration, index) => { - cy.get(INTEGRATION_LINK).eq(index).contains(getIntegrationName(integration), { - matchCase: false, - }); - cy.get(INTEGRATION_STATUS).eq(index).should('have.text', 'Not installed'); + RULE_RELATED_INTEGRATIONS.forEach((integration, index) => { + cy.get(INTEGRATION_LINK).eq(index).contains(getIntegrationName(integration), { + matchCase: false, }); + cy.get(INTEGRATION_STATUS).eq(index).should('have.text', 'Not installed'); }); }); }); + }); - describe('integrations installed (AWS CloudFront (enabled), AWS CloudTrail (disabled), System (enabled))', () => { + describe('integrations installed (AWS CloudFront (enabled), AWS CloudTrail (disabled), System (enabled))', () => { + beforeEach(() => { + installIntegrations({ + packages: [ + { name: 'aws', version: '1.17.0' }, + { name: 'system', version: '1.17.0' }, + ], + agentPolicy: { + name: 'Agent policy', + namespace: 'default', + monitoring_enabled: ['logs'], + inactivity_timeout: 1209600, + }, + packagePolicy: AWS_PACKAGE_POLICY, + }); + }); + + describe('rules management table', () => { beforeEach(() => { - installIntegrations({ - packages: [ - { name: 'aws', version: '1.17.0' }, - { name: 'system', version: '1.17.0' }, - ], - agentPolicy: { - name: 'Agent policy', - namespace: 'default', - monitoring_enabled: ['logs'], - inactivity_timeout: 1209600, - }, - packagePolicy: AWS_PACKAGE_POLICY, - }); + visitRulesManagementTable(); + disableAutoRefresh(); }); - describe('rules management table', () => { - beforeEach(() => { - visitRulesManagementTable(); - disableAutoRefresh(); - }); + it('should display a badge with the installed integrations', () => { + const enabledIntegrations = RULE_RELATED_INTEGRATIONS.filter((x) => x.enabled).length; + const totalIntegrations = RULE_RELATED_INTEGRATIONS.length; - it('should display a badge with the installed integrations', () => { - const enabledIntegrations = RULE_RELATED_INTEGRATIONS.filter((x) => x.enabled).length; - const totalIntegrations = RULE_RELATED_INTEGRATIONS.length; + cy.get(INTEGRATIONS_POPOVER).should( + 'have.text', + `${enabledIntegrations}/${totalIntegrations} integrations` + ); + }); - cy.get(INTEGRATIONS_POPOVER).should( - 'have.text', - `${enabledIntegrations}/${totalIntegrations} integrations` - ); - }); + it('should display a popover when clicking the badge with the installed integrations', () => { + openIntegrationsPopover(); - it('should display a popover when clicking the badge with the installed integrations', () => { - openIntegrationsPopover(); - - cy.get(INTEGRATIONS_POPOVER_TITLE).should( - 'have.text', - `[${RULE_RELATED_INTEGRATIONS.length}] Related integrations available` - ); - cy.get(INTEGRATION_LINK).should('have.length', RULE_RELATED_INTEGRATIONS.length); - cy.get(INTEGRATION_STATUS).should('have.length', RULE_RELATED_INTEGRATIONS.length); - - RULE_RELATED_INTEGRATIONS.forEach((integration, index) => { - cy.get(INTEGRATION_LINK).eq(index).contains(getIntegrationName(integration), { - matchCase: false, - }); - cy.get(INTEGRATION_STATUS) - .eq(index) - .should('have.text', getIntegrationStatus(integration)); + cy.get(INTEGRATIONS_POPOVER_TITLE).should( + 'have.text', + `[${RULE_RELATED_INTEGRATIONS.length}] Related integrations available` + ); + cy.get(INTEGRATION_LINK).should('have.length', RULE_RELATED_INTEGRATIONS.length); + cy.get(INTEGRATION_STATUS).should('have.length', RULE_RELATED_INTEGRATIONS.length); + + RULE_RELATED_INTEGRATIONS.forEach((integration, index) => { + cy.get(INTEGRATION_LINK).eq(index).contains(getIntegrationName(integration), { + matchCase: false, }); + cy.get(INTEGRATION_STATUS) + .eq(index) + .should('have.text', getIntegrationStatus(integration)); }); }); + }); - describe('rule details', () => { - beforeEach(() => { - visitFirstInstalledPrebuiltRuleDetailsPage(); - waitForPageToBeLoaded(PREBUILT_RULE_NAME); - }); + describe('rule details', () => { + beforeEach(() => { + visitFirstInstalledPrebuiltRuleDetailsPage(); + waitForPageToBeLoaded(PREBUILT_RULE_NAME); + }); + + it('should display the integrations in the definition section', () => { + cy.get(INTEGRATION_LINK).should('have.length', RULE_RELATED_INTEGRATIONS.length); + cy.get(INTEGRATION_STATUS).should('have.length', RULE_RELATED_INTEGRATIONS.length); - it('should display the integrations in the definition section', () => { - cy.get(INTEGRATION_LINK).should('have.length', RULE_RELATED_INTEGRATIONS.length); - cy.get(INTEGRATION_STATUS).should('have.length', RULE_RELATED_INTEGRATIONS.length); - - RULE_RELATED_INTEGRATIONS.forEach((integration, index) => { - cy.get(INTEGRATION_LINK).eq(index).contains(getIntegrationName(integration), { - matchCase: false, - }); - cy.get(INTEGRATION_STATUS) - .eq(index) - .should('have.text', getIntegrationStatus(integration)); + RULE_RELATED_INTEGRATIONS.forEach((integration, index) => { + cy.get(INTEGRATION_LINK).eq(index).contains(getIntegrationName(integration), { + matchCase: false, }); + cy.get(INTEGRATION_STATUS) + .eq(index) + .should('have.text', getIntegrationStatus(integration)); }); + }); + + const RELATED_INTEGRATION_FIELD = 'kibana.alert.rule.parameters.related_integrations'; + + it(`the alerts generated should have a "${RELATED_INTEGRATION_FIELD}" field containing the integrations`, () => { + deleteDataStream(DATA_STREAM_NAME); + createDocument(DATA_STREAM_NAME, generateEvent()); - const RELATED_INTEGRATION_FIELD = 'kibana.alert.rule.parameters.related_integrations'; - - it(`the alerts generated should have a "${RELATED_INTEGRATION_FIELD}" field containing the integrations`, () => { - deleteDataStream(DATA_STREAM_NAME); - createDocument(DATA_STREAM_NAME, generateEvent()); - - clickEnableRuleSwitch(); - waitForAlertsToPopulate(); - - fetchRuleAlerts({ - ruleId: 'rule_1', - fields: [RELATED_INTEGRATION_FIELD], - size: 1, - }).then((alertsResponse) => { - expect(alertsResponse.body.hits.hits[0].fields).to.deep.equal({ - [RELATED_INTEGRATION_FIELD]: RULE_RELATED_INTEGRATIONS.map((x) => - omit(x, ['installed', 'enabled']) - ), - }); + clickEnableRuleSwitch(); + waitForAlertsToPopulate(); + + fetchRuleAlerts({ + ruleId: 'rule_1', + fields: [RELATED_INTEGRATION_FIELD], + size: 1, + }).then((alertsResponse) => { + expect(alertsResponse.body.hits.hits[0].fields).to.deep.equal({ + [RELATED_INTEGRATION_FIELD]: RULE_RELATED_INTEGRATIONS.map((x) => + omit(x, ['installed', 'enabled']) + ), }); }); }); }); + }); - describe('related Integrations Advanced Setting is disabled', () => { - before(() => { - disableRelatedIntegrations(); - }); + describe('related Integrations Advanced Setting is disabled', () => { + before(() => { + disableRelatedIntegrations(); + }); - after(() => { - enableRelatedIntegrations(); - }); + after(() => { + enableRelatedIntegrations(); + }); - describe('rules management table', () => { - beforeEach(() => { - visitRulesManagementTable(); - disableAutoRefresh(); - }); + describe('rules management table', () => { + beforeEach(() => { + visitRulesManagementTable(); + disableAutoRefresh(); + }); - it('should not display a badge with the installed integrations', () => { - cy.get(RULE_NAME).should('have.text', PREBUILT_RULE_NAME); - cy.get(INTEGRATION_LINK).should('not.exist'); - }); + it('should not display a badge with the installed integrations', () => { + cy.get(RULE_NAME).should('have.text', PREBUILT_RULE_NAME); + cy.get(INTEGRATION_LINK).should('not.exist'); }); + }); - describe('rule details', () => { - beforeEach(() => { - visitFirstInstalledPrebuiltRuleDetailsPage(); - }); + describe('rule details', () => { + beforeEach(() => { + visitFirstInstalledPrebuiltRuleDetailsPage(); + }); - it('should display the integrations in the definition section', () => { - cy.get(INTEGRATION_LINK).should('have.length', RULE_RELATED_INTEGRATIONS.length); - cy.get(INTEGRATION_STATUS).should('have.length', RULE_RELATED_INTEGRATIONS.length); + it('should display the integrations in the definition section', () => { + cy.get(INTEGRATION_LINK).should('have.length', RULE_RELATED_INTEGRATIONS.length); + cy.get(INTEGRATION_STATUS).should('have.length', RULE_RELATED_INTEGRATIONS.length); - RULE_RELATED_INTEGRATIONS.forEach((integration, index) => { - cy.get(INTEGRATION_LINK).eq(index).contains(getIntegrationName(integration), { - matchCase: false, - }); - cy.get(INTEGRATION_STATUS).eq(index).should('have.text', 'Not installed'); + RULE_RELATED_INTEGRATIONS.forEach((integration, index) => { + cy.get(INTEGRATION_LINK).eq(index).contains(getIntegrationName(integration), { + matchCase: false, }); + cy.get(INTEGRATION_STATUS).eq(index).should('have.text', 'Not installed'); }); }); }); - } -); + }); +}); const INSTALLED_PREBUILT_RULES_RESPONSE_ALIAS = 'prebuiltRules'; function addAndInstallPrebuiltRules(rules: Array): void { installPrebuiltRuleAssets(rules); - installAllPrebuiltRulesRequest().as(INSTALLED_PREBUILT_RULES_RESPONSE_ALIAS); + installSpecificPrebuiltRulesRequest(rules).as(INSTALLED_PREBUILT_RULES_RESPONSE_ALIAS); } function visitFirstInstalledPrebuiltRuleDetailsPage(): void {