From 16bb9d0071c8cd642bb5678cc69616c4b5395eca Mon Sep 17 00:00:00 2001 From: MadameSheema Date: Fri, 21 Feb 2020 14:38:28 +0100 Subject: [PATCH] [SIEM] Cleans Cypress tests code (#58134) (#58197) * deletes 'events viewer' lib * deletes 'fields browser' lib * deletes 'inspect' lib * deletes 'ml conditional links' lib * deletes 'navigate' lib * delete 'overview' lib * deletes 'pagination' lib * deletes 'timeline' lib * deletes 'url state' lib * deletes the rest of lib folders * reorders tasks and screens * reorders 'integration' folder * orders integration files * extracts defeault timeout to cypress configuration * orders screens files * cleans tasks files * fixes type check --- x-pack/legacy/plugins/siem/cypress.json | 1 + .../events_viewer => }/events_viewer.spec.ts | 48 +++--- .../fields_browser.spec.ts | 49 +++--- .../{smoke_tests/inspect => }/inspect.spec.ts | 24 +-- .../integration/lib/drag_n_drop/helpers.ts | 50 ------ .../integration/lib/events_viewer/helpers.ts | 31 ---- .../lib/events_viewer/selectors.ts | 31 ---- .../integration/lib/fields_browser/helpers.ts | 44 ------ .../lib/fields_browser/selectors.ts | 40 ----- .../integration/lib/fixtures/helpers.ts | 19 --- .../cypress/integration/lib/hosts/helpers.ts | 16 -- .../integration/lib/hosts/selectors.ts | 21 --- .../integration/lib/inspect/helpers.ts | 29 ---- .../integration/lib/inspect/selectors.ts | 89 ----------- .../cypress/integration/lib/login/helpers.ts | 115 -------------- .../integration/lib/login/selectors.ts | 14 -- .../lib/ml_conditional_links/index.ts | 76 --------- .../integration/lib/navigation/selectors.ts | 25 --- .../integration/lib/overview/selectors.ts | 144 ------------------ .../integration/lib/pagination/selectors.ts | 14 -- .../integration/lib/timeline/helpers.ts | 59 ------- .../integration/lib/timeline/selectors.ts | 47 ------ .../integration/lib/url_state/index.ts | 47 ------ .../cypress/integration/lib/urls/index.ts | 33 ---- .../cypress/integration/lib/util/helpers.ts | 27 ---- .../ml_conditional_links.spec.ts | 46 +++--- .../navigation => }/navigation.spec.ts | 9 +- .../overview => }/overview.spec.ts | 10 +- .../pagination => }/pagination.spec.ts | 20 +-- ...pec.ts => timeline_data_providers.spec.ts} | 31 ++-- ...spec.ts => timeline_flyout_button.spec.ts} | 17 +-- ...c.ts => timeline_search_or_filter.spec.ts} | 14 +- ...spec.ts => timeline_toggle_column.spec.ts} | 32 ++-- .../url_state => }/url_state.spec.ts | 65 ++++---- .../screens/{calendar.ts => date_picker.ts} | 22 ++- .../screens/{timeline => }/fields_browser.ts | 67 ++++---- .../siem/cypress/screens/hosts/all_hosts.ts | 4 +- .../screens/{ => hosts}/authentications.ts | 0 .../siem/cypress/screens/hosts/events.ts | 36 +++-- .../cypress/screens/hosts/fields_browser.ts | 20 --- .../siem/cypress/screens/hosts/main.ts | 12 +- .../screens/hosts/uncommon_processes.ts | 4 +- .../screens/{header.ts => siem_header.ts} | 8 +- .../screens/{timeline/main.ts => timeline.ts} | 39 +++-- .../cypress/screens/uncommon_processes.ts | 8 - .../plugins/siem/cypress/tasks/common.ts | 14 +- .../tasks/{calendar.ts => date_picker.ts} | 58 ++++--- .../tasks/{timeline => }/fields_browser.ts | 51 +++---- .../siem/cypress/tasks/hosts/all_hosts.ts | 26 ++-- .../tasks/{ => hosts}/authentications.ts | 5 +- .../siem/cypress/tasks/hosts/events.ts | 59 ++++--- .../cypress/tasks/hosts/fields_browsers.ts | 12 -- .../plugins/siem/cypress/tasks/hosts/main.ts | 19 +-- .../tasks/{ => hosts}/uncommon_processes.ts | 5 +- .../plugins/siem/cypress/tasks/inspect.ts | 12 +- .../plugins/siem/cypress/tasks/login.ts | 113 +++++++++++++- .../siem/cypress/tasks/network/flows.ts | 3 +- .../tasks/{header.ts => siem_header.ts} | 23 ++- .../plugins/siem/cypress/tasks/siem_main.ts | 9 +- .../tasks/{timeline/main.ts => timeline.ts} | 82 +++++----- .../plugins/siem/cypress/urls/navigation.ts | 5 +- 61 files changed, 562 insertions(+), 1491 deletions(-) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/events_viewer => }/events_viewer.spec.ts (83%) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/fields_browser => }/fields_browser.spec.ts (87%) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/inspect => }/inspect.spec.ts (70%) delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/drag_n_drop/helpers.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/events_viewer/helpers.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/events_viewer/selectors.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/fields_browser/helpers.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/fields_browser/selectors.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/fixtures/helpers.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/hosts/helpers.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/hosts/selectors.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/inspect/helpers.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/inspect/selectors.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/login/helpers.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/login/selectors.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/ml_conditional_links/index.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/navigation/selectors.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/overview/selectors.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/pagination/selectors.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/url_state/index.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/urls/index.ts delete mode 100644 x-pack/legacy/plugins/siem/cypress/integration/lib/util/helpers.ts rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/ml_conditional_links => }/ml_conditional_links.spec.ts (93%) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/navigation => }/navigation.spec.ts (78%) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/overview => }/overview.spec.ts (74%) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/pagination => }/pagination.spec.ts (80%) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/timeline/data_providers.spec.ts => timeline_data_providers.spec.ts} (81%) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/timeline/flyout_button.spec.ts => timeline_flyout_button.spec.ts} (68%) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/timeline/search_or_filter.spec.ts => timeline_search_or_filter.spec.ts} (58%) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/timeline/toggle_column.spec.ts => timeline_toggle_column.spec.ts} (82%) rename x-pack/legacy/plugins/siem/cypress/integration/{smoke_tests/url_state => }/url_state.spec.ts (84%) rename x-pack/legacy/plugins/siem/cypress/screens/{calendar.ts => date_picker.ts} (99%) rename x-pack/legacy/plugins/siem/cypress/screens/{timeline => }/fields_browser.ts (92%) rename x-pack/legacy/plugins/siem/cypress/screens/{ => hosts}/authentications.ts (100%) delete mode 100644 x-pack/legacy/plugins/siem/cypress/screens/hosts/fields_browser.ts rename x-pack/legacy/plugins/siem/cypress/screens/{header.ts => siem_header.ts} (100%) rename x-pack/legacy/plugins/siem/cypress/screens/{timeline/main.ts => timeline.ts} (89%) delete mode 100644 x-pack/legacy/plugins/siem/cypress/screens/uncommon_processes.ts rename x-pack/legacy/plugins/siem/cypress/tasks/{calendar.ts => date_picker.ts} (70%) rename x-pack/legacy/plugins/siem/cypress/tasks/{timeline => }/fields_browser.ts (81%) rename x-pack/legacy/plugins/siem/cypress/tasks/{ => hosts}/authentications.ts (60%) delete mode 100644 x-pack/legacy/plugins/siem/cypress/tasks/hosts/fields_browsers.ts rename x-pack/legacy/plugins/siem/cypress/tasks/{ => hosts}/uncommon_processes.ts (59%) rename x-pack/legacy/plugins/siem/cypress/tasks/{header.ts => siem_header.ts} (68%) rename x-pack/legacy/plugins/siem/cypress/tasks/{timeline/main.ts => timeline.ts} (79%) diff --git a/x-pack/legacy/plugins/siem/cypress.json b/x-pack/legacy/plugins/siem/cypress.json index ae73965f8f10f..d2397e1ec90dd 100644 --- a/x-pack/legacy/plugins/siem/cypress.json +++ b/x-pack/legacy/plugins/siem/cypress.json @@ -1,5 +1,6 @@ { "baseUrl": "http://localhost:5601", + "defaultCommandTimeout": 30000, "screenshotsFolder": "../../../../target/kibana-siem/cypress/screenshots", "trashAssetsBeforeRuns": false, "video": false, diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/events_viewer/events_viewer.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/events_viewer.spec.ts similarity index 83% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/events_viewer/events_viewer.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/events_viewer.spec.ts index 7bb7b9f4da5d1..e44c8f4459ba9 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/events_viewer/events_viewer.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/events_viewer.spec.ts @@ -4,38 +4,36 @@ * you may not use this file except in compliance with the Elastic License. */ -import { filterFieldsBrowser } from '../../lib/fields_browser/helpers'; import { + FIELDS_BROWSER_CHECKBOX, FIELDS_BROWSER_CONTAINER, FIELDS_BROWSER_SELECTED_CATEGORY_TITLE, FIELDS_BROWSER_TITLE, - FIELDS_BROWSER_CHECKBOX, -} from '../../../screens/hosts/fields_browser'; -import { HOSTS_PAGE } from '../../lib/urls'; -import { loginAndWaitForPage } from '../../../tasks/login'; -import { openEventsViewerFieldsBrowser, filterSearchBar } from '../../lib/events_viewer/helpers'; -import { closeFieldsBrowser } from '../../../tasks/hosts/fields_browsers'; -import { openEvents } from '../../../tasks/hosts/main'; -import { - closeModal, - opensInspectQueryModal, - waitsForEventsToBeLoaded, - addsHostGeoCityNameToHeader, - addsHostGeoCountryNameToHeader, - resetFields, -} from '../../../tasks/hosts/events'; - +} from '../screens/fields_browser'; import { HEADER_SUBTITLE, + HOST_GEO_CITY_NAME_HEADER, + HOST_GEO_COUNTRY_NAME_HEADER, INSPECT_MODAL, LOAD_MORE, LOCAL_EVENTS_COUNT, - HOST_GEO_CITY_NAME_HEADER, - HOST_GEO_COUNTRY_NAME_HEADER, -} from '../../../screens/hosts/events'; -import { DEFAULT_TIMEOUT } from '../../lib/util/helpers'; +} from '../screens/hosts/events'; + +import { closeFieldsBrowser, filterFieldsBrowser } from '../tasks/fields_browser'; +import { loginAndWaitForPage } from '../tasks/login'; +import { openEvents } from '../tasks/hosts/main'; +import { + addsHostGeoCityNameToHeader, + addsHostGeoCountryNameToHeader, + closeModal, + openEventsViewerFieldsBrowser, + opensInspectQueryModal, + resetFields, + waitsForEventsToBeLoaded, +} from '../tasks/hosts/events'; +import { clearSearchBar, kqlSearch } from '../tasks/siem_header'; -import { clearSearchBar } from '../../../tasks/header'; +import { HOSTS_PAGE } from '../urls/navigation'; const defaultHeadersInDefaultEcsCategory = [ { id: '@timestamp' }, @@ -90,13 +88,13 @@ describe('Events Viewer', () => { after(() => { closeModal(); - cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('not.exist'); + cy.get(INSPECT_MODAL).should('not.exist'); }); it('launches the inspect query modal when the inspect button is clicked', () => { waitsForEventsToBeLoaded(); opensInspectQueryModal(); - cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('exist'); + cy.get(INSPECT_MODAL).should('exist'); }); }); @@ -147,7 +145,7 @@ describe('Events Viewer', () => { cy.get(HEADER_SUBTITLE) .invoke('text') .then(initialNumberOfEvents => { - filterSearchBar(filterInput); + kqlSearch(`${filterInput}{enter}`); cy.get(HEADER_SUBTITLE) .invoke('text') .should('not.equal', initialNumberOfEvents); diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/fields_browser/fields_browser.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/fields_browser.spec.ts similarity index 87% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/fields_browser/fields_browser.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/fields_browser.spec.ts index 6e8ef93a54016..095fc30356fd4 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/fields_browser/fields_browser.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/fields_browser.spec.ts @@ -4,38 +4,35 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HOSTS_PAGE } from '../../lib/urls'; - -import { loginAndWaitForPage, DEFAULT_TIMEOUT } from '../../../tasks/login'; - import { - FIELDS_BROWSER_TITLE, - FIELDS_BROWSER_SELECTED_CATEGORY_TITLE, - FIELDS_BROWSER_SELECTED_CATEGORY_COUNT, FIELDS_BROWSER_CATEGORIES_COUNT, - FIELDS_BROWSER_HOST_CATEGORIES_COUNT, - FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT, FIELDS_BROWSER_FIELDS_COUNT, - FIELDS_BROWSER_MESSAGE_HEADER, + FIELDS_BROWSER_HOST_CATEGORIES_COUNT, FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER, FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER, FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER, -} from '../../../screens/timeline/fields_browser'; - -import { populateTimeline, openTimelineFieldsBrowser } from '../../../tasks/timeline/main'; - -import { openTimeline } from '../../../tasks/siem_main'; + FIELDS_BROWSER_MESSAGE_HEADER, + FIELDS_BROWSER_SELECTED_CATEGORY_TITLE, + FIELDS_BROWSER_SELECTED_CATEGORY_COUNT, + FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT, + FIELDS_BROWSER_TITLE, +} from '../screens/fields_browser'; import { + addsHostGeoCityNameToTimeline, + addsHostGeoContinentNameToTimeline, + addsHostGeoCountryNameToTimelineDraggingIt, clearFieldsBrowser, - filterFieldsBrowser, closeFieldsBrowser, + filterFieldsBrowser, removesMessageField, - addsHostGeoCityNameToTimeline, - addsHostGeoCountryNameToTimelineDraggingIt, - addsHostGeoContinentNameToTimeline, resetFields, -} from '../../../tasks/timeline/fields_browser'; +} from '../tasks/fields_browser'; +import { loginAndWaitForPage } from '../tasks/login'; +import { openTimeline } from '../tasks/siem_main'; +import { openTimelineFieldsBrowser, populateTimeline } from '../tasks/timeline'; + +import { HOSTS_PAGE } from '../urls/navigation'; const defaultHeaders = [ { id: '@timestamp' }, @@ -90,7 +87,7 @@ describe('Fields Browser', () => { filterFieldsBrowser(filterInput); - cy.get(FIELDS_BROWSER_CATEGORIES_COUNT, { timeout: DEFAULT_TIMEOUT }) + cy.get(FIELDS_BROWSER_CATEGORIES_COUNT) .invoke('text') .should('eq', '2 categories'); }); @@ -106,7 +103,7 @@ describe('Fields Browser', () => { cy.get(FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT) .invoke('text') .then(systemCategoriesCount => { - cy.get(FIELDS_BROWSER_FIELDS_COUNT, { timeout: DEFAULT_TIMEOUT }) + cy.get(FIELDS_BROWSER_FIELDS_COUNT) .invoke('text') .should('eq', `${+hostCategoriesCount + +systemCategoriesCount} fields`); }); @@ -163,9 +160,7 @@ describe('Fields Browser', () => { addsHostGeoCityNameToTimeline(); closeFieldsBrowser(); - cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER, { - timeout: DEFAULT_TIMEOUT, - }).should('exist'); + cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER).should('exist'); }); it('adds a field to the timeline when the user drags and drops a field', () => { @@ -177,9 +172,7 @@ describe('Fields Browser', () => { addsHostGeoCountryNameToTimelineDraggingIt(); - cy.get(FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER, { - timeout: DEFAULT_TIMEOUT, - }).should('exist'); + cy.get(FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER).should('exist'); }); it('resets all fields in the timeline when `Reset Fields` is clicked', () => { diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/inspect/inspect.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/inspect.spec.ts similarity index 70% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/inspect/inspect.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/inspect.spec.ts index 1555470f5eee7..b6b4e7a72b8f6 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/inspect/inspect.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/inspect.spec.ts @@ -4,20 +4,22 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HOSTS_PAGE, NETWORK_PAGE } from '../../lib/urls'; import { + INSPECT_HOSTS_BUTTONS_IN_SIEM, INSPECT_MODAL, INSPECT_NETWORK_BUTTONS_IN_SIEM, - INSPECT_HOSTS_BUTTONS_IN_SIEM, -} from '../../../screens/inspect'; +} from '../screens/inspect'; + +import { closesModal, openStatsAndTables } from '../tasks/inspect'; +import { loginAndWaitForPage } from '../tasks/login'; +import { openTimeline } from '../tasks/siem_main'; import { executeTimelineKQL, - openTimelineSettings, openTimelineInspectButton, -} from '../../../tasks/timeline/main'; -import { openTimeline } from '../../../tasks/siem_main'; -import { DEFAULT_TIMEOUT, loginAndWaitForPage } from '../../../tasks/login'; -import { closesModal, openStatsAndTables } from '../../../tasks/inspect'; + openTimelineSettings, +} from '../tasks/timeline'; + +import { HOSTS_PAGE, NETWORK_PAGE } from '../urls/navigation'; describe('Inspect', () => { context('Hosts stats and tables', () => { @@ -31,7 +33,7 @@ describe('Inspect', () => { INSPECT_HOSTS_BUTTONS_IN_SIEM.forEach(table => it(`inspects the ${table.title}`, () => { openStatsAndTables(table); - cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('be.visible'); + cy.get(INSPECT_MODAL).should('be.visible'); }) ); }); @@ -47,7 +49,7 @@ describe('Inspect', () => { INSPECT_NETWORK_BUTTONS_IN_SIEM.forEach(table => it(`inspects the ${table.title}`, () => { openStatsAndTables(table); - cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('be.visible'); + cy.get(INSPECT_MODAL).should('be.visible'); }) ); }); @@ -60,7 +62,7 @@ describe('Inspect', () => { executeTimelineKQL(hostExistsQuery); openTimelineSettings(); openTimelineInspectButton(); - cy.get(INSPECT_MODAL, { timeout: DEFAULT_TIMEOUT }).should('be.visible'); + cy.get(INSPECT_MODAL).should('be.visible'); }); }); }); diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/drag_n_drop/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/drag_n_drop/helpers.ts deleted file mode 100644 index 39a61401c15b3..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/drag_n_drop/helpers.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -const primaryButton = 0; - -/** - * To overcome the React Beautiful DND sloppy click detection threshold: - * https://github.com/atlassian/react-beautiful-dnd/blob/67b96c8d04f64af6b63ae1315f74fc02b5db032b/docs/sensors/mouse.md#sloppy-clicks-and-click-prevention- - */ -const dndSloppyClickDetectionThreshold = 5; - -/** Starts dragging the subject */ -export const drag = (subject: JQuery) => { - const subjectLocation = subject[0].getBoundingClientRect(); - - cy.wrap(subject) - .trigger('mousedown', { - button: primaryButton, - clientX: subjectLocation.left, - clientY: subjectLocation.top, - force: true, - }) - .wait(1) - .trigger('mousemove', { - button: primaryButton, - clientX: subjectLocation.left + dndSloppyClickDetectionThreshold, - clientY: subjectLocation.top, - force: true, - }) - .wait(1); -}; - -/** "Drops" the subject being dragged on the specified drop target */ -export const drop = (dropTarget: JQuery) => { - cy.wrap(dropTarget) - .trigger('mousemove', { button: primaryButton, force: true }) - .wait(1) - .trigger('mouseup', { force: true }) - .wait(1); -}; - -/** Drags the subject being dragged on the specified drop target, but does not drop it */ -export const dragWithoutDrop = (dropTarget: JQuery) => { - cy.wrap(dropTarget).trigger('mousemove', 'center', { - button: primaryButton, - }); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/events_viewer/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/events_viewer/helpers.ts deleted file mode 100644 index 02a80f6c0329c..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/events_viewer/helpers.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { EVENTS_VIEWER_FIELDS_BUTTON, KQL_SEARCH_BAR } from './selectors'; -import { FIELDS_BROWSER_CONTAINER } from '../fields_browser/selectors'; -import { SERVER_SIDE_EVENT_COUNT } from '../timeline/selectors'; -import { DEFAULT_TIMEOUT } from '../util/helpers'; - -/** Opens the eventsViewer Field Browser */ -export const openEventsViewerFieldsBrowser = () => { - cy.get(EVENTS_VIEWER_FIELDS_BUTTON, { timeout: DEFAULT_TIMEOUT }).click({ force: true }); - - cy.get(SERVER_SIDE_EVENT_COUNT, { timeout: DEFAULT_TIMEOUT }) - .invoke('text') - .should('not.equal', '0'); - - cy.get(FIELDS_BROWSER_CONTAINER).should('exist'); -}; - -/** Clicks an arbitrary UI element that's not part of the fields browser (to dismiss it) */ -export const clickOutsideFieldsBrowser = () => { - cy.get(KQL_SEARCH_BAR, { timeout: DEFAULT_TIMEOUT }).click(); -}; - -/** Filters the search bar at the top of most pages with the specified KQL */ -export const filterSearchBar = (kql: string) => { - cy.get(KQL_SEARCH_BAR).type(`${kql} {enter}`); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/events_viewer/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/events_viewer/selectors.ts deleted file mode 100644 index 6f7906d7fd791..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/events_viewer/selectors.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/** The panel containing the events viewer */ -export const EVENTS_VIEWER_PANEL = '[data-test-subj="events-viewer-panel"]'; - -/** Clicking this button in the timeline opens the Fields browser in the Events Viewer */ -export const EVENTS_VIEWER_FIELDS_BUTTON = `${EVENTS_VIEWER_PANEL} [data-test-subj="show-field-browser-gear"]`; - -/** The KQL search bar that exists at the top of most pages */ -export const KQL_SEARCH_BAR = '[data-test-subj="queryInput"]'; - -/** The Events Viewer Showing N events header subtitle */ -export const HEADER_SUBTITLE = `${EVENTS_VIEWER_PANEL} [data-test-subj="header-panel-subtitle"]`; - -/** The inspect query modal */ -export const INSPECT_MODAL = '[data-test-subj="modal-inspect-euiModal"]'; - -export const CLOSE_MODAL = '[data-test-subj="modal-inspect-close"]'; - -/** The inspect query button that launches the inspect query modal */ -export const INSPECT_QUERY = `${EVENTS_VIEWER_PANEL} [data-test-subj="inspect-icon-button"]`; - -/** A count of the events loaded in the table */ -export const LOCAL_EVENTS_COUNT = `${EVENTS_VIEWER_PANEL} [data-test-subj="local-events-count"]`; - -/** The events viewer Load More button */ -export const LOAD_MORE = `${EVENTS_VIEWER_PANEL} [data-test-subj="TimelineMoreButton"]`; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/fields_browser/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/fields_browser/helpers.ts deleted file mode 100644 index b02eda513cba3..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/fields_browser/helpers.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { FIELDS_BROWSER_CONTAINER, FIELDS_BROWSER_FILTER_INPUT } from './selectors'; -import { - assertAtLeastOneEventMatchesSearch, - executeKQL, - hostExistsQuery, - toggleTimelineVisibility, -} from '../timeline/helpers'; -import { TIMELINE_DATA_PROVIDERS, TIMELINE_FIELDS_BUTTON } from '../timeline/selectors'; - -/** Opens the timeline's Field Browser */ -export const openTimelineFieldsBrowser = () => { - cy.get(TIMELINE_FIELDS_BUTTON).click({ force: true }); - - cy.get(FIELDS_BROWSER_CONTAINER).should('exist'); -}; - -/** Populates the timeline with a host from the hosts page */ -export const populateTimeline = () => { - toggleTimelineVisibility(); - - executeKQL(hostExistsQuery); - - assertAtLeastOneEventMatchesSearch(); -}; - -/** Clicks an arbitrary UI element that's not part of the fields browser (to dismiss it) */ -export const clickOutsideFieldsBrowser = () => { - cy.get(TIMELINE_DATA_PROVIDERS).click(); -}; - -/** Filters the Field Browser by typing `fieldName` in the input */ -export const filterFieldsBrowser = (fieldName: string) => { - cy.get(FIELDS_BROWSER_FILTER_INPUT).type(fieldName); -}; - -export const clearFieldsBrowser = () => { - cy.get(FIELDS_BROWSER_FILTER_INPUT).type('{selectall}{backspace}'); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/fields_browser/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/fields_browser/selectors.ts deleted file mode 100644 index 039e38aaf3ee7..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/fields_browser/selectors.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/** Clicking this button in the timeline opens the Fields browser */ -export const TIMELINE_FIELDS_BUTTON = - '[data-test-subj="timeline"] [data-test-subj="show-field-browser"]'; - -/** The title displayed in the fields browser (i.e. Customize Columns) */ -export const FIELDS_BROWSER_TITLE = '[data-test-subj="field-browser-title"]'; - -/** Contains the body of the fields browser */ -export const FIELDS_BROWSER_CONTAINER = '[data-test-subj="fields-browser-container"]'; - -/** The title of the selected category in the right-hand side of the fields browser */ -export const FIELDS_BROWSER_SELECTED_CATEGORY_TITLE = '[data-test-subj="selected-category-title"]'; - -/** A count of the fields in the selected category in the right-hand side of the fields browser */ -export const FIELDS_BROWSER_SELECTED_CATEGORY_COUNT = - '[data-test-subj="selected-category-count-badge"]'; - -/** Typing in this input filters the Field Browser */ -export const FIELDS_BROWSER_FILTER_INPUT = '[data-test-subj="field-search"]'; - -/** - * This label displays a count of the categories containing (one or more) - * fields that match the filter criteria - */ -export const FIELDS_BROWSER_CATEGORIES_COUNT = '[data-test-subj="categories-count"]'; - -export const FIELDS_BROWSER_HOST_CATEGORIES_COUNT = '[data-test-subj="host-category-count"]'; - -export const FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT = '[data-test-subj="system-category-count"]'; - -/** - * This label displays a count of the fields that match the filter criteria - */ -export const FIELDS_BROWSER_FIELDS_COUNT = '[data-test-subj="fields-count"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/fixtures/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/fixtures/helpers.ts deleted file mode 100644 index e66199e0419ec..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/fixtures/helpers.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// Cypress workaround to hijack XHR -// https://github.com/cypress-io/cypress/issues/687 -export const clearFetch = () => - cy.on('window:before:load', win => { - // @ts-ignore no null, this is a temp hack see issue above - win.fetch = null; - }); - -export const stubApi = (dataFileName: string) => { - cy.server(); - cy.fixture(dataFileName).as(`${dataFileName}JSON`); - cy.route('POST', 'api/siem/graphql', `@${dataFileName}JSON`); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/hosts/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/hosts/helpers.ts deleted file mode 100644 index 8f4efbe0c09c2..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/hosts/helpers.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { DEFAULT_TIMEOUT } from '../util/helpers'; - -import { ALL_HOSTS_WIDGET, EVENTS_TAB_BUTTON } from './selectors'; - -/** Wait for the for the `All Hosts` widget on the `Hosts` page to load */ -export const waitForAllHostsWidget = () => cy.get(ALL_HOSTS_WIDGET, { timeout: DEFAULT_TIMEOUT }); - -/** Clicks the Events tab on the hosts page */ -export const clickEventsTab = () => - cy.get(EVENTS_TAB_BUTTON, { timeout: DEFAULT_TIMEOUT }).click({ force: true }); diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/hosts/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/hosts/selectors.ts deleted file mode 100644 index ab2502676d6f7..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/hosts/selectors.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/** The `All Hosts` widget on the `Hosts` page */ -export const ALL_HOSTS_WIDGET = '[data-test-subj="table-allHosts-loading-false"]'; - -/** A single draggable host in the `All Hosts` widget on the `Hosts` page */ -export const ALL_HOSTS_WIDGET_HOST = '[data-test-subj="draggable-content-host.name"]'; - -/** All the draggable hosts in the `All Hosts` widget on the `Hosts` page */ -export const ALL_HOSTS_WIDGET_DRAGGABLE_HOSTS = `${ALL_HOSTS_WIDGET} ${ALL_HOSTS_WIDGET_HOST}`; - -/** Clicking this button displays the `Events` tab */ -export const EVENTS_TAB_BUTTON = '[data-test-subj="navigation-events"]'; - -export const NAVIGATION_HOSTS_ALL_HOSTS = '[data-test-subj="navigation-allHosts"]'; - -export const NAVIGATION_HOSTS_ANOMALIES = '[data-test-subj="navigation-anomalies"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/inspect/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/inspect/helpers.ts deleted file mode 100644 index c431d0551b29a..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/inspect/helpers.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { DEFAULT_TIMEOUT } from '../util/helpers'; - -import { INSPECT_BUTTON_ICON, InspectButtonMetadata } from './selectors'; - -export const openStatsAndTables = (table: InspectButtonMetadata) => { - if (table.tabId) { - cy.get(table.tabId).click({ force: true }); - } - cy.get(table.id, { timeout: DEFAULT_TIMEOUT }); - if (table.altInspectId) { - cy.get(table.altInspectId, { timeout: DEFAULT_TIMEOUT }).trigger('click', { - force: true, - }); - } else { - cy.get(`${table.id} ${INSPECT_BUTTON_ICON}`, { - timeout: DEFAULT_TIMEOUT, - }).trigger('click', { force: true }); - } -}; - -export const closesModal = () => { - cy.get('[data-test-subj="modal-inspect-close"]', { timeout: DEFAULT_TIMEOUT }).click(); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/inspect/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/inspect/selectors.ts deleted file mode 100644 index a6d4b37be9f00..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/inspect/selectors.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const INSPECT_BUTTON_ICON = '[data-test-subj="inspect-icon-button"]'; -export const INSPECT_MODAL = '[data-test-subj="modal-inspect-euiModal"]'; -export const TIMELINE_SETTINGS_ICON = '[data-test-subj="settings-gear"]'; -export const TIMELINE_INSPECT_BUTTON = '[data-test-subj="inspect-empty-button"]'; - -export interface InspectButtonMetadata { - altInspectId?: string; - id: string; - title: string; - tabId?: string; -} - -export const INSPECT_HOSTS_BUTTONS_IN_SIEM: InspectButtonMetadata[] = [ - { - id: '[data-test-subj="stat-hosts"]', - title: 'Hosts Stat', - }, - { - id: '[data-test-subj="stat-authentication"]', - title: 'User Authentications Stat', - }, - { - id: '[data-test-subj="stat-uniqueIps"]', - title: 'Unique IPs Stat', - }, - { - id: '[data-test-subj="table-allHosts-loading-false"]', - title: 'All Hosts Table', - tabId: '[data-test-subj="navigation-allHosts"]', - }, - { - id: '[data-test-subj="table-authentications-loading-false"]', - title: 'Authentications Table', - tabId: '[data-test-subj="navigation-authentications"]', - }, - { - id: '[data-test-subj="table-uncommonProcesses-loading-false"]', - title: 'Uncommon processes Table', - tabId: '[data-test-subj="navigation-uncommonProcesses"]', - }, - { - altInspectId: `[data-test-subj="events-viewer-panel"] ${INSPECT_BUTTON_ICON}`, - id: '[data-test-subj="events-container-loading-false"]', - title: 'Events Table', - tabId: '[data-test-subj="navigation-events"]', - }, -]; - -export const INSPECT_NETWORK_BUTTONS_IN_SIEM: InspectButtonMetadata[] = [ - { - id: '[data-test-subj="stat-networkEvents"]', - title: 'Network events Stat', - }, - { - id: '[data-test-subj="stat-dnsQueries"]', - title: 'DNS queries Stat', - }, - { - id: '[data-test-subj="stat-uniqueFlowId"]', - title: 'Unique flow IDs Stat', - }, - { - id: '[data-test-subj="stat-tlsHandshakes"]', - title: 'TLS handshakes Stat', - }, - { - id: '[data-test-subj="stat-UniqueIps"]', - title: 'Unique private IPs Stat', - }, - { - id: '[data-test-subj="table-topNFlowSource-loading-false"]', - title: 'Source IPs Table', - }, - { - id: '[data-test-subj="table-topNFlowDestination-loading-false"]', - title: 'Destination IPs Table', - }, - { - id: '[data-test-subj="table-dns-loading-false"]', - title: 'Top DNS Domains Table', - tabId: '[data-test-subj="navigation-dns"]', - }, -]; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/login/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/login/helpers.ts deleted file mode 100644 index b2b8ce7b9c000..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/login/helpers.ts +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import * as yaml from 'js-yaml'; - -/** - * Credentials in the `kibana.dev.yml` config file will be used to authenticate - * with Kibana when credentials are not provided via environment variables - */ -const KIBANA_DEV_YML_PATH = '../../../../config/kibana.dev.yml'; - -/** - * The configuration path in `kibana.dev.yml` to the username to be used when - * authenticating with Kibana. - */ -const ELASTICSEARCH_USERNAME_CONFIG_PATH = 'config.elasticsearch.username'; - -/** - * The configuration path in `kibana.dev.yml` to the password to be used when - * authenticating with Kibana. - */ -const ELASTICSEARCH_PASSWORD_CONFIG_PATH = 'config.elasticsearch.password'; - -/** - * The `CYPRESS_ELASTICSEARCH_USERNAME` environment variable specifies the - * username to be used when authenticating with Kibana - */ -const ELASTICSEARCH_USERNAME = 'ELASTICSEARCH_USERNAME'; - -/** - * The `CYPRESS_ELASTICSEARCH_PASSWORD` environment variable specifies the - * username to be used when authenticating with Kibana - */ -const ELASTICSEARCH_PASSWORD = 'ELASTICSEARCH_PASSWORD'; - -/** - * The Kibana server endpoint used for authentication - */ -const LOGIN_API_ENDPOINT = '/internal/security/login'; - -/** - * Authenticates with Kibana using, if specified, credentials specified by - * environment variables. The credentials in `kibana.dev.yml` will be used - * for authentication when the environment variables are unset. - * - * To speed the execution of tests, prefer this non-interactive authentication, - * which is faster than authentication via Kibana's interactive login page. - */ -export const login = () => { - if (credentialsProvidedByEnvironment()) { - loginViaEnvironmentCredentials(); - } else { - loginViaConfig(); - } -}; - -/** - * Returns `true` if the credentials used to login to Kibana are provided - * via environment variables - */ -const credentialsProvidedByEnvironment = (): boolean => - Cypress.env(ELASTICSEARCH_USERNAME) != null && Cypress.env(ELASTICSEARCH_PASSWORD) != null; - -/** - * Authenticates with Kibana by reading credentials from the - * `CYPRESS_ELASTICSEARCH_USERNAME` and `CYPRESS_ELASTICSEARCH_PASSWORD` - * environment variables, and POSTing the username and password directly to - * Kibana's `/internal/security/login` endpoint, bypassing the login page (for speed). - */ -const loginViaEnvironmentCredentials = () => { - cy.log( - `Authenticating via environment credentials from the \`CYPRESS_${ELASTICSEARCH_USERNAME}\` and \`CYPRESS_${ELASTICSEARCH_PASSWORD}\` environment variables` - ); - - // programmatically authenticate without interacting with the Kibana login page - cy.request({ - body: { - username: Cypress.env(ELASTICSEARCH_USERNAME), - password: Cypress.env(ELASTICSEARCH_PASSWORD), - }, - headers: { 'kbn-xsrf': 'cypress-creds-via-env' }, - method: 'POST', - url: `${Cypress.config().baseUrl}${LOGIN_API_ENDPOINT}`, - }); -}; - -/** - * Authenticates with Kibana by reading credentials from the - * `kibana.dev.yml` file and POSTing the username and password directly to - * Kibana's `/internal/security/login` endpoint, bypassing the login page (for speed). - */ -const loginViaConfig = () => { - cy.log( - `Authenticating via config credentials \`${ELASTICSEARCH_USERNAME_CONFIG_PATH}\` and \`${ELASTICSEARCH_PASSWORD_CONFIG_PATH}\` from \`${KIBANA_DEV_YML_PATH}\`` - ); - - // read the login details from `kibana.dev.yaml` - cy.readFile(KIBANA_DEV_YML_PATH).then(kibanaDevYml => { - const config = yaml.safeLoad(kibanaDevYml); - - // programmatically authenticate without interacting with the Kibana login page - cy.request({ - body: { - username: config.elasticsearch.username, - password: config.elasticsearch.password, - }, - headers: { 'kbn-xsrf': 'cypress-creds-via-config' }, - method: 'POST', - url: `${Cypress.config().baseUrl}${LOGIN_API_ENDPOINT}`, - }); - }); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/login/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/login/selectors.ts deleted file mode 100644 index ac028fa91216c..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/login/selectors.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/** The Username field in the Kibana login page */ -export const USERNAME = '[data-test-subj="loginUsername"]'; - -/** The Password field in the Kibana login page */ -export const PASSWORD = '[data-test-subj="loginPassword"]'; - -/** The `Default` space button on the `Select your space` page */ -export const DEFAULT_SPACE_BUTTON = '[data-test-subj="space-card-default"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/ml_conditional_links/index.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/ml_conditional_links/index.ts deleted file mode 100644 index 655418fc98bf8..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/ml_conditional_links/index.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* - * These links are for different test scenarios that try and capture different drill downs into - * ml-network and ml-hosts and are of the flavor of testing: - * A filter being null: (query:!n) - * A filter being set with single values: query=(query:%27process.name%20:%20%22conhost.exe%22%27,language:kuery) - * A filter being set with multiple values: query=(query:%27process.name%20:%20%22conhost.exe,sc.exe%22%27,language:kuery) - * A filter containing variables not replaced: query=(query:%27process.name%20:%20%$process.name$%22%27,language:kuery) - * - * In different combination with: - * network not being set: $ip$ - * host not being set: $host.name$ - * ...or... - * network being set normally: 127.0.0.1 - * host being set normally: suricata-iowa - * ...or... - * network having multiple values: 127.0.0.1,127.0.0.2 - * host having multiple values: suricata-iowa,siem-windows - */ - -// Single IP with a null for the Query: -export const mlNetworkSingleIpNullKqlQuery = - "/app/siem#/ml-network/ip/127.0.0.1?query=!n&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))"; - -// Single IP with a value for the Query: -export const mlNetworkSingleIpKqlQuery = - "/app/siem#/ml-network/ip/127.0.0.1?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))"; - -// Multiple IPs with a null for the Query: -export const mlNetworkMultipleIpNullKqlQuery = - "/app/siem#/ml-network/ip/127.0.0.1,127.0.0.2?query=!n&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))"; - -// Multiple IPs with a value for the Query: -export const mlNetworkMultipleIpKqlQuery = - "/app/siem#/ml-network/ip/127.0.0.1,127.0.0.2?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))"; - -// $ip$ with a null Query: -export const mlNetworkNullKqlQuery = - "/app/siem#/ml-network/ip/$ip$?query=!n&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))"; - -// $ip$ with a value for the Query: -export const mlNetworkKqlQuery = - "/app/siem#/ml-network/ip/$ip$?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-08-28T11:00:00.000Z',kind:absolute,to:'2019-08-28T13:59:59.999Z')))"; - -// Single host name with a null for the Query: -export const mlHostSingleHostNullKqlQuery = - "/app/siem#/ml-hosts/siem-windows?query=!n&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))"; - -// Single host name with a variable in the Query: -export const mlHostSingleHostKqlQueryVariable = - "/app/siem#/ml-hosts/siem-windows?query=(language:kuery,query:'process.name%20:%20%22$process.name$%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))"; - -// Single host name with a value for Query: -export const mlHostSingleHostKqlQuery = - "/app/siem#/ml-hosts/siem-windows?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))"; - -// Multiple host names with null for Query: -export const mlHostMultiHostNullKqlQuery = - "/app/siem#/ml-hosts/siem-windows,siem-suricata?query=!n&&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))"; - -// Multiple host names with a value for Query: -export const mlHostMultiHostKqlQuery = - "/app/siem#/ml-hosts/siem-windows,siem-suricata?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))"; - -// Undefined/null host name with a null for the KQL: -export const mlHostVariableHostNullKqlQuery = - "/app/siem#/ml-hosts/$host.name$?query=!n&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))"; - -// Undefined/null host name but with a value for Query: -export const mlHostVariableHostKqlQuery = - "/app/siem#/ml-hosts/$host.name$?query=(language:kuery,query:'process.name%20:%20%22conhost.exe,sc.exe%22')&timerange=(global:(linkTo:!(timeline),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')),timeline:(linkTo:!(global),timerange:(from:'2019-06-06T06:00:00.000Z',kind:absolute,to:'2019-06-07T05:59:59.999Z')))"; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/navigation/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/navigation/selectors.ts deleted file mode 100644 index 0d5f40ae53966..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/navigation/selectors.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/** Top-level (global) navigation link to the `Hosts` page */ -export const NAVIGATION_HOSTS = '[data-test-subj="navigation-hosts"]'; - -/** Top-level (global) navigation link to the `Network` page */ -export const NAVIGATION_NETWORK = '[data-test-subj="navigation-network"]'; - -/** Top-level (global) navigation link to the `Overview` page */ -export const NAVIGATION_OVERVIEW = '[data-test-subj="navigation-overview"]'; - -/** Top-level (global) navigation link to the `Timelines` page */ -export const NAVIGATION_TIMELINES = '[data-test-subj="navigation-timelines"]'; - -export const HOSTS_PAGE_TABS = { - allHosts: '[data-test-subj="navigation-allHosts"]', - anomalies: '[data-test-subj="navigation-anomalies"]', - authentications: '[data-test-subj="navigation-authentications"]', - events: '[data-test-subj="navigation-events"]', - uncommonProcesses: '[data-test-subj="navigation-uncommonProcesses"]', -}; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/overview/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/overview/selectors.ts deleted file mode 100644 index 95facc8974400..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/overview/selectors.ts +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// Host Stats -export const STAT_AUDITD = { - value: '123', - domId: '[data-test-subj="host-stat-auditbeatAuditd"]', -}; -export const ENDGAME_DNS = { - value: '391', - domId: '[data-test-subj="host-stat-endgameDns"]', -}; -export const ENDGAME_FILE = { - value: '392', - domId: '[data-test-subj="host-stat-endgameFile"]', -}; -export const ENDGAME_IMAGE_LOAD = { - value: '393', - domId: '[data-test-subj="host-stat-endgameImageLoad"]', -}; -export const ENDGAME_NETWORK = { - value: '394', - domId: '[data-test-subj="host-stat-endgameNetwork"]', -}; -export const ENDGAME_PROCESS = { - value: '395', - domId: '[data-test-subj="host-stat-endgameProcess"]', -}; -export const ENDGAME_REGISTRY = { - value: '396', - domId: '[data-test-subj="host-stat-endgameRegistry"]', -}; -export const ENDGAME_SECURITY = { - value: '397', - domId: '[data-test-subj="host-stat-endgameSecurity"]', -}; -export const STAT_FILEBEAT = { - value: '890', - domId: '[data-test-subj="host-stat-filebeatSystemModule"]', -}; -export const STAT_FIM = { - value: '345', - domId: '[data-test-subj="host-stat-auditbeatFIM"]', -}; -export const STAT_LOGIN = { - value: '456', - domId: '[data-test-subj="host-stat-auditbeatLogin"]', -}; -export const STAT_PACKAGE = { - value: '567', - domId: '[data-test-subj="host-stat-auditbeatPackage"]', -}; -export const STAT_PROCESS = { - value: '678', - domId: '[data-test-subj="host-stat-auditbeatProcess"]', -}; -export const STAT_USER = { - value: '789', - domId: '[data-test-subj="host-stat-auditbeatUser"]', -}; -export const STAT_WINLOGBEAT_SECURITY = { - value: '70', - domId: '[data-test-subj="host-stat-winlogbeatSecurity"]', -}; -export const STAT_WINLOGBEAT_MWSYSMON_OPERATIONAL = { - value: '30', - domId: '[data-test-subj="host-stat-winlogbeatMWSysmonOperational"]', -}; - -export const HOST_STATS = [ - STAT_AUDITD, - ENDGAME_DNS, - ENDGAME_FILE, - ENDGAME_IMAGE_LOAD, - ENDGAME_NETWORK, - ENDGAME_PROCESS, - ENDGAME_REGISTRY, - ENDGAME_SECURITY, - STAT_FILEBEAT, - STAT_FIM, - STAT_LOGIN, - STAT_PACKAGE, - STAT_PROCESS, - STAT_USER, - STAT_WINLOGBEAT_SECURITY, - STAT_WINLOGBEAT_MWSYSMON_OPERATIONAL, -]; - -// Network Stats -export const STAT_SOCKET = { - value: '578,502', - domId: '[data-test-subj="network-stat-auditbeatSocket"]', -}; -export const STAT_CISCO = { - value: '999', - domId: '[data-test-subj="network-stat-filebeatCisco"]', -}; -export const STAT_NETFLOW = { - value: '2,544', - domId: '[data-test-subj="network-stat-filebeatNetflow"]', -}; -export const STAT_PANW = { - value: '678', - domId: '[data-test-subj="network-stat-filebeatPanw"]', -}; -export const STAT_SURICATA = { - value: '303,699', - domId: '[data-test-subj="network-stat-filebeatSuricata"]', -}; -export const STAT_ZEEK = { - value: '71,129', - domId: '[data-test-subj="network-stat-filebeatZeek"]', -}; -export const STAT_DNS = { - value: '1,090', - domId: '[data-test-subj="network-stat-packetbeatDNS"]', -}; -export const STAT_FLOW = { - value: '722,153', - domId: '[data-test-subj="network-stat-packetbeatFlow"]', -}; -export const STAT_TLS = { - value: '340', - domId: '[data-test-subj="network-stat-packetbeatTLS"]', -}; - -export const NETWORK_STATS = [ - STAT_SOCKET, - STAT_CISCO, - STAT_NETFLOW, - STAT_PANW, - STAT_SURICATA, - STAT_ZEEK, - STAT_DNS, - STAT_FLOW, - STAT_TLS, -]; - -export const OVERVIEW_HOST_STATS = '[data-test-subj="overview-hosts-stats"]'; - -export const OVERVIEW_NETWORK_STATS = '[data-test-subj="overview-network-stats"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/pagination/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/pagination/selectors.ts deleted file mode 100644 index 8e05f3e54568e..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/pagination/selectors.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const AUTHENTICATIONS_TABLE = '[data-test-subj="table-authentications-loading-false"]'; -export const getDraggableField = (field: string) => `[data-test-subj="draggable-content-${field}"]`; -export const getPageButtonSelector = (num: number) => `[data-test-subj="pagination-button-${num}"]`; -export const NAVIGATION_AUTHENTICATIONS = '[data-test-subj="navigation-authentications"]'; -export const NAVIGATION_UNCOMMON_PROCESSES = '[data-test-subj="navigation-uncommonProcesses"]'; -export const NUMBERED_PAGINATION = '[data-test-subj="numberedPagination"]'; -export const SUPER_DATE_PICKER_APPLY_BUTTON = '[data-test-subj="superDatePickerApplyTimeButton"]'; -export const UNCOMMON_PROCCESSES_TABLE = '[data-test-subj="table-uncommonProcesses-loading-false"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts deleted file mode 100644 index ef2c19bd7e737..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/helpers.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { drag, drop } from '../drag_n_drop/helpers'; -import { ALL_HOSTS_WIDGET_DRAGGABLE_HOSTS } from '../hosts/selectors'; -import { - CLOSE_TIMELINE_BTN, - CREATE_NEW_TIMELINE, - SEARCH_OR_FILTER_CONTAINER, - SERVER_SIDE_EVENT_COUNT, - TIMELINE_DATA_PROVIDERS, - TIMELINE_SETTINGS, - TIMELINE_TOGGLE_BUTTON, - TOGGLE_TIMELINE_EXPAND_EVENT, -} from './selectors'; -import { DEFAULT_TIMEOUT } from '../util/helpers'; - -/** Toggles the timeline's open / closed state by clicking the `T I M E L I N E` button */ -export const toggleTimelineVisibility = () => - cy.get(TIMELINE_TOGGLE_BUTTON, { timeout: DEFAULT_TIMEOUT }).click(); - -export const createNewTimeline = () => { - cy.get(TIMELINE_SETTINGS).click(); - cy.get(CREATE_NEW_TIMELINE).click(); - cy.get(CLOSE_TIMELINE_BTN).click({ force: true }); -}; - -/** Drags and drops a host from the `All Hosts` widget on the `Hosts` page to the timeline */ -export const dragFromAllHostsToTimeline = () => { - cy.get(ALL_HOSTS_WIDGET_DRAGGABLE_HOSTS) - .first() - .then(host => drag(host)); - cy.get(TIMELINE_DATA_PROVIDERS).then(dataProvidersDropArea => drop(dataProvidersDropArea)); -}; - -/** Executes the specified KQL query in the timeline */ -export const executeKQL = (query: string) => { - cy.get(`${SEARCH_OR_FILTER_CONTAINER} input`).type(`${query} {enter}`); -}; - -/** A sample KQL query that finds any documents where the `host.name` field exists */ -export const hostExistsQuery = 'host.name: *'; - -/** Asserts that at least one event matches the timeline's search criteria */ -export const assertAtLeastOneEventMatchesSearch = () => - cy - .get(SERVER_SIDE_EVENT_COUNT, { timeout: DEFAULT_TIMEOUT }) - .invoke('text') - .should('be.above', 0); - -/** Toggles open or closed the first event in the timeline */ -export const toggleFirstTimelineEventDetails = () => { - cy.get(TOGGLE_TIMELINE_EXPAND_EVENT, { timeout: DEFAULT_TIMEOUT }) - .first() - .click({ force: true }); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts deleted file mode 100644 index 5515c1f7d58e2..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/timeline/selectors.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/** A data provider rendered in the timeline's data providers drop area */ -export const DATA_PROVIDER = '[data-test-subj="providerContainer"]'; - -export const TIMELINE_FIELDS_BUTTON = - '[data-test-subj="timeline"] [data-test-subj="show-field-browser"]'; - -/** Data providers are dropped and rendered in this area of the timeline */ -export const TIMELINE_DATA_PROVIDERS = '[data-test-subj="dataProviders"]'; - -/** The empty data providers area when no data providers have been added to the timeline */ -export const TIMELINE_DATA_PROVIDERS_EMPTY = - '[data-test-subj="dataProviders"] [data-test-subj="empty"]'; - -/** Data providers that were dropped on a timeline */ -export const TIMELINE_DROPPED_DATA_PROVIDERS = `${TIMELINE_DATA_PROVIDERS} ${DATA_PROVIDER}`; - -/** The `Timeline ^` button that toggles visibility of the Timeline */ -export const TIMELINE_TOGGLE_BUTTON = '[data-test-subj="flyoutOverlay"]'; - -/** The flyout button shown when a data provider is not ready to be dropped on the timeline */ -export const TIMELINE_NOT_READY_TO_DROP_BUTTON = - '[data-test-subj="flyout-button-not-ready-to-drop"]'; - -/** Contains the KQL bar for searching or filtering in the timeline */ -export const SEARCH_OR_FILTER_CONTAINER = - '[data-test-subj="timeline-search-or-filter-search-container"]'; - -/** The total server-side count of the events matching the timeline's search criteria */ -export const SERVER_SIDE_EVENT_COUNT = '[data-test-subj="server-side-event-count"]'; - -/** Expands or collapses an event in the timeline */ -export const TOGGLE_TIMELINE_EXPAND_EVENT = '[data-test-subj="expand-event"]'; - -/** The body of the timeline flyout */ -export const TIMELINE_FLYOUT_BODY = '[data-test-subj="eui-flyout-body"]'; - -export const CLOSE_TIMELINE_BTN = '[data-test-subj="close-timeline"]'; - -export const TIMELINE_SETTINGS = '[data-test-subj="settings-gear"]'; - -export const CREATE_NEW_TIMELINE = '[data-test-subj="timeline-new"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/url_state/index.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/url_state/index.ts deleted file mode 100644 index fa754cd4b8db4..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/url_state/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* - * Be Careful here by using iso date and epoch date - * because the conversion might not what you expect - * for different timezone better to calculate - * them on the fly - */ - -export const ABSOLUTE_DATE_RANGE = { - url: - '/app/siem#/network/?timerange=(global:(linkTo:!(timeline),timerange:(from:1564689809186,kind:absolute,to:1564691609186)),timeline:(linkTo:!(global),timerange:(from:1564689809186,kind:absolute,to:1564691609186)))', - - urlUnlinked: - '/app/siem#/network/?timerange=(global:(linkTo:!(),timerange:(from:1564689809186,kind:absolute,to:1564691609186)),timeline:(linkTo:!(),timerange:(from:1564776209186,kind:absolute,to:1564779809186)))', - urlKqlNetworkNetwork: `/app/siem#/network/?query=(language:kuery,query:'source.ip:%20"10.142.0.9"')&timerange=(global:(linkTo:!(timeline),timerange:(from:1564689809186,kind:absolute,to:1564691609186)),timeline:(linkTo:!(global),timerange:(from:1564689809186,kind:absolute,to:1564691609186)))`, - urlKqlNetworkHosts: `/app/siem#/network/?query=(language:kuery,query:'source.ip:%20"10.142.0.9"')&timerange=(global:(linkTo:!(timeline),timerange:(from:1564689809186,kind:absolute,to:1564691609186)),timeline:(linkTo:!(global),timerange:(from:1564689809186,kind:absolute,to:1564691609186)))`, - urlKqlHostsNetwork: `/app/siem#/hosts/allHosts?query=(language:kuery,query:'source.ip:%20"10.142.0.9"')&timerange=(global:(linkTo:!(timeline),timerange:(from:1564689809186,kind:absolute,to:1564691609186)),timeline:(linkTo:!(global),timerange:(from:1564689809186,kind:absolute,to:1564691609186)))`, - urlKqlHostsHosts: `/app/siem#/hosts/allHosts?query=(language:kuery,query:'source.ip:%20"10.142.0.9"')&timerange=(global:(linkTo:!(timeline),timerange:(from:1564689809186,kind:absolute,to:1564691609186)),timeline:(linkTo:!(global),timerange:(from:1564689809186,kind:absolute,to:1564691609186)))`, - urlHost: - '/app/siem#/hosts/authentications?timerange=(global:(linkTo:!(timeline),timerange:(from:1564689809186,kind:absolute,to:1564691609186)),timeline:(linkTo:!(global),timerange:(from:1564689809186,kind:absolute,to:1564691609186)))', - urlHostNew: - '/app/siem#/hosts/authentications?timerange=(global:(linkTo:!(timeline),timerange:(from:1564689809186,kind:absolute,to:1577914409186)),timeline:(linkTo:!(global),timerange:(from:1564689809186,kind:absolute,to:1577914409186)))', -}; -export const DATE_PICKER_START_DATE_POPOVER_BUTTON = - 'div[data-test-subj="globalDatePicker"] button[data-test-subj="superDatePickerstartDatePopoverButton"]'; -export const DATE_PICKER_END_DATE_POPOVER_BUTTON = - '[data-test-subj="globalDatePicker"] [data-test-subj="superDatePickerendDatePopoverButton"]'; -export const DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE = - '[data-test-subj="timeline-properties"] [data-test-subj="superDatePickerstartDatePopoverButton"]'; -export const DATE_PICKER_END_DATE_POPOVER_BUTTON_TIMELINE = - '[data-test-subj="timeline-properties"] [data-test-subj="superDatePickerendDatePopoverButton"]'; -export const DATE_PICKER_ABSOLUTE_TAB = '[data-test-subj="superDatePickerAbsoluteTab"]'; -export const DATE_PICKER_APPLY_BUTTON = - '[data-test-subj="globalDatePicker"] button[data-test-subj="querySubmitButton"]'; -export const DATE_PICKER_APPLY_BUTTON_TIMELINE = - '[data-test-subj="timeline-properties"] button[data-test-subj="superDatePickerApplyTimeButton"]'; -export const DATE_PICKER_ABSOLUTE_INPUT = '[data-test-subj="superDatePickerAbsoluteDateInput"]'; -export const KQL_INPUT = '[data-test-subj="queryInput"]'; -export const TIMELINE_TITLE = '[data-test-subj="timeline-title"]'; - -export const HOST_DETAIL_SIEM_KIBANA = '[data-test-subj="table-allHosts-loading-false"] a.euiLink'; -export const BREADCRUMBS = '[data-test-subj="breadcrumbs"] a'; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/urls/index.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/urls/index.ts deleted file mode 100644 index 18276580289c7..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/urls/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/** The SIEM app's Hosts page */ -export const HOSTS_PAGE = '/app/siem#/hosts/allHosts'; -export const HOSTS_PAGE_TAB_URLS = { - allHosts: '/app/siem#/hosts/allHosts', - anomalies: '/app/siem#/hosts/anomalies', - authentications: '/app/siem#/hosts/authentications', - events: '/app/siem#/hosts/events', - uncommonProcesses: '/app/siem#/hosts/uncommonProcesses', -}; - -/** Kibana's login page */ -export const LOGIN_PAGE = '/login'; - -/** The SIEM app's Network page */ -export const NETWORK_PAGE = '/app/siem#/network'; -export const NETWORK_TAB_URLS = { - dns: `${NETWORK_PAGE}/dns`, -}; - -/** The SIEM app's Overview page */ -export const OVERVIEW_PAGE = '/app/siem#/overview'; - -/** The SIEM app's Timelines page */ -export const TIMELINES_PAGE = '/app/siem#/timelines'; - -/** Visit this URL to logout of Kibana */ -export const LOGOUT = '/logout'; diff --git a/x-pack/legacy/plugins/siem/cypress/integration/lib/util/helpers.ts b/x-pack/legacy/plugins/siem/cypress/integration/lib/util/helpers.ts deleted file mode 100644 index 4f96430bb381e..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/integration/lib/util/helpers.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { login } from '../login/helpers'; - -/** The default time in ms to wait for a Cypress command to complete */ -export const DEFAULT_TIMEOUT = 30 * 1000; - -/** - * Authenticates with Kibana, visits the specified `url`, and waits for the - * Kibana logo to be displayed before continuing - */ -export const loginAndWaitForPage = (url: string) => { - login(); - - cy.visit(`${Cypress.config().baseUrl}${url}`); - - cy.viewport('macbook-15'); - - cy.contains('a', 'SIEM', { timeout: DEFAULT_TIMEOUT }); -}; - -export const waitForTableLoad = (dataTestSubj: string) => - cy.get(dataTestSubj, { timeout: DEFAULT_TIMEOUT }); diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/ml_conditional_links/ml_conditional_links.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/ml_conditional_links.spec.ts similarity index 93% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/ml_conditional_links/ml_conditional_links.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/ml_conditional_links.spec.ts index fabd86cf51f91..b02ed1a5e4c94 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/ml_conditional_links/ml_conditional_links.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/ml_conditional_links.spec.ts @@ -4,28 +4,30 @@ * you may not use this file except in compliance with the Elastic License. */ +import { KQL_INPUT } from '../screens/siem_header'; + +import { loginAndWaitForPage } from '../tasks/login'; + import { - mlNetworkSingleIpNullKqlQuery, - mlNetworkSingleIpKqlQuery, - mlNetworkMultipleIpNullKqlQuery, - mlNetworkMultipleIpKqlQuery, - mlNetworkNullKqlQuery, - mlNetworkKqlQuery, - mlHostSingleHostNullKqlQuery, - mlHostSingleHostKqlQueryVariable, - mlHostSingleHostKqlQuery, - mlHostMultiHostNullKqlQuery, mlHostMultiHostKqlQuery, - mlHostVariableHostNullKqlQuery, + mlHostMultiHostNullKqlQuery, + mlHostSingleHostKqlQuery, + mlHostSingleHostKqlQueryVariable, + mlHostSingleHostNullKqlQuery, mlHostVariableHostKqlQuery, -} from '../../../urls/ml_conditional_links'; -import { loginAndWaitForPage, DEFAULT_TIMEOUT } from '../../../tasks/login'; -import { KQL_INPUT } from '../../../screens/header'; + mlHostVariableHostNullKqlQuery, + mlNetworkKqlQuery, + mlNetworkMultipleIpKqlQuery, + mlNetworkMultipleIpNullKqlQuery, + mlNetworkNullKqlQuery, + mlNetworkSingleIpKqlQuery, + mlNetworkSingleIpNullKqlQuery, +} from '../urls/ml_conditional_links'; describe('ml conditional links', () => { it('sets the KQL from a single IP with a value for the query', () => { loginAndWaitForPage(mlNetworkSingleIpKqlQuery); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( + cy.get(KQL_INPUT).should( 'have.attr', 'value', '(process.name: "conhost.exe" or process.name: "sc.exe")' @@ -34,7 +36,7 @@ describe('ml conditional links', () => { it('sets the KQL from a multiple IPs with a null for the query', () => { loginAndWaitForPage(mlNetworkMultipleIpNullKqlQuery); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( + cy.get(KQL_INPUT).should( 'have.attr', 'value', '((source.ip: "127.0.0.1" or destination.ip: "127.0.0.1") or (source.ip: "127.0.0.2" or destination.ip: "127.0.0.2"))' @@ -43,7 +45,7 @@ describe('ml conditional links', () => { it('sets the KQL from a multiple IPs with a value for the query', () => { loginAndWaitForPage(mlNetworkMultipleIpKqlQuery); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( + cy.get(KQL_INPUT).should( 'have.attr', 'value', '((source.ip: "127.0.0.1" or destination.ip: "127.0.0.1") or (source.ip: "127.0.0.2" or destination.ip: "127.0.0.2")) and ((process.name: "conhost.exe" or process.name: "sc.exe"))' @@ -52,7 +54,7 @@ describe('ml conditional links', () => { it('sets the KQL from a $ip$ with a value for the query', () => { loginAndWaitForPage(mlNetworkKqlQuery); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( + cy.get(KQL_INPUT).should( 'have.attr', 'value', '(process.name: "conhost.exe" or process.name: "sc.exe")' @@ -61,7 +63,7 @@ describe('ml conditional links', () => { it('sets the KQL from a single host name with a value for query', () => { loginAndWaitForPage(mlHostSingleHostKqlQuery); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( + cy.get(KQL_INPUT).should( 'have.attr', 'value', '(process.name: "conhost.exe" or process.name: "sc.exe")' @@ -70,7 +72,7 @@ describe('ml conditional links', () => { it('sets the KQL from a multiple host names with null for query', () => { loginAndWaitForPage(mlHostMultiHostNullKqlQuery); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( + cy.get(KQL_INPUT).should( 'have.attr', 'value', '(host.name: "siem-windows" or host.name: "siem-suricata")' @@ -79,7 +81,7 @@ describe('ml conditional links', () => { it('sets the KQL from a multiple host names with a value for query', () => { loginAndWaitForPage(mlHostMultiHostKqlQuery); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( + cy.get(KQL_INPUT).should( 'have.attr', 'value', '(host.name: "siem-windows" or host.name: "siem-suricata") and ((process.name: "conhost.exe" or process.name: "sc.exe"))' @@ -88,7 +90,7 @@ describe('ml conditional links', () => { it('sets the KQL from a undefined/null host name but with a value for query', () => { loginAndWaitForPage(mlHostVariableHostKqlQuery); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( + cy.get(KQL_INPUT).should( 'have.attr', 'value', '(process.name: "conhost.exe" or process.name: "sc.exe")' diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/navigation/navigation.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/navigation.spec.ts similarity index 78% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/navigation/navigation.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/navigation.spec.ts index 364864b395d41..2c5a0e5eeea8a 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/navigation/navigation.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/navigation.spec.ts @@ -3,11 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { HOSTS, NETWORK, OVERVIEW, TIMELINES } from '../screens/siem_header'; -import { TIMELINES_PAGE } from '../../../urls/navigation'; -import { HOSTS, NETWORK, OVERVIEW, TIMELINES } from '../../../screens/header'; -import { loginAndWaitForPage } from '../../../tasks/login'; -import { navigateFromHeaderTo } from '../../../tasks/header'; +import { loginAndWaitForPage } from '../tasks/login'; +import { navigateFromHeaderTo } from '../tasks/siem_header'; + +import { TIMELINES_PAGE } from '../urls/navigation'; describe('top-level navigation common to all pages in the SIEM app', () => { before(() => { diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/overview/overview.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/overview.spec.ts similarity index 74% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/overview/overview.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/overview.spec.ts index 64002aadc86d8..cadb4beca0f9e 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/overview/overview.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/overview.spec.ts @@ -4,10 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { OVERVIEW_PAGE } from '../../../urls/navigation'; -import { HOST_STATS, NETWORK_STATS } from '../../../screens/overview'; -import { expandHostStats, expandNetworkStats } from '../../../tasks/overview'; -import { loginAndWaitForPage } from '../../lib/util/helpers'; +import { HOST_STATS, NETWORK_STATS } from '../screens/overview'; + +import { expandHostStats, expandNetworkStats } from '../tasks/overview'; +import { loginAndWaitForPage } from '../tasks/login'; + +import { OVERVIEW_PAGE } from '../urls/navigation'; describe('Overview Page', () => { before(() => { diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/pagination/pagination.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/pagination.spec.ts similarity index 80% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/pagination/pagination.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/pagination.spec.ts index d8ad75322b889..482c97fe29c3b 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/pagination/pagination.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/pagination.spec.ts @@ -4,15 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HOSTS_PAGE_TAB_URLS } from '../../../urls/navigation'; -import { loginAndWaitForPage } from '../../../tasks/login'; -import { refreshPage } from '../../../tasks/header'; -import { goToFirstPage, goToThirdPage } from '../../../tasks/pagination'; -import { FIRST_PAGE_SELECTOR, THIRD_PAGE_SELECTOR } from '../../../screens/pagination'; -import { PROCESS_NAME_FIELD } from '../../../screens/uncommon_processes'; -import { waitForUncommonProcessesToBeLoaded } from '../../../tasks/uncommon_processes'; -import { waitForAuthenticationsToBeLoaded } from '../../../tasks/authentications'; -import { openAuthentications, openUncommonProcesses } from '../../../tasks/hosts/main'; +import { PROCESS_NAME_FIELD } from '../screens/hosts/uncommon_processes'; +import { FIRST_PAGE_SELECTOR, THIRD_PAGE_SELECTOR } from '../screens/pagination'; + +import { waitForAuthenticationsToBeLoaded } from '../tasks/hosts/authentications'; +import { openAuthentications, openUncommonProcesses } from '../tasks/hosts/main'; +import { waitForUncommonProcessesToBeLoaded } from '../tasks/hosts/uncommon_processes'; +import { loginAndWaitForPage } from '../tasks/login'; +import { goToFirstPage, goToThirdPage } from '../tasks/pagination'; +import { refreshPage } from '../tasks/siem_header'; + +import { HOSTS_PAGE_TAB_URLS } from '../urls/navigation'; describe('Pagination', () => { before(() => { diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/data_providers.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/timeline_data_providers.spec.ts similarity index 81% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/data_providers.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/timeline_data_providers.spec.ts index 7d1ee43b1b509..4889d40ae7d39 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/data_providers.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/timeline_data_providers.spec.ts @@ -4,22 +4,25 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HOSTS_PAGE } from '../../../urls/navigation'; import { - waitForAllHostsToBeLoaded, - dragAndDropFirstHostToTimeline, - dragFirstHostToTimeline, - dragFirstHostToEmptyTimelineDataProviders, -} from '../../../tasks/hosts/all_hosts'; -import { HOSTS_NAMES_DRAGGABLE } from '../../../screens/hosts/all_hosts'; -import { DEFAULT_TIMEOUT, loginAndWaitForPage } from '../../../tasks/login'; -import { createNewTimeline } from '../../../tasks/timeline/main'; -import { openTimeline } from '../../../tasks/siem_main'; -import { - TIMELINE_DATA_PROVIDERS_EMPTY, TIMELINE_DATA_PROVIDERS, + TIMELINE_DATA_PROVIDERS_EMPTY, TIMELINE_DROPPED_DATA_PROVIDERS, -} from '../../../screens/timeline/main'; +} from '../screens/timeline'; +import { HOSTS_NAMES_DRAGGABLE } from '../screens/hosts/all_hosts'; + +import { + dragAndDropFirstHostToTimeline, + dragFirstHostToEmptyTimelineDataProviders, + dragFirstHostToTimeline, + waitForAllHostsToBeLoaded, +} from '../tasks/hosts/all_hosts'; + +import { loginAndWaitForPage } from '../tasks/login'; +import { openTimeline } from '../tasks/siem_main'; +import { createNewTimeline } from '../tasks/timeline'; + +import { HOSTS_PAGE } from '../urls/navigation'; describe('timeline data providers', () => { before(() => { @@ -38,7 +41,7 @@ describe('timeline data providers', () => { it('renders the data provider of a host dragged from the All Hosts widget on the hosts page', () => { dragAndDropFirstHostToTimeline(); - cy.get(TIMELINE_DROPPED_DATA_PROVIDERS, { timeout: DEFAULT_TIMEOUT }) + cy.get(TIMELINE_DROPPED_DATA_PROVIDERS) .first() .invoke('text') .then(dataProviderText => { diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/timeline_flyout_button.spec.ts similarity index 68% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/timeline_flyout_button.spec.ts index b7faaaac1c06c..1a94a4abbe5bf 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/flyout_button.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/timeline_flyout_button.spec.ts @@ -4,15 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HOSTS_PAGE } from '../../../urls/navigation'; -import { waitForAllHostsToBeLoaded, dragFirstHostToTimeline } from '../../../tasks/hosts/all_hosts'; -import { loginAndWaitForPage } from '../../../tasks/login'; -import { openTimelineIfClosed, openTimeline } from '../../../tasks/siem_main'; -import { - TIMELINE_FLYOUT_BODY, - TIMELINE_NOT_READY_TO_DROP_BUTTON, -} from '../../../screens/timeline/main'; -import { createNewTimeline } from '../../../tasks/timeline/main'; +import { TIMELINE_FLYOUT_BODY, TIMELINE_NOT_READY_TO_DROP_BUTTON } from '../screens/timeline'; + +import { dragFirstHostToTimeline, waitForAllHostsToBeLoaded } from '../tasks/hosts/all_hosts'; +import { loginAndWaitForPage } from '../tasks/login'; +import { openTimeline, openTimelineIfClosed } from '../tasks/siem_main'; +import { createNewTimeline } from '../tasks/timeline'; + +import { HOSTS_PAGE } from '../urls/navigation'; describe('timeline flyout button', () => { before(() => { diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/search_or_filter.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/timeline_search_or_filter.spec.ts similarity index 58% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/search_or_filter.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/timeline_search_or_filter.spec.ts index 28cc4a6e8827d..c06fd69a558a4 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/search_or_filter.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/timeline_search_or_filter.spec.ts @@ -4,11 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SERVER_SIDE_EVENT_COUNT } from '../../../screens/timeline/main'; -import { HOSTS_PAGE } from '../../../urls/navigation'; -import { loginAndWaitForPage, DEFAULT_TIMEOUT } from '../../../tasks/login'; -import { openTimeline } from '../../../tasks/siem_main'; -import { executeTimelineKQL } from '../../../tasks/timeline/main'; +import { SERVER_SIDE_EVENT_COUNT } from '../screens/timeline'; + +import { loginAndWaitForPage } from '../tasks/login'; +import { openTimeline } from '../tasks/siem_main'; +import { executeTimelineKQL } from '../tasks/timeline'; + +import { HOSTS_PAGE } from '../urls/navigation'; describe('timeline search or filter KQL bar', () => { beforeEach(() => { @@ -20,7 +22,7 @@ describe('timeline search or filter KQL bar', () => { openTimeline(); executeTimelineKQL(hostExistsQuery); - cy.get(SERVER_SIDE_EVENT_COUNT, { timeout: DEFAULT_TIMEOUT }) + cy.get(SERVER_SIDE_EVENT_COUNT) .invoke('text') .should('be.above', 0); }); diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/toggle_column.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/timeline_toggle_column.spec.ts similarity index 82% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/toggle_column.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/timeline_toggle_column.spec.ts index ccd6ae818c6cd..7b2c6f3b55b2e 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/timeline/toggle_column.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/timeline_toggle_column.spec.ts @@ -4,23 +4,25 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HOSTS_PAGE } from '../../../urls/navigation'; -import { loginAndWaitForPage, DEFAULT_TIMEOUT } from '../../../tasks/login'; import { + ID_HEADER_FIELD, + ID_TOGGLE_FIELD, + TIMESTAMP_HEADER_FIELD, + TIMESTAMP_TOGGLE_FIELD, +} from '../screens/timeline'; + +import { loginAndWaitForPage } from '../tasks/login'; +import { openTimeline } from '../tasks/siem_main'; +import { + checkIdToggleField, createNewTimeline, - populateTimeline, + dragAndDropIdToggleFieldToTimeline, expandFirstTimelineEventDetails, + populateTimeline, uncheckTimestampToggleField, - checkIdToggleField, - dragAndDropIdToggleFieldToTimeline, -} from '../../../tasks/timeline/main'; -import { openTimeline } from '../../../tasks/siem_main'; -import { - TIMESTAMP_TOGGLE_FIELD, - ID_TOGGLE_FIELD, - TIMESTAMP_HEADER_FIELD, - ID_HEADER_FIELD, -} from '../../../screens/timeline/main'; +} from '../tasks/timeline'; + +import { HOSTS_PAGE } from '../urls/navigation'; describe('toggle column in timeline', () => { before(() => { @@ -63,8 +65,6 @@ describe('toggle column in timeline', () => { expandFirstTimelineEventDetails(); dragAndDropIdToggleFieldToTimeline(); - cy.get(ID_HEADER_FIELD, { - timeout: DEFAULT_TIMEOUT, - }).should('exist'); + cy.get(ID_HEADER_FIELD).should('exist'); }); }); diff --git a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/url_state/url_state.spec.ts b/x-pack/legacy/plugins/siem/cypress/integration/url_state.spec.ts similarity index 84% rename from x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/url_state/url_state.spec.ts rename to x-pack/legacy/plugins/siem/cypress/integration/url_state.spec.ts index 4345938c8867e..cabdb98fa5b67 100644 --- a/x-pack/legacy/plugins/siem/cypress/integration/smoke_tests/url_state/url_state.spec.ts +++ b/x-pack/legacy/plugins/siem/cypress/integration/url_state.spec.ts @@ -4,9 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ABSOLUTE_DATE_RANGE } from '../../../urls/state'; -import { DEFAULT_TIMEOUT, loginAndWaitForPage } from '../../../tasks/login'; -import { HOSTS_PAGE } from '../../../urls/navigation'; +import { + DATE_PICKER_END_DATE_POPOVER_BUTTON, + DATE_PICKER_END_DATE_POPOVER_BUTTON_TIMELINE, + DATE_PICKER_START_DATE_POPOVER_BUTTON, + DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE, +} from '../screens/date_picker'; +import { HOSTS_NAMES } from '../screens/hosts/all_hosts'; +import { ANOMALIES_TAB } from '../screens/hosts/main'; +import { BREADCRUMBS, HOSTS, KQL_INPUT, NETWORK } from '../screens/siem_header'; +import { SERVER_SIDE_EVENT_COUNT, TIMELINE_TITLE } from '../screens/timeline'; + +import { loginAndWaitForPage } from '../tasks/login'; import { setStartDate, setEndDate, @@ -14,23 +23,17 @@ import { setTimelineStartDate, setTimelineEndDate, updateTimelineDates, -} from '../../../tasks/calendar'; -import { waitForIpsTableToBeLoaded } from '../../../tasks/network/flows'; -import { openTimeline } from '../../../tasks/siem_main'; -import { - DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE, - DATE_PICKER_END_DATE_POPOVER_BUTTON_TIMELINE, - DATE_PICKER_START_DATE_POPOVER_BUTTON, - DATE_PICKER_END_DATE_POPOVER_BUTTON, -} from '../../../screens/calendar'; -import { kqlSearch, navigateFromHeaderTo, clearSearchBar } from '../../../tasks/header'; -import { HOSTS, NETWORK, KQL_INPUT, BREADCRUMBS } from '../../../screens/header'; -import { openAllHosts } from '../../../tasks/hosts/main'; -import { ANOMALIES_TAB } from '../../../screens/hosts/main'; -import { waitForAllHostsToBeLoaded, openFirstHostDetails } from '../../../tasks/hosts/all_hosts'; -import { HOSTS_NAMES } from '../../../screens/hosts/all_hosts'; -import { executeTimelineKQL, addNameToTimeline } from '../../../tasks/timeline/main'; -import { SERVER_SIDE_EVENT_COUNT, TIMELINE_TITLE } from '../../../screens/timeline/main'; +} from '../tasks/date_picker'; +import { openFirstHostDetails, waitForAllHostsToBeLoaded } from '../tasks/hosts/all_hosts'; +import { openAllHosts } from '../tasks/hosts/main'; + +import { waitForIpsTableToBeLoaded } from '../tasks/network/flows'; +import { clearSearchBar, kqlSearch, navigateFromHeaderTo } from '../tasks/siem_header'; +import { openTimeline } from '../tasks/siem_main'; +import { addNameToTimeline, executeTimelineKQL } from '../tasks/timeline'; + +import { HOSTS_PAGE } from '../urls/navigation'; +import { ABSOLUTE_DATE_RANGE } from '../urls/state'; const ABSOLUTE_DATE = { endTime: '1564691609186', @@ -146,20 +149,12 @@ describe('url state', () => { it('sets kql on network page', () => { loginAndWaitForPage(ABSOLUTE_DATE_RANGE.urlKqlNetworkNetwork); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( - 'have.attr', - 'value', - 'source.ip: "10.142.0.9"' - ); + cy.get(KQL_INPUT).should('have.attr', 'value', 'source.ip: "10.142.0.9"'); }); it('sets kql on hosts page', () => { loginAndWaitForPage(ABSOLUTE_DATE_RANGE.urlKqlHostsHosts); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( - 'have.attr', - 'value', - 'source.ip: "10.142.0.9"' - ); + cy.get(KQL_INPUT).should('have.attr', 'value', 'source.ip: "10.142.0.9"'); }); it('sets the url state when kql is set', () => { @@ -197,7 +192,7 @@ describe('url state', () => { 'href', "#/link-to/network?query=(language:kuery,query:'host.name:%20%22siem-kibana%22%20')&timerange=(global:(linkTo:!(timeline),timerange:(from:1564689809186,kind:absolute,to:1577914409186)),timeline:(linkTo:!(global),timerange:(from:1564689809186,kind:absolute,to:1577914409186)))" ); - cy.get(HOSTS_NAMES, { timeout: DEFAULT_TIMEOUT }) + cy.get(HOSTS_NAMES) .first() .invoke('text') .should('eq', 'siem-kibana'); @@ -231,11 +226,7 @@ describe('url state', () => { loginAndWaitForPage(ABSOLUTE_DATE_RANGE.urlKqlHostsHosts); navigateFromHeaderTo(NETWORK); - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).should( - 'have.attr', - 'value', - 'source.ip: "10.142.0.9"' - ); + cy.get(KQL_INPUT).should('have.attr', 'value', 'source.ip: "10.142.0.9"'); }); it('sets and reads the url state for timeline by id', () => { @@ -243,7 +234,7 @@ describe('url state', () => { openTimeline(); executeTimelineKQL('host.name: *'); - cy.get(SERVER_SIDE_EVENT_COUNT, { timeout: DEFAULT_TIMEOUT }) + cy.get(SERVER_SIDE_EVENT_COUNT) .invoke('text') .should('be.above', 0); diff --git a/x-pack/legacy/plugins/siem/cypress/screens/calendar.ts b/x-pack/legacy/plugins/siem/cypress/screens/date_picker.ts similarity index 99% rename from x-pack/legacy/plugins/siem/cypress/screens/calendar.ts rename to x-pack/legacy/plugins/siem/cypress/screens/date_picker.ts index caff721c683e9..e49f5afa7bd0c 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/calendar.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/date_picker.ts @@ -4,18 +4,24 @@ * you may not use this file except in compliance with the Elastic License. */ -export const DATE_PICKER_START_DATE_POPOVER_BUTTON = - 'div[data-test-subj="globalDatePicker"] button[data-test-subj="superDatePickerstartDatePopoverButton"]'; -export const DATE_PICKER_END_DATE_POPOVER_BUTTON = - '[data-test-subj="globalDatePicker"] [data-test-subj="superDatePickerendDatePopoverButton"]'; -export const DATE_PICKER_ABSOLUTE_TAB = '[data-test-subj="superDatePickerAbsoluteTab"]'; +export const DATE_PICKER_ABSOLUTE_INPUT = '[data-test-subj="superDatePickerAbsoluteDateInput"]'; + export const DATE_PICKER_APPLY_BUTTON = '[data-test-subj="globalDatePicker"] button[data-test-subj="querySubmitButton"]'; + export const DATE_PICKER_APPLY_BUTTON_TIMELINE = '[data-test-subj="timeline-properties"] button[data-test-subj="superDatePickerApplyTimeButton"]'; -export const DATE_PICKER_ABSOLUTE_INPUT = '[data-test-subj="superDatePickerAbsoluteDateInput"]'; -export const DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE = - '[data-test-subj="timeline-properties"] [data-test-subj="superDatePickerstartDatePopoverButton"]'; + +export const DATE_PICKER_ABSOLUTE_TAB = '[data-test-subj="superDatePickerAbsoluteTab"]'; + +export const DATE_PICKER_END_DATE_POPOVER_BUTTON = + '[data-test-subj="globalDatePicker"] [data-test-subj="superDatePickerendDatePopoverButton"]'; export const DATE_PICKER_END_DATE_POPOVER_BUTTON_TIMELINE = '[data-test-subj="timeline-properties"] [data-test-subj="superDatePickerendDatePopoverButton"]'; + +export const DATE_PICKER_START_DATE_POPOVER_BUTTON = + 'div[data-test-subj="globalDatePicker"] button[data-test-subj="superDatePickerstartDatePopoverButton"]'; + +export const DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE = + '[data-test-subj="timeline-properties"] [data-test-subj="superDatePickerstartDatePopoverButton"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/timeline/fields_browser.ts b/x-pack/legacy/plugins/siem/cypress/screens/fields_browser.ts similarity index 92% rename from x-pack/legacy/plugins/siem/cypress/screens/timeline/fields_browser.ts rename to x-pack/legacy/plugins/siem/cypress/screens/fields_browser.ts index aa63aaf89f98b..f15096bd874bc 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/timeline/fields_browser.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/fields_browser.ts @@ -4,57 +4,58 @@ * you may not use this file except in compliance with the Elastic License. */ -export const FIELDS_BROWSER_TITLE = '[data-test-subj="field-browser-title"]'; +export const FIELDS_BROWSER_CATEGORIES_COUNT = '[data-test-subj="categories-count"]'; -/** Typing in this input filters the Field Browser */ -export const FIELDS_BROWSER_FILTER_INPUT = '[data-test-subj="field-search"]'; +export const FIELDS_BROWSER_CHECKBOX = (id: string) => { + return `[data-test-subj="field-${id}-checkbox`; +}; -/** The title of the selected category in the right-hand side of the fields browser */ -export const FIELDS_BROWSER_SELECTED_CATEGORY_TITLE = '[data-test-subj="selected-category-title"]'; +export const FIELDS_BROWSER_CONTAINER = '[data-test-subj="fields-browser-container"]'; -export const FIELDS_BROWSER_SELECTED_CATEGORY_COUNT = - '[data-test-subj="selected-category-count-badge"]'; +export const FIELDS_BROWSER_DRAGGABLE_HOST_GEO_COUNTRY_NAME_HEADER = + '[data-test-subj="timeline"] [data-test-subj="field-name-host.geo.country_name"]'; -export const FIELDS_BROWSER_CATEGORIES_COUNT = '[data-test-subj="categories-count"]'; +export const FIELDS_BROWSER_FIELDS_COUNT = '[data-test-subj="fields-count"]'; -export const FIELDS_BROWSER_HOST_CATEGORIES_COUNT = '[data-test-subj="host-category-count"]'; +export const FIELDS_BROWSER_FILTER_INPUT = '[data-test-subj="field-search"]'; -export const FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT = '[data-test-subj="system-category-count"]'; +export const FIELDS_BROWSER_HEADER_DROP_AREA = + '[data-test-subj="timeline"] [data-test-subj="headers-group"]'; -export const FIELDS_BROWSER_FIELDS_COUNT = '[data-test-subj="fields-count"]'; +export const FIELDS_BROWSER_HOST_CATEGORIES_COUNT = '[data-test-subj="host-category-count"]'; -/** Contains the body of the fields browser */ -export const FIELDS_BROWSER_CONTAINER = '[data-test-subj="fields-browser-container"]'; +export const FIELDS_BROWSER_HOST_GEO_CITY_NAME_CHECKBOX = + '[data-test-subj="field-host.geo.city_name-checkbox"]'; -export const FIELDS_BROWSER_MESSAGE_HEADER = - '[data-test-subj="timeline"] [data-test-subj="header-text-message"]'; +export const FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER = + '[data-test-subj="header-text-host.geo.city_name"]'; -export const FIELDS_BROWSER_MESSAGE_CHECKBOX = - '[data-test-subj="timeline"] [data-test-subj="field-message-checkbox"]'; +export const FIELDS_BROWSER_HOST_GEO_CONTINENT_NAME_CHECKBOX = + '[data-test-subj="field-host.geo.continent_name-checkbox"]'; -export const FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER = - '[data-test-subj="header-text-host.geo.country_name"]'; +export const FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER = + '[data-test-subj="header-text-host.geo.continent_name"]'; export const FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_CHECKBOX = '[data-test-subj="field-host.geo.country_name-checkbox"]'; -export const FIELDS_BROWSER_DRAGGABLE_HOST_GEO_COUNTRY_NAME_HEADER = - '[data-test-subj="timeline"] [data-test-subj="field-name-host.geo.country_name"]'; +export const FIELDS_BROWSER_HOST_GEO_COUNTRY_NAME_HEADER = + '[data-test-subj="header-text-host.geo.country_name"]'; -export const FIELDS_BROWSER_HOST_GEO_CITY_NAME_HEADER = - '[data-test-subj="header-text-host.geo.city_name"]'; +export const FIELDS_BROWSER_MESSAGE_CHECKBOX = + '[data-test-subj="timeline"] [data-test-subj="field-message-checkbox"]'; -export const FIELDS_BROWSER_HOST_GEO_CITY_NAME_CHECKBOX = - '[data-test-subj="field-host.geo.city_name-checkbox"]'; +export const FIELDS_BROWSER_MESSAGE_HEADER = + '[data-test-subj="timeline"] [data-test-subj="header-text-message"]'; -export const FIELDS_BROWSER_HEADER_DROP_AREA = - '[data-test-subj="timeline"] [data-test-subj="headers-group"]'; +export const FIELDS_BROWSER_RESET_FIELDS = + '[data-test-subj="timeline"] [data-test-subj="reset-fields"]'; -export const FIELDS_BROWSER_HEADER_HOST_GEO_CONTINENT_NAME_HEADER = - '[data-test-subj="header-text-host.geo.continent_name"]'; +export const FIELDS_BROWSER_TITLE = '[data-test-subj="field-browser-title"]'; -export const FIELDS_BROWSER_HOST_GEO_CONTINENT_NAME_CHECKBOX = - '[data-test-subj="field-host.geo.continent_name-checkbox"]'; +export const FIELDS_BROWSER_SELECTED_CATEGORY_COUNT = + '[data-test-subj="selected-category-count-badge"]'; -export const FIELDS_BROWSER_RESET_FIELDS = - '[data-test-subj="timeline"] [data-test-subj="reset-fields"]'; +export const FIELDS_BROWSER_SELECTED_CATEGORY_TITLE = '[data-test-subj="selected-category-title"]'; + +export const FIELDS_BROWSER_SYSTEM_CATEGORIES_COUNT = '[data-test-subj="system-category-count"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/hosts/all_hosts.ts b/x-pack/legacy/plugins/siem/cypress/screens/hosts/all_hosts.ts index 61f39ca7a8b0c..ca123a8afc6c9 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/hosts/all_hosts.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/hosts/all_hosts.ts @@ -6,6 +6,6 @@ export const ALL_HOSTS_TABLE = '[data-test-subj="table-allHosts-loading-false"]'; -export const HOSTS_NAMES_DRAGGABLE = '[data-test-subj="draggable-content-host.name"]'; - export const HOSTS_NAMES = '[data-test-subj="draggable-content-host.name"] a.euiLink'; + +export const HOSTS_NAMES_DRAGGABLE = '[data-test-subj="draggable-content-host.name"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/authentications.ts b/x-pack/legacy/plugins/siem/cypress/screens/hosts/authentications.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/authentications.ts rename to x-pack/legacy/plugins/siem/cypress/screens/hosts/authentications.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/hosts/events.ts b/x-pack/legacy/plugins/siem/cypress/screens/hosts/events.ts index 034c1453fc979..ed46a90c872c8 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/hosts/events.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/hosts/events.ts @@ -4,33 +4,39 @@ * you may not use this file except in compliance with the Elastic License. */ -export const EVENTS_VIEWER_PANEL = '[data-test-subj="events-viewer-panel"]'; - export const CLOSE_MODAL = '[data-test-subj="modal-inspect-close"]'; -export const HEADER_SUBTITLE = `${EVENTS_VIEWER_PANEL} [data-test-subj="header-panel-subtitle"]`; +export const EVENTS_VIEWER_FIELDS_BUTTON = + '[data-test-subj="events-viewer-panel"] [data-test-subj="show-field-browser-gear"]'; -export const INSPECT_MODAL = '[data-test-subj="modal-inspect-euiModal"]'; - -export const INSPECT_QUERY = `${EVENTS_VIEWER_PANEL} [data-test-subj="inspect-icon-button"]`; +export const EVENTS_VIEWER_PANEL = '[data-test-subj="events-viewer-panel"]'; -export const LOAD_MORE = `${EVENTS_VIEWER_PANEL} [data-test-subj="TimelineMoreButton"]`; +export const FIELDS_BROWSER_CONTAINER = '[data-test-subj="fields-browser-container"]'; -export const LOCAL_EVENTS_COUNT = `${EVENTS_VIEWER_PANEL} [data-test-subj="local-events-count"]`; +export const HEADER_SUBTITLE = + '[data-test-subj="events-viewer-panel"] [data-test-subj="header-panel-subtitle"]'; -export const SERVER_SIDE_EVENT_COUNT = '[data-test-subj="server-side-event-count"]'; +export const HOST_GEO_CITY_NAME_CHECKBOX = '[data-test-subj="field-host.geo.city_name-checkbox"]'; export const HOST_GEO_CITY_NAME_HEADER = '[data-test-subj="header-text-host.geo.city_name"]'; -export const HOST_GEO_CITY_NAME_CHECKBOX = '[data-test-subj="field-host.geo.city_name-checkbox"]'; +export const HOST_GEO_COUNTRY_NAME_CHECKBOX = + '[data-test-subj="field-host.geo.country_name-checkbox"]'; export const HOST_GEO_COUNTRY_NAME_HEADER = '[data-test-subj="header-text-host.geo.country_name"]'; -export const HOST_GEO_COUNTRY_NAME_CHECKBOX = - '[data-test-subj="field-host.geo.country_name-checkbox"]'; +export const INSPECT_MODAL = '[data-test-subj="modal-inspect-euiModal"]'; -export const FIELDS_BROWSER_CONTAINER = '[data-test-subj="fields-browser-container"]'; +export const INSPECT_QUERY = + '[data-test-subj="events-viewer-panel"] [data-test-subj="inspect-icon-button"]'; + +export const LOCAL_EVENTS_COUNT = + '[data-test-subj="events-viewer-panel"] [data-test-subj="local-events-count"'; -export const EVENTS_VIEWER_FIELDS_BUTTON = `${EVENTS_VIEWER_PANEL} [data-test-subj="show-field-browser-gear"]`; +export const LOAD_MORE = + '[data-test-subj="events-viewer-panel"] [data-test-subj="TimelineMoreButton"'; -export const RESET_FIELDS = `${EVENTS_VIEWER_PANEL} [data-test-subj="reset-fields"]`; +export const RESET_FIELDS = + '[data-test-subj="events-viewer-panel"] [data-test-subj="reset-fields"]'; + +export const SERVER_SIDE_EVENT_COUNT = '[data-test-subj="server-side-event-count"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/hosts/fields_browser.ts b/x-pack/legacy/plugins/siem/cypress/screens/hosts/fields_browser.ts deleted file mode 100644 index 252fa7d44a7c7..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/screens/hosts/fields_browser.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/** Clicking this button in the timeline opens the Fields browser */ - -/** The title displayed in the fields browser (i.e. Customize Columns) */ -export const FIELDS_BROWSER_TITLE = '[data-test-subj="field-browser-title"]'; - -/** Contains the body of the fields browser */ -export const FIELDS_BROWSER_CONTAINER = '[data-test-subj="fields-browser-container"]'; - -/** The title of the selected category in the right-hand side of the fields browser */ -export const FIELDS_BROWSER_SELECTED_CATEGORY_TITLE = '[data-test-subj="selected-category-title"]'; - -export const FIELDS_BROWSER_CHECKBOX = (id: string) => { - return `[data-test-subj="field-${id}-checkbox`; -}; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/hosts/main.ts b/x-pack/legacy/plugins/siem/cypress/screens/hosts/main.ts index 25696be526e5f..3c30562680e86 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/hosts/main.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/hosts/main.ts @@ -4,14 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -export const EVENTS_TAB = '[data-test-subj="navigation-events"]'; - -export const AUTHENTICATIONS_TAB = '[data-test-subj="navigation-authentications"]'; - -export const UNCOMMON_PROCESSES_TAB = '[data-test-subj="navigation-uncommonProcesses"]'; - export const ALL_HOSTS_TAB = '[data-test-subj="navigation-allHosts'; export const ANOMALIES_TAB = '[data-test-subj="navigation-anomalies"]'; +export const AUTHENTICATIONS_TAB = '[data-test-subj="navigation-authentications"]'; + +export const EVENTS_TAB = '[data-test-subj="navigation-events"]'; + export const KQL_SEARCH_BAR = '[data-test-subj="queryInput"]'; + +export const UNCOMMON_PROCESSES_TAB = '[data-test-subj="navigation-uncommonProcesses"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/hosts/uncommon_processes.ts b/x-pack/legacy/plugins/siem/cypress/screens/hosts/uncommon_processes.ts index 9e15bea79eae0..68ea8e008bfd3 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/hosts/uncommon_processes.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/hosts/uncommon_processes.ts @@ -4,4 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -export const PROCESS_NAME = '[data-test-subj="draggable-content-process.name"]'; +export const PROCESS_NAME_FIELD = '[data-test-subj="draggable-content-process.name"]'; + +export const UNCOMMON_PROCESSES_TABLE = '[data-test-subj="table-uncommonProcesses-loading-false"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/header.ts b/x-pack/legacy/plugins/siem/cypress/screens/siem_header.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/header.ts rename to x-pack/legacy/plugins/siem/cypress/screens/siem_header.ts index 4ffb497a62432..cf1059269393a 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/header.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/siem_header.ts @@ -4,16 +4,16 @@ * you may not use this file except in compliance with the Elastic License. */ -export const KQL_INPUT = '[data-test-subj="queryInput"]'; +export const BREADCRUMBS = '[data-test-subj="breadcrumbs"] a'; export const HOSTS = '[data-test-subj="navigation-hosts"]'; +export const KQL_INPUT = '[data-test-subj="queryInput"]'; + export const NETWORK = '[data-test-subj="navigation-network"]'; export const OVERVIEW = '[data-test-subj="navigation-overview"]'; -export const TIMELINES = '[data-test-subj="navigation-timelines"]'; - export const REFRESH_BUTTON = '[data-test-subj="querySubmitButton"]'; -export const BREADCRUMBS = '[data-test-subj="breadcrumbs"] a'; +export const TIMELINES = '[data-test-subj="navigation-timelines"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts b/x-pack/legacy/plugins/siem/cypress/screens/timeline.ts similarity index 89% rename from x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts rename to x-pack/legacy/plugins/siem/cypress/screens/timeline.ts index 6df269b7691a8..1640647b45427 100644 --- a/x-pack/legacy/plugins/siem/cypress/screens/timeline/main.ts +++ b/x-pack/legacy/plugins/siem/cypress/screens/timeline.ts @@ -4,26 +4,20 @@ * you may not use this file except in compliance with the Elastic License. */ -/** The `Timeline ^` button that toggles visibility of the Timeline */ -export const TIMELINE_TOGGLE_BUTTON = '[data-test-subj="flyoutOverlay"]'; - -/** Contains the KQL bar for searching or filtering in the timeline */ -export const SEARCH_OR_FILTER_CONTAINER = - '[data-test-subj="timeline-search-or-filter-search-container"]'; +export const CLOSE_TIMELINE_BTN = '[data-test-subj="close-timeline"]'; -export const TIMELINE_FIELDS_BUTTON = - '[data-test-subj="timeline"] [data-test-subj="show-field-browser"]'; +export const CREATE_NEW_TIMELINE = '[data-test-subj="timeline-new"]'; -/** The total server-side count of the events matching the timeline's search criteria */ -export const SERVER_SIDE_EVENT_COUNT = '[data-test-subj="server-side-event-count"]'; +export const ID_HEADER_FIELD = '[data-test-subj="timeline"] [data-test-subj="header-text-_id"]'; -export const TIMELINE_SETTINGS_ICON = '[data-test-subj="settings-gear"]'; +export const ID_FIELD = '[data-test-subj="timeline"] [data-test-subj="field-name-_id"]'; -export const TIMELINE_INSPECT_BUTTON = '[data-test-subj="inspect-empty-button"]'; +export const ID_TOGGLE_FIELD = '[data-test-subj="toggle-field-_id"]'; -export const CLOSE_TIMELINE_BTN = '[data-test-subj="close-timeline"]'; +export const SEARCH_OR_FILTER_CONTAINER = + '[data-test-subj="timeline-search-or-filter-search-container"]'; -export const CREATE_NEW_TIMELINE = '[data-test-subj="timeline-new"]'; +export const SERVER_SIDE_EVENT_COUNT = '[data-test-subj="server-side-event-count"]'; export const TIMELINE_DATA_PROVIDERS = '[data-test-subj="dataProviders"]'; @@ -33,21 +27,24 @@ export const TIMELINE_DATA_PROVIDERS_EMPTY = export const TIMELINE_DROPPED_DATA_PROVIDERS = '[data-test-subj="dataProviders"] [data-test-subj="providerContainer"]'; +export const TIMELINE_FIELDS_BUTTON = + '[data-test-subj="timeline"] [data-test-subj="show-field-browser"]'; + export const TIMELINE_FLYOUT_BODY = '[data-test-subj="eui-flyout-body"]'; +export const TIMELINE_INSPECT_BUTTON = '[data-test-subj="inspect-empty-button"]'; + export const TIMELINE_NOT_READY_TO_DROP_BUTTON = '[data-test-subj="flyout-button-not-ready-to-drop"]'; -export const TOGGLE_TIMELINE_EXPAND_EVENT = '[data-test-subj="expand-event"]'; - -export const TIMESTAMP_TOGGLE_FIELD = '[data-test-subj="toggle-field-@timestamp"]'; +export const TIMELINE_SETTINGS_ICON = '[data-test-subj="settings-gear"]'; -export const ID_TOGGLE_FIELD = '[data-test-subj="toggle-field-_id"]'; +export const TIMELINE_TITLE = '[data-test-subj="timeline-title"]'; export const TIMESTAMP_HEADER_FIELD = '[data-test-subj="header-text-@timestamp"]'; -export const ID_HEADER_FIELD = '[data-test-subj="timeline"] [data-test-subj="header-text-_id"]'; +export const TIMELINE_TOGGLE_BUTTON = '[data-test-subj="flyoutOverlay"]'; -export const ID_FIELD = '[data-test-subj="timeline"] [data-test-subj="field-name-_id"]'; +export const TIMESTAMP_TOGGLE_FIELD = '[data-test-subj="toggle-field-@timestamp"]'; -export const TIMELINE_TITLE = '[data-test-subj="timeline-title"]'; +export const TOGGLE_TIMELINE_EXPAND_EVENT = '[data-test-subj="expand-event"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/screens/uncommon_processes.ts b/x-pack/legacy/plugins/siem/cypress/screens/uncommon_processes.ts deleted file mode 100644 index 71abaa21bf6bd..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/screens/uncommon_processes.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const PROCESS_NAME_FIELD = '[data-test-subj="draggable-content-process.name"]'; -export const UNCOMMON_PROCESSES_TABLE = '[data-test-subj="table-uncommonProcesses-loading-false"]'; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/common.ts b/x-pack/legacy/plugins/siem/cypress/tasks/common.ts index 39a61401c15b3..e02d3506b33bc 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/common.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/common.ts @@ -33,6 +33,13 @@ export const drag = (subject: JQuery) => { .wait(1); }; +/** Drags the subject being dragged on the specified drop target, but does not drop it */ +export const dragWithoutDrop = (dropTarget: JQuery) => { + cy.wrap(dropTarget).trigger('mousemove', 'center', { + button: primaryButton, + }); +}; + /** "Drops" the subject being dragged on the specified drop target */ export const drop = (dropTarget: JQuery) => { cy.wrap(dropTarget) @@ -41,10 +48,3 @@ export const drop = (dropTarget: JQuery) => { .trigger('mouseup', { force: true }) .wait(1); }; - -/** Drags the subject being dragged on the specified drop target, but does not drop it */ -export const dragWithoutDrop = (dropTarget: JQuery) => { - cy.wrap(dropTarget).trigger('mousemove', 'center', { - button: primaryButton, - }); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/calendar.ts b/x-pack/legacy/plugins/siem/cypress/tasks/date_picker.ts similarity index 70% rename from x-pack/legacy/plugins/siem/cypress/tasks/calendar.ts rename to x-pack/legacy/plugins/siem/cypress/tasks/date_picker.ts index 16231317d6aef..9d79b73a52b08 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/calendar.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/date_picker.ts @@ -5,73 +5,67 @@ */ import { - DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE, - DATE_PICKER_END_DATE_POPOVER_BUTTON_TIMELINE, - DATE_PICKER_APPLY_BUTTON_TIMELINE, - DATE_PICKER_START_DATE_POPOVER_BUTTON, DATE_PICKER_ABSOLUTE_TAB, DATE_PICKER_ABSOLUTE_INPUT, DATE_PICKER_APPLY_BUTTON, + DATE_PICKER_APPLY_BUTTON_TIMELINE, DATE_PICKER_END_DATE_POPOVER_BUTTON, -} from '../screens/calendar'; - -import { DEFAULT_TIMEOUT } from '../tasks/login'; + DATE_PICKER_END_DATE_POPOVER_BUTTON_TIMELINE, + DATE_PICKER_START_DATE_POPOVER_BUTTON, + DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE, +} from '../screens/date_picker'; -export const setStartDate = (date: string) => { - cy.get(DATE_PICKER_START_DATE_POPOVER_BUTTON).click({ force: true }); +export const setEndDate = (date: string) => { + cy.get(DATE_PICKER_END_DATE_POPOVER_BUTTON).click({ force: true }); cy.get(DATE_PICKER_ABSOLUTE_TAB) .first() .click({ force: true }); - cy.get(DATE_PICKER_ABSOLUTE_INPUT, { timeout: DEFAULT_TIMEOUT }) + cy.get(DATE_PICKER_ABSOLUTE_INPUT) .clear() .type(date); }; -export const setEndDate = (date: string) => { - cy.get(DATE_PICKER_END_DATE_POPOVER_BUTTON).click({ force: true }); +export const setStartDate = (date: string) => { + cy.get(DATE_PICKER_START_DATE_POPOVER_BUTTON).click({ force: true }); cy.get(DATE_PICKER_ABSOLUTE_TAB) .first() .click({ force: true }); - cy.get(DATE_PICKER_ABSOLUTE_INPUT, { timeout: DEFAULT_TIMEOUT }) + cy.get(DATE_PICKER_ABSOLUTE_INPUT) .clear() .type(date); }; -export const updateDates = () => { - cy.get(DATE_PICKER_APPLY_BUTTON, { timeout: DEFAULT_TIMEOUT }) - .click({ force: true }) - .invoke('text', { timeout: DEFAULT_TIMEOUT }) - .should('not.equal', 'Updating'); -}; - -export const setTimelineStartDate = (date: string) => { - cy.get(DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE, { timeout: DEFAULT_TIMEOUT }).click({ - force: true, - }); +export const setTimelineEndDate = (date: string) => { + cy.get(DATE_PICKER_END_DATE_POPOVER_BUTTON_TIMELINE).click({ force: true }); cy.get(DATE_PICKER_ABSOLUTE_TAB) .first() .click({ force: true }); - cy.get(DATE_PICKER_ABSOLUTE_INPUT, { timeout: DEFAULT_TIMEOUT }).type( - `{selectall}{backspace}${date}{enter}` - ); + cy.get(DATE_PICKER_ABSOLUTE_INPUT).type(`{selectall}{backspace}${date}{enter}`); }; -export const setTimelineEndDate = (date: string) => { - cy.get(DATE_PICKER_END_DATE_POPOVER_BUTTON_TIMELINE).click({ force: true }); +export const setTimelineStartDate = (date: string) => { + cy.get(DATE_PICKER_START_DATE_POPOVER_BUTTON_TIMELINE).click({ + force: true, + }); cy.get(DATE_PICKER_ABSOLUTE_TAB) .first() .click({ force: true }); - cy.get(DATE_PICKER_ABSOLUTE_INPUT, { timeout: DEFAULT_TIMEOUT }).type( - `{selectall}{backspace}${date}{enter}` - ); + cy.get(DATE_PICKER_ABSOLUTE_INPUT).type(`{selectall}{backspace}${date}{enter}`); +}; + +export const updateDates = () => { + cy.get(DATE_PICKER_APPLY_BUTTON) + .click({ force: true }) + .invoke('text') + .should('not.equal', 'Updating'); }; export const updateTimelineDates = () => { diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/timeline/fields_browser.ts b/x-pack/legacy/plugins/siem/cypress/tasks/fields_browser.ts similarity index 81% rename from x-pack/legacy/plugins/siem/cypress/tasks/timeline/fields_browser.ts rename to x-pack/legacy/plugins/siem/cypress/tasks/fields_browser.ts index d30e49a25bab0..e1d2f24da424c 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/timeline/fields_browser.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/fields_browser.ts @@ -3,42 +3,27 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { drag, drop } from '../../integration/lib/drag_n_drop/helpers'; +import { drag, drop } from '../tasks/common'; import { FIELDS_BROWSER_FILTER_INPUT, - FIELDS_BROWSER_MESSAGE_CHECKBOX, - FIELDS_BROWSER_HOST_GEO_CITY_NAME_CHECKBOX, FIELDS_BROWSER_DRAGGABLE_HOST_GEO_COUNTRY_NAME_HEADER, FIELDS_BROWSER_HEADER_DROP_AREA, + FIELDS_BROWSER_HOST_GEO_CITY_NAME_CHECKBOX, FIELDS_BROWSER_HOST_GEO_CONTINENT_NAME_CHECKBOX, + FIELDS_BROWSER_MESSAGE_CHECKBOX, FIELDS_BROWSER_RESET_FIELDS, -} from '../../screens/timeline/fields_browser'; -import { DEFAULT_TIMEOUT } from '../../integration/lib/util/helpers'; -import { KQL_SEARCH_BAR } from '../../screens/hosts/main'; - -export const clearFieldsBrowser = () => { - cy.get(FIELDS_BROWSER_FILTER_INPUT).type('{selectall}{backspace}'); -}; - -export const filterFieldsBrowser = (fieldName: string) => { - cy.get(FIELDS_BROWSER_FILTER_INPUT, { timeout: DEFAULT_TIMEOUT }) - .type(fieldName) - .should('not.have.class', 'euiFieldSearch-isLoading'); -}; - -export const closeFieldsBrowser = () => { - cy.get(KQL_SEARCH_BAR, { timeout: DEFAULT_TIMEOUT }).click({ force: true }); -}; +} from '../screens/fields_browser'; +import { KQL_SEARCH_BAR } from '../screens/hosts/main'; -export const removesMessageField = () => { - cy.get(FIELDS_BROWSER_MESSAGE_CHECKBOX).uncheck({ +export const addsHostGeoCityNameToTimeline = () => { + cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_CHECKBOX).check({ force: true, }); }; -export const addsHostGeoCityNameToTimeline = () => { - cy.get(FIELDS_BROWSER_HOST_GEO_CITY_NAME_CHECKBOX).check({ +export const addsHostGeoContinentNameToTimeline = () => { + cy.get(FIELDS_BROWSER_HOST_GEO_CONTINENT_NAME_CHECKBOX).check({ force: true, }); }; @@ -50,8 +35,22 @@ export const addsHostGeoCountryNameToTimelineDraggingIt = () => { cy.get(FIELDS_BROWSER_HEADER_DROP_AREA).then(headersDropArea => drop(headersDropArea)); }; -export const addsHostGeoContinentNameToTimeline = () => { - cy.get(FIELDS_BROWSER_HOST_GEO_CONTINENT_NAME_CHECKBOX).check({ +export const clearFieldsBrowser = () => { + cy.get(FIELDS_BROWSER_FILTER_INPUT).type('{selectall}{backspace}'); +}; + +export const closeFieldsBrowser = () => { + cy.get(KQL_SEARCH_BAR).click({ force: true }); +}; + +export const filterFieldsBrowser = (fieldName: string) => { + cy.get(FIELDS_BROWSER_FILTER_INPUT) + .type(fieldName) + .should('not.have.class', 'euiFieldSearch-isLoading'); +}; + +export const removesMessageField = () => { + cy.get(FIELDS_BROWSER_MESSAGE_CHECKBOX).uncheck({ force: true, }); }; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/all_hosts.ts b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/all_hosts.ts index 7146c132db4a0..312df96df1ddf 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/all_hosts.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/all_hosts.ts @@ -5,16 +5,9 @@ */ import { ALL_HOSTS_TABLE, HOSTS_NAMES_DRAGGABLE, HOSTS_NAMES } from '../../screens/hosts/all_hosts'; -import { - TIMELINE_DATA_PROVIDERS, - TIMELINE_DATA_PROVIDERS_EMPTY, -} from '../../screens/timeline/main'; -import { DEFAULT_TIMEOUT } from '../../tasks/login'; -import { drag, drop, dragWithoutDrop } from '../../tasks/common'; +import { TIMELINE_DATA_PROVIDERS, TIMELINE_DATA_PROVIDERS_EMPTY } from '../../screens/timeline'; -export const waitForAllHostsToBeLoaded = () => { - cy.get(ALL_HOSTS_TABLE, { timeout: DEFAULT_TIMEOUT }).should('exist'); -}; +import { drag, dragWithoutDrop, drop } from '../../tasks/common'; export const dragAndDropFirstHostToTimeline = () => { cy.get(HOSTS_NAMES_DRAGGABLE) @@ -23,12 +16,6 @@ export const dragAndDropFirstHostToTimeline = () => { cy.get(TIMELINE_DATA_PROVIDERS).then(dataProvidersDropArea => drop(dataProvidersDropArea)); }; -export const dragFirstHostToTimeline = () => { - cy.get(HOSTS_NAMES_DRAGGABLE) - .first() - .then(host => drag(host)); -}; - export const dragFirstHostToEmptyTimelineDataProviders = () => { cy.get(HOSTS_NAMES_DRAGGABLE) .first() @@ -39,8 +26,17 @@ export const dragFirstHostToEmptyTimelineDataProviders = () => { ); }; +export const dragFirstHostToTimeline = () => { + cy.get(HOSTS_NAMES_DRAGGABLE) + .first() + .then(host => drag(host)); +}; export const openFirstHostDetails = () => { cy.get(HOSTS_NAMES) .first() .click({ force: true }); }; + +export const waitForAllHostsToBeLoaded = () => { + cy.get(ALL_HOSTS_TABLE).should('exist'); +}; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/authentications.ts b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/authentications.ts similarity index 60% rename from x-pack/legacy/plugins/siem/cypress/tasks/authentications.ts rename to x-pack/legacy/plugins/siem/cypress/tasks/hosts/authentications.ts index 6fa4bf72ca2b2..f5f15150e8ac3 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/authentications.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/authentications.ts @@ -4,9 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AUTHENTICATIONS_TABLE } from '../screens/authentications'; -import { DEFAULT_TIMEOUT } from '../tasks/login'; +import { AUTHENTICATIONS_TABLE } from '../../screens/hosts/authentications'; export const waitForAuthenticationsToBeLoaded = () => { - cy.get(AUTHENTICATIONS_TABLE, { timeout: DEFAULT_TIMEOUT }).should('exist'); + cy.get(AUTHENTICATIONS_TABLE).should('exist'); }; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/events.ts b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/events.ts index d84d62f82d2e6..de0c99bd31dff 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/events.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/events.ts @@ -4,37 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -import { DEFAULT_TIMEOUT } from '../../integration/lib/util/helpers'; import { - EVENTS_VIEWER_FIELDS_BUTTON, CLOSE_MODAL, - INSPECT_QUERY, - SERVER_SIDE_EVENT_COUNT, + EVENTS_VIEWER_FIELDS_BUTTON, + FIELDS_BROWSER_CONTAINER, HOST_GEO_CITY_NAME_CHECKBOX, HOST_GEO_COUNTRY_NAME_CHECKBOX, - FIELDS_BROWSER_CONTAINER, - RESET_FIELDS, + INSPECT_QUERY, LOAD_MORE, + RESET_FIELDS, + SERVER_SIDE_EVENT_COUNT, } from '../../screens/hosts/events'; -export const closeModal = () => { - cy.get(CLOSE_MODAL, { timeout: DEFAULT_TIMEOUT }).click(); -}; - -export const opensInspectQueryModal = () => { - cy.get(INSPECT_QUERY, { timeout: DEFAULT_TIMEOUT }) - .should('exist') - .trigger('mousemove', { force: true }) - .click({ force: true }); -}; - -export const waitsForEventsToBeLoaded = () => { - cy.get(SERVER_SIDE_EVENT_COUNT, { timeout: DEFAULT_TIMEOUT }) - .should('exist') - .invoke('text', { timeout: DEFAULT_TIMEOUT }) - .should('not.equal', '0'); -}; - export const addsHostGeoCityNameToHeader = () => { cy.get(HOST_GEO_CITY_NAME_CHECKBOX).check({ force: true, @@ -47,20 +28,38 @@ export const addsHostGeoCountryNameToHeader = () => { }); }; -export const resetFields = () => { - cy.get(RESET_FIELDS).click({ force: true }); +export const closeModal = () => { + cy.get(CLOSE_MODAL).click(); +}; + +export const loadMoreEvents = () => { + cy.get(LOAD_MORE).click({ force: true }); }; export const openEventsViewerFieldsBrowser = () => { - cy.get(EVENTS_VIEWER_FIELDS_BUTTON, { timeout: DEFAULT_TIMEOUT }).click({ force: true }); + cy.get(EVENTS_VIEWER_FIELDS_BUTTON).click({ force: true }); - cy.get(SERVER_SIDE_EVENT_COUNT, { timeout: DEFAULT_TIMEOUT }) + cy.get(SERVER_SIDE_EVENT_COUNT) .invoke('text') .should('not.equal', '0'); cy.get(FIELDS_BROWSER_CONTAINER).should('exist'); }; -export const loadMoreEvents = () => { - cy.get(LOAD_MORE).click({ force: true }); +export const opensInspectQueryModal = () => { + cy.get(INSPECT_QUERY) + .should('exist') + .trigger('mousemove', { force: true }) + .click({ force: true }); +}; + +export const resetFields = () => { + cy.get(RESET_FIELDS).click({ force: true }); +}; + +export const waitsForEventsToBeLoaded = () => { + cy.get(SERVER_SIDE_EVENT_COUNT) + .should('exist') + .invoke('text') + .should('not.equal', '0'); }; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/fields_browsers.ts b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/fields_browsers.ts deleted file mode 100644 index ae3ed2010a0ae..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/fields_browsers.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { DEFAULT_TIMEOUT } from '../../integration/lib/util/helpers'; -import { KQL_SEARCH_BAR } from '../../screens/hosts/main'; - -export const closeFieldsBrowser = () => { - cy.get(KQL_SEARCH_BAR, { timeout: DEFAULT_TIMEOUT }).click(); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/main.ts b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/main.ts index cbf410b4bc232..eba0c353fbf37 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/main.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/main.ts @@ -4,24 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ -import { DEFAULT_TIMEOUT } from '../../integration/lib/util/helpers'; - import { - EVENTS_TAB, + ALL_HOSTS_TAB, AUTHENTICATIONS_TAB, + EVENTS_TAB, UNCOMMON_PROCESSES_TAB, - ALL_HOSTS_TAB, } from '../../screens/hosts/main'; -/** Clicks the Events tab on the hosts page */ -export const openEvents = () => - cy.get(EVENTS_TAB, { timeout: DEFAULT_TIMEOUT }).click({ force: true }); +export const openAllHosts = () => cy.get(ALL_HOSTS_TAB).click({ force: true }); -export const openAuthentications = () => - cy.get(AUTHENTICATIONS_TAB, { timeout: DEFAULT_TIMEOUT }).click({ force: true }); +export const openAuthentications = () => cy.get(AUTHENTICATIONS_TAB).click({ force: true }); -export const openUncommonProcesses = () => - cy.get(UNCOMMON_PROCESSES_TAB, { timeout: DEFAULT_TIMEOUT }).click({ force: true }); +export const openEvents = () => cy.get(EVENTS_TAB).click({ force: true }); -export const openAllHosts = () => - cy.get(ALL_HOSTS_TAB, { timeout: DEFAULT_TIMEOUT }).click({ force: true }); +export const openUncommonProcesses = () => cy.get(UNCOMMON_PROCESSES_TAB).click({ force: true }); diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/uncommon_processes.ts b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/uncommon_processes.ts similarity index 59% rename from x-pack/legacy/plugins/siem/cypress/tasks/uncommon_processes.ts rename to x-pack/legacy/plugins/siem/cypress/tasks/hosts/uncommon_processes.ts index 007a20c770ca0..c44249acdd964 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/uncommon_processes.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/hosts/uncommon_processes.ts @@ -4,9 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { UNCOMMON_PROCESSES_TABLE } from '../screens/uncommon_processes'; -import { DEFAULT_TIMEOUT } from '../tasks/login'; +import { UNCOMMON_PROCESSES_TABLE } from '../../screens/hosts/uncommon_processes'; export const waitForUncommonProcessesToBeLoaded = () => { - cy.get(UNCOMMON_PROCESSES_TABLE, { timeout: DEFAULT_TIMEOUT }).should('exist'); + cy.get(UNCOMMON_PROCESSES_TABLE).should('exist'); }; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/inspect.ts b/x-pack/legacy/plugins/siem/cypress/tasks/inspect.ts index 26b1c0f7e4e39..109cd9c477968 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/inspect.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/inspect.ts @@ -6,24 +6,20 @@ import { INSPECT_BUTTON_ICON, InspectButtonMetadata } from '../screens/inspect'; -import { DEFAULT_TIMEOUT } from '../tasks/login'; - export const closesModal = () => { - cy.get('[data-test-subj="modal-inspect-close"]', { timeout: DEFAULT_TIMEOUT }).click(); + cy.get('[data-test-subj="modal-inspect-close"]').click(); }; export const openStatsAndTables = (table: InspectButtonMetadata) => { if (table.tabId) { cy.get(table.tabId).click({ force: true }); } - cy.get(table.id, { timeout: DEFAULT_TIMEOUT }); + cy.get(table.id); if (table.altInspectId) { - cy.get(table.altInspectId, { timeout: DEFAULT_TIMEOUT }).trigger('click', { + cy.get(table.altInspectId).trigger('click', { force: true, }); } else { - cy.get(`${table.id} ${INSPECT_BUTTON_ICON}`, { - timeout: DEFAULT_TIMEOUT, - }).trigger('click', { force: true }); + cy.get(`${table.id} ${INSPECT_BUTTON_ICON}`).trigger('click', { force: true }); } }; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/login.ts b/x-pack/legacy/plugins/siem/cypress/tasks/login.ts index d5bf1178d5bdd..1b982d56d79a4 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/login.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/login.ts @@ -4,10 +4,115 @@ * you may not use this file except in compliance with the Elastic License. */ -import { login } from '../integration/lib/login/helpers'; +import * as yaml from 'js-yaml'; -/** The default time in ms to wait for a Cypress command to complete */ -export const DEFAULT_TIMEOUT = 30 * 1000; +/** + * Credentials in the `kibana.dev.yml` config file will be used to authenticate + * with Kibana when credentials are not provided via environment variables + */ +const KIBANA_DEV_YML_PATH = '../../../../config/kibana.dev.yml'; + +/** + * The configuration path in `kibana.dev.yml` to the username to be used when + * authenticating with Kibana. + */ +const ELASTICSEARCH_USERNAME_CONFIG_PATH = 'config.elasticsearch.username'; + +/** + * The configuration path in `kibana.dev.yml` to the password to be used when + * authenticating with Kibana. + */ +const ELASTICSEARCH_PASSWORD_CONFIG_PATH = 'config.elasticsearch.password'; + +/** + * The `CYPRESS_ELASTICSEARCH_USERNAME` environment variable specifies the + * username to be used when authenticating with Kibana + */ +const ELASTICSEARCH_USERNAME = 'ELASTICSEARCH_USERNAME'; + +/** + * The `CYPRESS_ELASTICSEARCH_PASSWORD` environment variable specifies the + * username to be used when authenticating with Kibana + */ +const ELASTICSEARCH_PASSWORD = 'ELASTICSEARCH_PASSWORD'; + +/** + * The Kibana server endpoint used for authentication + */ +const LOGIN_API_ENDPOINT = '/internal/security/login'; + +/** + * Authenticates with Kibana using, if specified, credentials specified by + * environment variables. The credentials in `kibana.dev.yml` will be used + * for authentication when the environment variables are unset. + * + * To speed the execution of tests, prefer this non-interactive authentication, + * which is faster than authentication via Kibana's interactive login page. + */ +export const login = () => { + if (credentialsProvidedByEnvironment()) { + loginViaEnvironmentCredentials(); + } else { + loginViaConfig(); + } +}; + +/** + * Returns `true` if the credentials used to login to Kibana are provided + * via environment variables + */ +const credentialsProvidedByEnvironment = (): boolean => + Cypress.env(ELASTICSEARCH_USERNAME) != null && Cypress.env(ELASTICSEARCH_PASSWORD) != null; + +/** + * Authenticates with Kibana by reading credentials from the + * `CYPRESS_ELASTICSEARCH_USERNAME` and `CYPRESS_ELASTICSEARCH_PASSWORD` + * environment variables, and POSTing the username and password directly to + * Kibana's `/internal/security/login` endpoint, bypassing the login page (for speed). + */ +const loginViaEnvironmentCredentials = () => { + cy.log( + `Authenticating via environment credentials from the \`CYPRESS_${ELASTICSEARCH_USERNAME}\` and \`CYPRESS_${ELASTICSEARCH_PASSWORD}\` environment variables` + ); + + // programmatically authenticate without interacting with the Kibana login page + cy.request({ + body: { + username: Cypress.env(ELASTICSEARCH_USERNAME), + password: Cypress.env(ELASTICSEARCH_PASSWORD), + }, + headers: { 'kbn-xsrf': 'cypress-creds-via-env' }, + method: 'POST', + url: `${Cypress.config().baseUrl}${LOGIN_API_ENDPOINT}`, + }); +}; + +/** + * Authenticates with Kibana by reading credentials from the + * `kibana.dev.yml` file and POSTing the username and password directly to + * Kibana's `/internal/security/login` endpoint, bypassing the login page (for speed). + */ +const loginViaConfig = () => { + cy.log( + `Authenticating via config credentials \`${ELASTICSEARCH_USERNAME_CONFIG_PATH}\` and \`${ELASTICSEARCH_PASSWORD_CONFIG_PATH}\` from \`${KIBANA_DEV_YML_PATH}\`` + ); + + // read the login details from `kibana.dev.yaml` + cy.readFile(KIBANA_DEV_YML_PATH).then(kibanaDevYml => { + const config = yaml.safeLoad(kibanaDevYml); + + // programmatically authenticate without interacting with the Kibana login page + cy.request({ + body: { + username: config.elasticsearch.username, + password: config.elasticsearch.password, + }, + headers: { 'kbn-xsrf': 'cypress-creds-via-config' }, + method: 'POST', + url: `${Cypress.config().baseUrl}${LOGIN_API_ENDPOINT}`, + }); + }); +}; /** * Authenticates with Kibana, visits the specified `url`, and waits for the @@ -20,5 +125,5 @@ export const loginAndWaitForPage = (url: string) => { cy.viewport('macbook-15'); - cy.contains('a', 'SIEM', { timeout: DEFAULT_TIMEOUT }); + cy.contains('a', 'SIEM'); }; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/network/flows.ts b/x-pack/legacy/plugins/siem/cypress/tasks/network/flows.ts index c7b031aabc8cd..c7255f3925d9e 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/network/flows.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/network/flows.ts @@ -5,8 +5,7 @@ */ import { IPS_TABLE_LOADED } from '../../screens/network/flows'; -import { DEFAULT_TIMEOUT } from '../../tasks/login'; export const waitForIpsTableToBeLoaded = () => { - cy.get(IPS_TABLE_LOADED, { timeout: DEFAULT_TIMEOUT }).should('exist'); + cy.get(IPS_TABLE_LOADED).should('exist'); }; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/header.ts b/x-pack/legacy/plugins/siem/cypress/tasks/siem_header.ts similarity index 68% rename from x-pack/legacy/plugins/siem/cypress/tasks/header.ts rename to x-pack/legacy/plugins/siem/cypress/tasks/siem_header.ts index 4067779136d9e..4c43948445c58 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/header.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/siem_header.ts @@ -4,26 +4,25 @@ * you may not use this file except in compliance with the Elastic License. */ -import { DEFAULT_TIMEOUT } from '../tasks/login'; -import { KQL_INPUT, REFRESH_BUTTON } from '../screens/header'; - -export const navigateFromHeaderTo = (page: string) => { - cy.get(page).click({ force: true }); -}; +import { KQL_INPUT, REFRESH_BUTTON } from '../screens/siem_header'; export const clearSearchBar = () => { - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }) + cy.get(KQL_INPUT) .clear() .type('{enter}'); }; +export const kqlSearch = (search: string) => { + cy.get(KQL_INPUT).type(search); +}; + +export const navigateFromHeaderTo = (page: string) => { + cy.get(page).click({ force: true }); +}; + export const refreshPage = () => { cy.get(REFRESH_BUTTON) .click({ force: true }) - .invoke('text', { timeout: DEFAULT_TIMEOUT }) + .invoke('text') .should('not.equal', 'Updating'); }; - -export const kqlSearch = (search: string) => { - cy.get(KQL_INPUT, { timeout: DEFAULT_TIMEOUT }).type(search); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/siem_main.ts b/x-pack/legacy/plugins/siem/cypress/tasks/siem_main.ts index 8501bb3d94e26..2bdc62ecbdc03 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/siem_main.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/siem_main.ts @@ -5,7 +5,10 @@ */ import { MAIN_PAGE, TIMELINE_TOGGLE_BUTTON } from '../screens/siem_main'; -import { DEFAULT_TIMEOUT } from '../tasks/login'; + +export const openTimeline = () => { + cy.get(TIMELINE_TOGGLE_BUTTON).click(); +}; export const openTimelineIfClosed = () => { cy.get(MAIN_PAGE).then($page => { @@ -14,7 +17,3 @@ export const openTimelineIfClosed = () => { } }); }; - -export const openTimeline = () => { - cy.get(TIMELINE_TOGGLE_BUTTON, { timeout: DEFAULT_TIMEOUT }).click(); -}; diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts b/x-pack/legacy/plugins/siem/cypress/tasks/timeline.ts similarity index 79% rename from x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts rename to x-pack/legacy/plugins/siem/cypress/tasks/timeline.ts index 80b5e4379212c..76acdad990a7e 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/timeline/main.ts +++ b/x-pack/legacy/plugins/siem/cypress/tasks/timeline.ts @@ -4,78 +4,74 @@ * you may not use this file except in compliance with the Elastic License. */ -import { DEFAULT_TIMEOUT } from '../../integration/lib/util/helpers'; - import { + CLOSE_TIMELINE_BTN, + CREATE_NEW_TIMELINE, + ID_FIELD, + ID_HEADER_FIELD, + ID_TOGGLE_FIELD, SEARCH_OR_FILTER_CONTAINER, - TIMELINE_FIELDS_BUTTON, SERVER_SIDE_EVENT_COUNT, - TIMELINE_SETTINGS_ICON, + TIMELINE_FIELDS_BUTTON, TIMELINE_INSPECT_BUTTON, - CREATE_NEW_TIMELINE, - CLOSE_TIMELINE_BTN, - TOGGLE_TIMELINE_EXPAND_EVENT, - TIMESTAMP_TOGGLE_FIELD, - ID_TOGGLE_FIELD, - ID_HEADER_FIELD, - ID_FIELD, + TIMELINE_SETTINGS_ICON, TIMELINE_TITLE, -} from '../../screens/timeline/main'; + TIMESTAMP_TOGGLE_FIELD, + TOGGLE_TIMELINE_EXPAND_EVENT, +} from '../screens/timeline'; -import { drag, drop } from '../../tasks/common'; +import { drag, drop } from '../tasks/common'; export const hostExistsQuery = 'host.name: *'; -export const populateTimeline = () => { - executeTimelineKQL(hostExistsQuery); - cy.get(SERVER_SIDE_EVENT_COUNT, { timeout: DEFAULT_TIMEOUT }) - .invoke('text') - .should('be.above', 0); +export const checkIdToggleField = () => { + cy.get(ID_TOGGLE_FIELD).should('not.exist'); + + cy.get(ID_TOGGLE_FIELD).check({ + force: true, + }); }; -export const openTimelineFieldsBrowser = () => { - cy.get(TIMELINE_FIELDS_BUTTON).click({ force: true }); +export const createNewTimeline = () => { + cy.get(TIMELINE_SETTINGS_ICON).click({ force: true }); + cy.get(CREATE_NEW_TIMELINE).click(); + cy.get(CLOSE_TIMELINE_BTN).click({ force: true }); }; export const executeTimelineKQL = (query: string) => { cy.get(`${SEARCH_OR_FILTER_CONTAINER} input`).type(`${query} {enter}`); }; -export const openTimelineSettings = () => { - cy.get(TIMELINE_SETTINGS_ICON).trigger('click', { force: true }); +export const expandFirstTimelineEventDetails = () => { + cy.get(TOGGLE_TIMELINE_EXPAND_EVENT) + .first() + .click({ force: true }); +}; + +export const openTimelineFieldsBrowser = () => { + cy.get(TIMELINE_FIELDS_BUTTON).click({ force: true }); }; export const openTimelineInspectButton = () => { - cy.get(TIMELINE_INSPECT_BUTTON, { timeout: DEFAULT_TIMEOUT }).should('not.be.disabled'); + cy.get(TIMELINE_INSPECT_BUTTON).should('not.be.disabled'); cy.get(TIMELINE_INSPECT_BUTTON).trigger('click', { force: true }); }; -export const createNewTimeline = () => { - cy.get(TIMELINE_SETTINGS_ICON).click({ force: true }); - cy.get(CREATE_NEW_TIMELINE).click(); - cy.get(CLOSE_TIMELINE_BTN).click({ force: true }); +export const openTimelineSettings = () => { + cy.get(TIMELINE_SETTINGS_ICON).trigger('click', { force: true }); }; -export const expandFirstTimelineEventDetails = () => { - cy.get(TOGGLE_TIMELINE_EXPAND_EVENT, { timeout: DEFAULT_TIMEOUT }) - .first() - .click({ force: true }); +export const populateTimeline = () => { + executeTimelineKQL(hostExistsQuery); + cy.get(SERVER_SIDE_EVENT_COUNT) + .invoke('text') + .should('be.above', 0); }; export const uncheckTimestampToggleField = () => { cy.get(TIMESTAMP_TOGGLE_FIELD).should('exist'); - cy.get(TIMESTAMP_TOGGLE_FIELD, { - timeout: DEFAULT_TIMEOUT, - }).uncheck({ force: true }); -}; - -export const checkIdToggleField = () => { - cy.get(ID_TOGGLE_FIELD).should('not.exist'); - - cy.get(ID_TOGGLE_FIELD).check({ - force: true, - }); + cy.get(TIMESTAMP_TOGGLE_FIELD).uncheck({ force: true }); }; export const dragAndDropIdToggleFieldToTimeline = () => { @@ -89,5 +85,5 @@ export const dragAndDropIdToggleFieldToTimeline = () => { }; export const addNameToTimeline = (name: string) => { - cy.get(TIMELINE_TITLE, { timeout: DEFAULT_TIMEOUT }).type(name); + cy.get(TIMELINE_TITLE).type(name); }; diff --git a/x-pack/legacy/plugins/siem/cypress/urls/navigation.ts b/x-pack/legacy/plugins/siem/cypress/urls/navigation.ts index 164a117b82475..8fdc939e7ee51 100644 --- a/x-pack/legacy/plugins/siem/cypress/urls/navigation.ts +++ b/x-pack/legacy/plugins/siem/cypress/urls/navigation.ts @@ -4,8 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -export const TIMELINES_PAGE = '/app/siem#/timelines'; -export const OVERVIEW_PAGE = '/app/siem#/overview'; export const HOSTS_PAGE = '/app/siem#/hosts/allHosts'; export const HOSTS_PAGE_TAB_URLS = { allHosts: '/app/siem#/hosts/allHosts', @@ -14,3 +12,6 @@ export const HOSTS_PAGE_TAB_URLS = { events: '/app/siem#/hosts/events', uncommonProcesses: '/app/siem#/hosts/uncommonProcesses', }; +export const NETWORK_PAGE = '/app/siem#/network'; +export const OVERVIEW_PAGE = '/app/siem#/overview'; +export const TIMELINES_PAGE = '/app/siem#/timelines';