diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_prepackaged_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_prepackaged_rules.ts index e787a3594dfe6..602b9929485e0 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_prepackaged_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_prepackaged_rules.ts @@ -13,7 +13,7 @@ import { createSignalsIndex, deleteAllAlerts, deleteSignalsIndex } from './utils // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('add_prepackaged_rules', () => { describe('validation errors', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts index 46645a9b5a944..43630d81e64ea 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts @@ -25,7 +25,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext) => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('create_rules', () => { describe('validation errors', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts index 117300be417d5..7d406777e23f0 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts @@ -23,7 +23,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('create_rules_bulk', () => { describe('validation errors', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules.ts index fb701681419d8..4902060f2c6ee 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules.ts @@ -23,7 +23,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('delete_rules', () => { describe('deleting rules', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules_bulk.ts index ac58ba4c77e4e..8ddb5f0656019 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules_bulk.ts @@ -23,7 +23,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('delete_rules_bulk', () => { describe('deleting rules bulk using DELETE', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/export_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/export_rules.ts index 51bdb9e45dc0c..ed1f92457e782 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/export_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/export_rules.ts @@ -21,7 +21,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('export_rules', () => { describe('exporting rules', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_rules.ts index feb4ecd125f7e..c0356f877377a 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_rules.ts @@ -22,7 +22,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('find_rules', () => { beforeEach(async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts index 44847d5c8146c..b4c9632320271 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts @@ -19,7 +19,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('find_statuses', () => { beforeEach(async () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_prepackaged_rules_status.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_prepackaged_rules_status.ts index e2dce77c1d70a..a366c04330e9b 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_prepackaged_rules_status.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_prepackaged_rules_status.ts @@ -16,7 +16,7 @@ import { createSignalsIndex, deleteAllAlerts, deleteSignalsIndex, getSimpleRule // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('get_prepackaged_rules_status', () => { describe('getting prepackaged rules status', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/import_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/import_rules.ts index 868dafedc6849..ac0f51abe1c10 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/import_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/import_rules.ts @@ -22,7 +22,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('import_rules', () => { describe('importing rules without an index', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules.ts index c3ecf79e58955..295bd456eeebf 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules.ts @@ -22,7 +22,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext) => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('patch_rules', () => { describe('patch rules', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules_bulk.ts index 8515d1cf404ea..14c9ca76f6aac 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules_bulk.ts @@ -22,7 +22,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext) => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('patch_rules_bulk', () => { describe('patch rules bulk', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/read_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/read_rules.ts index 4d7449dae2dbd..1ae6871348bbb 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/read_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/read_rules.ts @@ -23,7 +23,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext) => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('read_rules', () => { describe('reading rules', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts index 4b81b7d4304b2..42501c005d994 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts @@ -22,7 +22,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext) => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('update_rules', () => { describe('update rules', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts index 760e17ae1752e..b7f998d4043f7 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts @@ -22,7 +22,7 @@ import { // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext) => { const supertest = getService('supertest'); - const es = getService('legacyEs'); + const es = getService('es'); describe('update_rules_bulk', () => { describe('update rules bulk', () => { diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/utils.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/utils.ts index e508cf1aaa2e0..5eabecf96f3e6 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/utils.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/utils.ts @@ -4,6 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ +import { Client } from '@elastic/elasticsearch'; +import { SuperTest } from 'supertest'; +import supertestAsPromised from 'supertest-as-promised'; import { OutputRuleAlertRest } from '../../../../plugins/siem/server/lib/detection_engine/types'; import { DETECTION_ENGINE_INDEX_URL } from '../../../../plugins/siem/common/constants'; @@ -187,12 +190,13 @@ export const getSimpleMlRuleOutput = (ruleId = 'rule-1'): Partial => { +export const deleteAllAlerts = async (es: Client): Promise => { await es.deleteByQuery({ index: '.kibana', q: 'type:alert', - waitForCompletion: true, - refresh: 'wait_for', + wait_for_completion: true, + refresh: true, + body: {}, }); }; @@ -200,12 +204,13 @@ export const deleteAllAlerts = async (es: any): Promise => { * Remove all rules statuses from the .kibana index * @param es The ElasticSearch handle */ -export const deleteAllRulesStatuses = async (es: any): Promise => { +export const deleteAllRulesStatuses = async (es: Client): Promise => { await es.deleteByQuery({ index: '.kibana', q: 'type:siem-detection-engine-rule-status', - waitForCompletion: true, - refresh: 'wait_for', + wait_for_completion: true, + refresh: true, + body: {}, }); }; @@ -213,7 +218,9 @@ export const deleteAllRulesStatuses = async (es: any): Promise => { * Creates the signals index for use inside of beforeEach blocks of tests * @param supertest The supertest client library */ -export const createSignalsIndex = async (supertest: any): Promise => { +export const createSignalsIndex = async ( + supertest: SuperTest +): Promise => { await supertest .post(DETECTION_ENGINE_INDEX_URL) .set('kbn-xsrf', 'true') @@ -225,7 +232,9 @@ export const createSignalsIndex = async (supertest: any): Promise => { * Deletes the signals index for use inside of afterEach blocks of tests * @param supertest The supertest client library */ -export const deleteSignalsIndex = async (supertest: any): Promise => { +export const deleteSignalsIndex = async ( + supertest: SuperTest +): Promise => { await supertest .delete(DETECTION_ENGINE_INDEX_URL) .set('kbn-xsrf', 'true')