From e98bc412ef4d67fbe406b49e8482a904bd29b78a Mon Sep 17 00:00:00 2001 From: Amardeepsingh Siglani Date: Thu, 12 Oct 2023 19:18:21 -0700 Subject: [PATCH] fixed cypress tests Signed-off-by: Amardeepsingh Siglani --- cypress/integration/1_detectors.spec.js | 2 +- cypress/integration/5_integrations.spec.js | 142 ------------------ .../components/FindingDetailsFlyout.tsx | 5 +- 3 files changed, 3 insertions(+), 146 deletions(-) delete mode 100644 cypress/integration/5_integrations.spec.js diff --git a/cypress/integration/1_detectors.spec.js b/cypress/integration/1_detectors.spec.js index 8e57325ec..4dba6903f 100644 --- a/cypress/integration/1_detectors.spec.js +++ b/cypress/integration/1_detectors.spec.js @@ -126,7 +126,7 @@ const createDetector = (detectorName, dataSource, expectFailure) => { cy.getElementByText('.euiAccordion .euiTitle', 'Detection rules (14 selected)') .click({ force: true, timeout: 5000 }) - .then(() => cy.contains('.euiTable .euiTableRow', 'Dns')); + .then(() => cy.contains('.euiTable .euiTableRow', 'DNS')); cy.getElementByText('.euiAccordion .euiTitle', 'Configure field mapping - optional'); cy.get('[aria-controls="mappedTitleFieldsAccordion"]').then(($btn) => { diff --git a/cypress/integration/5_integrations.spec.js b/cypress/integration/5_integrations.spec.js deleted file mode 100644 index 054295d7a..000000000 --- a/cypress/integration/5_integrations.spec.js +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { DETECTOR_TRIGGER_TIMEOUT, OPENSEARCH_DASHBOARDS_URL } from '../support/constants'; -import sample_index_settings from '../fixtures/sample_windows_index_settings.json'; -import sample_dns_settings from '../fixtures/integration_tests/index/create_dns_settings.json'; -import windows_usb_rule_data from '../fixtures/integration_tests/rule/create_windows_usb_rule.json'; -import dns_rule_data from '../fixtures/integration_tests/rule/create_dns_rule_with_name_selection.json'; -import usb_detector_data from '../fixtures/integration_tests/detector/create_usb_detector_data.json'; -import usb_detector_data_mappings from '../fixtures/integration_tests/detector/create_usb_detector_mappings_data.json'; -import dns_detector_data_mappings from '../fixtures/integration_tests/detector/create_dns_detector_mappings_data.json'; -import dns_detector_data from '../fixtures/integration_tests/detector/create_dns_detector_data.json'; -import add_windows_index_data from '../fixtures/integration_tests/index/add_windows_index_data.json'; -import add_dns_index_data from '../fixtures/integration_tests/index/add_dns_index_data.json'; - -describe('Integration tests', () => { - const indexName = 'cypress-index-windows'; - const dnsName = 'cypress-index-dns'; - - before(() => { - cy.cleanUpTests(); - - // Create custom rules - cy.createRule(windows_usb_rule_data).then((response) => { - usb_detector_data.inputs[0].detector_input.custom_rules[0].id = response.body.response._id; - usb_detector_data.triggers[0].ids.push(response.body.response._id); - }); - cy.createRule(dns_rule_data).then((response) => { - dns_detector_data.inputs[0].detector_input.custom_rules[0].id = response.body.response._id; - dns_detector_data.triggers[0].ids.push(response.body.response._id); - }); - - // Create test index - cy.createIndex(indexName, sample_index_settings); - cy.createIndex(dnsName, sample_dns_settings); - - // Create detectors - cy.createAliasMappings( - indexName, - usb_detector_data.detector_type, - usb_detector_data_mappings, - true - ).then(() => cy.createDetector(usb_detector_data)); - - cy.createAliasMappings( - dnsName, - dns_detector_data.detector_type, - dns_detector_data_mappings, - true - ).then(() => cy.createDetector(dns_detector_data)); - - // Ingest docs - cy.request( - 'POST', - `${Cypress.env('opensearch')}/${indexName}/_doc/101`, - add_windows_index_data - ); - cy.request('POST', `${Cypress.env('opensearch')}/${dnsName}/_doc/101`, add_dns_index_data); - - // Wait for detector interval to pass - cy.wait(DETECTOR_TRIGGER_TIMEOUT); - }); - - beforeEach(() => { - // Visit Detectors page - cy.visit(`${OPENSEARCH_DASHBOARDS_URL}/detectors`); - - // Wait for page to load - cy.waitForPageLoad('detectors', 'Threat detectors'); - }); - - xit('...can navigate to findings page', () => { - cy.intercept({ - method: 'GET', - pathname: '/_plugins/_security_analytics/findings/_search', - }).as('getFindings'); - - // Cypress USB Detector - cy.contains('Cypress USB Detector') - .click() - .then(() => { - cy.contains('View Findings') - .click() - .then(() => { - cy.hash() - .should('match', /findings\/.+$/) - .then((hash) => { - const detectorId = hash.replace('#/findings/', ''); - if (!detectorId) { - throw new Error('Navigating to findings page should contain detector ID'); - } else { - cy.wait('@getFindings').then((interception) => { - const url = new URL(interception.request.url); - // The request query param detectorId should match the hash param from the url - expect(url.searchParams.get('detectorId')).to.eq(detectorId); - }); - - // There should be only one call to the API - cy.get('@getFindings.all').should('have.length', 1); - } - }); - }); - }); - }); - xit('...can navigate to alerts page', () => { - cy.intercept({ - method: 'GET', - pathname: '/_plugins/_security_analytics/alerts', - }).as('getAlerts'); - - // Cypress USB Detector - cy.contains('Cypress USB Detector') - .click() - .then(() => { - cy.contains('View Alerts') - .click() - .then(() => { - cy.hash() - .should('match', /alerts\/.+$/) - .then((hash) => { - const detectorId = hash.replace('#/alerts/', ''); - if (!detectorId) { - throw new Error('Navigating to alerts page should contain detector ID'); - } else { - cy.wait('@getAlerts').then((interception) => { - const url = new URL(interception.request.url); - // The request query param detectorId should match the hash param from the url - expect(url.searchParams.get('detector_id')).to.eq(detectorId); - }); - - // There should be only one call to the API - cy.get('@getAlerts.all').should('have.length', 1); - } - }); - }); - }); - }); - - after(() => cy.cleanUpTests()); -}); diff --git a/public/pages/Findings/components/FindingDetailsFlyout.tsx b/public/pages/Findings/components/FindingDetailsFlyout.tsx index 9adba27e8..74518b31e 100644 --- a/public/pages/Findings/components/FindingDetailsFlyout.tsx +++ b/public/pages/Findings/components/FindingDetailsFlyout.tsx @@ -45,6 +45,7 @@ import { CorrelationFinding, RuleItemInfoBase } from '../../../../types'; import { FindingFlyoutTabId, FindingFlyoutTabs } from '../utils/constants'; import { DataStore } from '../../../store/DataStore'; import { CorrelationsTable } from './CorrelationsTable/CorrelationsTable'; +import { getLogTypeLabel } from '../../LogTypes/utils/helpers'; export interface FindingDetailsFlyoutBaseProps { finding: FindingItemType; @@ -249,9 +250,7 @@ export default class FindingDetailsFlyout extends Component< label={'Log type'} data-test-subj={'finding-details-flyout-rule-category'} > - - {capitalizeFirstLetter(fullRule.category) || DEFAULT_EMPTY_DATA} - + {getLogTypeLabel(fullRule.category) || DEFAULT_EMPTY_DATA}