mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[SIEM][Detection Engine] Moves functional tests from legacyEs to Es and improves types (#65709)
Moves functional tests from "legacyEs" to "Es" and improves types - [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios
This commit is contained in:
parent
e029e35a5b
commit
fe26a79608
16 changed files with 32 additions and 23 deletions
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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<OutputRuleAler
|
|||
* Remove all alerts from the .kibana index
|
||||
* @param es The ElasticSearch handle
|
||||
*/
|
||||
export const deleteAllAlerts = async (es: any): Promise<void> => {
|
||||
export const deleteAllAlerts = async (es: Client): Promise<void> => {
|
||||
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<void> => {
|
|||
* Remove all rules statuses from the .kibana index
|
||||
* @param es The ElasticSearch handle
|
||||
*/
|
||||
export const deleteAllRulesStatuses = async (es: any): Promise<void> => {
|
||||
export const deleteAllRulesStatuses = async (es: Client): Promise<void> => {
|
||||
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<void> => {
|
|||
* 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<void> => {
|
||||
export const createSignalsIndex = async (
|
||||
supertest: SuperTest<supertestAsPromised.Test>
|
||||
): Promise<void> => {
|
||||
await supertest
|
||||
.post(DETECTION_ENGINE_INDEX_URL)
|
||||
.set('kbn-xsrf', 'true')
|
||||
|
@ -225,7 +232,9 @@ export const createSignalsIndex = async (supertest: any): Promise<void> => {
|
|||
* 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<void> => {
|
||||
export const deleteSignalsIndex = async (
|
||||
supertest: SuperTest<supertestAsPromised.Test>
|
||||
): Promise<void> => {
|
||||
await supertest
|
||||
.delete(DETECTION_ENGINE_INDEX_URL)
|
||||
.set('kbn-xsrf', 'true')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue