diff --git a/x-pack/test/alerting_api_integration/basic/tests/alerts/basic_noop_alert_type.ts b/x-pack/test/alerting_api_integration/basic/tests/alerts/basic_noop_alert_type.ts index 805f4440909ec..a176d4e73ccf3 100644 --- a/x-pack/test/alerting_api_integration/basic/tests/alerts/basic_noop_alert_type.ts +++ b/x-pack/test/alerting_api_integration/basic/tests/alerts/basic_noop_alert_type.ts @@ -5,19 +5,19 @@ * 2.0. */ -import { getTestAlertData } from '../../../common/lib'; +import { getTestRuleData } from '../../../common/lib'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export -export default function basicAlertTest({ getService }: FtrProviderContext) { +export default function basicRuleTest({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - describe('basic alert', () => { - it('should return 200 when creating a basic license alert', async () => { + describe('basic rule', () => { + it('should return 200 when creating a basic license rule', async () => { await supertest .post(`/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); }); }); diff --git a/x-pack/test/alerting_api_integration/basic/tests/alerts/gold_noop_alert_type.ts b/x-pack/test/alerting_api_integration/basic/tests/alerts/gold_noop_alert_type.ts index 9e66282d42454..5726ad8d5d86c 100644 --- a/x-pack/test/alerting_api_integration/basic/tests/alerts/gold_noop_alert_type.ts +++ b/x-pack/test/alerting_api_integration/basic/tests/alerts/gold_noop_alert_type.ts @@ -5,19 +5,19 @@ * 2.0. */ -import { getTestAlertData } from '../../../common/lib'; +import { getTestRuleData } from '../../../common/lib'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export export default function emailTest({ getService }: FtrProviderContext) { const supertest = getService('supertest'); - describe('create gold noop alert', () => { - it('should return 403 when creating an gold alert', async () => { + describe('create gold noop rule', () => { + it('should return 403 when creating an gold rule', async () => { await supertest .post(`/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ rule_type_id: 'test.gold.noop' })) + .send(getTestRuleData({ rule_type_id: 'test.gold.noop' })) .expect(403, { statusCode: 403, error: 'Forbidden', diff --git a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/plugin.ts b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/plugin.ts index 7937a9a2db92c..0f345c81f08b4 100644 --- a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/plugin.ts +++ b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/server/plugin.ts @@ -5,9 +5,15 @@ * 2.0. */ -import { Plugin, CoreSetup, Logger, PluginInitializerContext } from 'kibana/server'; +import { Plugin, CoreSetup, CoreStart, Logger, PluginInitializerContext } from 'kibana/server'; +import { Subject } from 'rxjs'; +import { first } from 'rxjs/operators'; import { PluginSetupContract as ActionsPluginSetup } from '../../../../../../../plugins/actions/server/plugin'; import { PluginSetupContract as AlertingPluginSetup } from '../../../../../../../plugins/alerting/server/plugin'; +import { + TaskManagerSetupContract, + TaskManagerStartContract, +} from '../../../../../../../plugins/task_manager/server/plugin'; import { EncryptedSavedObjectsPluginStart } from '../../../../../../../plugins/encrypted_saved_objects/server'; import { PluginSetupContract as FeaturesPluginSetup } from '../../../../../../../plugins/features/server'; import { defineAlertTypes } from './alert_types'; @@ -21,6 +27,7 @@ export interface FixtureSetupDeps { features: FeaturesPluginSetup; actions: ActionsPluginSetup; alerting: AlertingPluginSetup; + taskManager: TaskManagerSetupContract; } export interface FixtureStartDeps { @@ -28,11 +35,17 @@ export interface FixtureStartDeps { security?: SecurityPluginStart; spaces?: SpacesPluginStart; actions: ActionsPluginStart; + taskManager: TaskManagerStartContract; } export class FixturePlugin implements Plugin { private readonly logger: Logger; + taskManagerStart$: Subject = new Subject(); + taskManagerStart: Promise = this.taskManagerStart$ + .pipe(first()) + .toPromise(); + constructor(initializerContext: PluginInitializerContext) { this.logger = initializerContext.logger.get('fixtures', 'plugins', 'alerts'); } @@ -127,9 +140,12 @@ export class FixturePlugin implements Plugin, { logger }: { logger: Logger }) { +export function defineRoutes( + core: CoreSetup, + taskManagerStart: Promise, + { logger }: { logger: Logger } +) { const router = core.http.createRouter(); router.put( { @@ -324,4 +329,39 @@ export function defineRoutes(core: CoreSetup, { logger }: { lo } } ); + + router.post( + { + path: `/api/alerting_actions_telemetry/run_now`, + validate: { + body: schema.object({ + taskId: schema.string({ + validate: (telemetryTaskId: string) => { + if ( + ['Alerting-alerting_telemetry', 'Actions-actions_telemetry'].includes( + telemetryTaskId + ) + ) { + return; + } + return 'invalid telemetry task id'; + }, + }), + }), + }, + }, + async function ( + context: RequestHandlerContext, + req: KibanaRequest, + res: KibanaResponseFactory + ): Promise> { + const { taskId } = req.body; + try { + const taskManager = await taskManagerStart; + return res.ok({ body: await taskManager.runNow(taskId) }); + } catch (err) { + return res.ok({ body: { id: taskId, error: `${err}` } }); + } + } + ); } diff --git a/x-pack/test/alerting_api_integration/common/lib/alert_utils.ts b/x-pack/test/alerting_api_integration/common/lib/alert_utils.ts index ea16351b49543..9da73e1ca6f43 100644 --- a/x-pack/test/alerting_api_integration/common/lib/alert_utils.ts +++ b/x-pack/test/alerting_api_integration/common/lib/alert_utils.ts @@ -9,7 +9,7 @@ import { Space, User } from '../types'; import { ObjectRemover } from './object_remover'; import { getUrlPrefix } from './space_test_utils'; import { ES_TEST_INDEX_NAME } from './es_test_index_tool'; -import { getTestAlertData } from './get_test_alert_data'; +import { getTestRuleData } from './get_test_rule_data'; export interface AlertUtilsOpts { user?: User; @@ -293,7 +293,7 @@ export class AlertUtils { request = request.auth(this.user.username, this.user.password); } const response = await request.send({ - ...getTestAlertData(), + ...getTestRuleData(), ...overwrites, }); if (response.statusCode === 200) { diff --git a/x-pack/test/alerting_api_integration/common/lib/get_test_alert_data.ts b/x-pack/test/alerting_api_integration/common/lib/get_test_rule_data.ts similarity index 91% rename from x-pack/test/alerting_api_integration/common/lib/get_test_alert_data.ts rename to x-pack/test/alerting_api_integration/common/lib/get_test_rule_data.ts index 22dc93b110a07..ace220a5e81de 100644 --- a/x-pack/test/alerting_api_integration/common/lib/get_test_alert_data.ts +++ b/x-pack/test/alerting_api_integration/common/lib/get_test_rule_data.ts @@ -5,7 +5,7 @@ * 2.0. */ -export function getTestAlertData(overwrites = {}) { +export function getTestRuleData(overwrites = {}) { return { enabled: true, name: 'abc', diff --git a/x-pack/test/alerting_api_integration/common/lib/index.ts b/x-pack/test/alerting_api_integration/common/lib/index.ts index 305c42b5c1d64..df7895ed03f6a 100644 --- a/x-pack/test/alerting_api_integration/common/lib/index.ts +++ b/x-pack/test/alerting_api_integration/common/lib/index.ts @@ -8,7 +8,7 @@ export { ObjectRemover } from './object_remover'; export { getUrlPrefix } from './space_test_utils'; export { ES_TEST_INDEX_NAME, ESTestIndexTool } from './es_test_index_tool'; -export { getTestAlertData } from './get_test_alert_data'; +export { getTestRuleData } from './get_test_rule_data'; export { AlertUtils, getConsumerUnauthorizedErrorMessage, diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/get_all.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/get_all.ts index 5692e5dd8f8b2..8ae50b9158487 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/get_all.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/get_all.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { UserAtSpaceScenarios } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export @@ -134,7 +134,7 @@ export default function getAllActionTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ actions: [ { group: 'default', diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts index c3e3c4fc93005..37455149a2a42 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/alerts.ts @@ -14,7 +14,7 @@ import { ESTestIndexTool, ES_TEST_INDEX_NAME, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, AlertUtils, getConsumerUnauthorizedErrorMessage, @@ -494,7 +494,7 @@ instanceStateValue: true .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.always-firing', params: { index: ES_TEST_INDEX_NAME, @@ -603,7 +603,7 @@ instanceStateValue: true .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.authorization', params: { callClusterAuthorizationIndex: authorizationIndex, @@ -711,7 +711,7 @@ instanceStateValue: true .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.always-firing', params: { index: ES_TEST_INDEX_NAME, diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts index eaa73facb3734..3044142e3c54c 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { UserAtSpaceScenarios } from '../../scenarios'; import { checkAAD, - getTestAlertData, + getTestRuleData, getConsumerUnauthorizedErrorMessage, getUrlPrefix, ObjectRemover, @@ -57,7 +57,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ actions: [ { id: createdAction.id, @@ -155,7 +155,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', }) @@ -194,7 +194,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', }) @@ -244,7 +244,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.noop', consumer: 'alerts', }) @@ -290,7 +290,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.noop', consumer: 'some consumer patrick invented', }) @@ -325,7 +325,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .auth(user.username, user.password) - .send(getTestAlertData({ enabled: false })); + .send(getTestRuleData({ enabled: false })); switch (scenario.id) { case 'no_kibana_privileges at space1': @@ -361,7 +361,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ name: ' leading and trailing whitespace ', }) ); @@ -400,7 +400,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.unregistered-alert-type', }) ); @@ -458,7 +458,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.validation', }) ); @@ -500,7 +500,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .auth(user.username, user.password) - .send(getTestAlertData(getTestAlertData({ schedule: { interval: '10x' } }))); + .send(getTestRuleData({ schedule: { interval: '10x' } })); switch (scenario.id) { case 'no_kibana_privileges at space1': @@ -527,7 +527,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .auth(user.username, user.password) - .send(getTestAlertData(getTestAlertData({ schedule: { interval: '0s' } }))); + .send(getTestRuleData({ schedule: { interval: '0s' } })); switch (scenario.id) { case 'no_kibana_privileges at space1': diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/delete.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/delete.ts index d43fb2e7d835f..93e39a011ba3a 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/delete.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/delete.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { UserAtSpaceScenarios } from '../../scenarios'; import { getUrlPrefix, - getTestAlertData, + getTestRuleData, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, ObjectRemover, @@ -42,7 +42,7 @@ export default function createDeleteTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); const response = await supertestWithoutAuth @@ -91,7 +91,7 @@ export default function createDeleteTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', }) @@ -144,7 +144,7 @@ export default function createDeleteTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', }) @@ -211,7 +211,7 @@ export default function createDeleteTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.noop', consumer: 'alerts', }) @@ -270,7 +270,7 @@ export default function createDeleteTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -303,7 +303,7 @@ export default function createDeleteTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); await retry.try(async () => { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/disable.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/disable.ts index 66f01000ede5e..8a4266eb8dc8a 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/disable.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/disable.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, @@ -58,7 +58,7 @@ export default function createDisableAlertTests({ getService }: FtrProviderConte .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: true, actions: [ { @@ -121,7 +121,7 @@ export default function createDisableAlertTests({ getService }: FtrProviderConte .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', enabled: true, @@ -170,7 +170,7 @@ export default function createDisableAlertTests({ getService }: FtrProviderConte .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', enabled: true, @@ -230,7 +230,7 @@ export default function createDisableAlertTests({ getService }: FtrProviderConte .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.noop', consumer: 'alerts', enabled: true, @@ -285,7 +285,7 @@ export default function createDisableAlertTests({ getService }: FtrProviderConte const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: true })) + .send(getTestRuleData({ enabled: true })) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -351,7 +351,7 @@ export default function createDisableAlertTests({ getService }: FtrProviderConte const { body: createdAlert } = await supertest .post(`${getUrlPrefix('other')}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: true })) + .send(getTestRuleData({ enabled: true })) .expect(200); objectRemover.add('other', createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts index 1589a63cb7108..205bfe3fda2ab 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/enable.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, @@ -60,7 +60,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, actions: [ { @@ -146,7 +146,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', enabled: false, @@ -195,7 +195,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', enabled: false, @@ -249,7 +249,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.noop', consumer: 'alerts', enabled: false, @@ -304,7 +304,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -375,7 +375,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex const { body: createdAlert } = await supertest .post(`${getUrlPrefix('other')}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add('other', createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts index 940203a9b1f8c..04ff3d929dc15 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/event_log.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover, getEventLog } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover, getEventLog } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { validateEvent } from '../../../spaces_only/tests/alerting/event_log'; @@ -27,7 +27,7 @@ export default function eventLogTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(spaceId)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.noop', schedule: { interval: '1s' }, throttle: null, diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/excluded.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/excluded.ts index add30b178c7e6..eae80da85dc59 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/excluded.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/excluded.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import { UserAtSpaceScenarios } from '../../scenarios'; import { - getTestAlertData, + getTestRuleData, getUrlPrefix, ObjectRemover, getEventLog, @@ -57,7 +57,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .auth(scenario.user.username, scenario.user.password) .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.always-firing', schedule: { interval: '1s' }, throttle: '1s', diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/execution_status.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/execution_status.ts index 2bae1c541bc48..dba73cba184dd 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/execution_status.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/execution_status.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import { AlertExecutionStatusErrorReasons } from '../../../../../plugins/alerting/common'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export @@ -28,7 +28,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(spaceId)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.noop', schedule: { interval: '1s' }, }) diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/find.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/find.ts index 3274e25e48301..f6ba70e7c2197 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/find.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/find.ts @@ -10,7 +10,7 @@ import { SuperTest, Test } from 'supertest'; import { chunk, omit } from 'lodash'; import uuid from 'uuid'; import { UserAtSpaceScenarios } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; const findTestUtils = ( @@ -29,7 +29,7 @@ const findTestUtils = ( const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -94,7 +94,7 @@ const findTestUtils = ( it('should filter out types that the user is not authorized to `get` retaining pagination', async () => { async function createNoOpAlert(overrides = {}) { - const alert = getTestAlertData(overrides); + const alert = getTestRuleData(overrides); const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') @@ -212,7 +212,7 @@ const findTestUtils = ( .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, actions: [ { @@ -297,7 +297,7 @@ const findTestUtils = ( .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, tags: [myTag], rule_type_id: 'test.restricted-noop', @@ -312,7 +312,7 @@ const findTestUtils = ( .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ tags: [myTag], rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', @@ -374,7 +374,7 @@ const findTestUtils = ( .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, tags: [myTag], rule_type_id: 'test.restricted-noop', @@ -389,7 +389,7 @@ const findTestUtils = ( .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ tags: [myTag], rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', @@ -451,7 +451,7 @@ const findTestUtils = ( const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get.ts index 05b053f468a69..6d072b2e26f45 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get.ts @@ -10,7 +10,7 @@ import { SuperTest, Test } from 'supertest'; import { UserAtSpaceScenarios } from '../../scenarios'; import { getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, @@ -32,7 +32,7 @@ const getTestUtils = ( const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -96,7 +96,7 @@ const getTestUtils = ( .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', }) @@ -143,7 +143,7 @@ const getTestUtils = ( .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', }) @@ -201,7 +201,7 @@ const getTestUtils = ( .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.restricted-noop', consumer: 'alerts', }) @@ -258,7 +258,7 @@ const getTestUtils = ( const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get_alert_state.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get_alert_state.ts index e00d8e53e438e..3bdfe49464fcf 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get_alert_state.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get_alert_state.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { getUrlPrefix, ObjectRemover, - getTestAlertData, + getTestRuleData, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, } from '../../../common/lib'; @@ -33,7 +33,7 @@ export default function createGetAlertStateTests({ getService }: FtrProviderCont const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -69,7 +69,7 @@ export default function createGetAlertStateTests({ getService }: FtrProviderCont .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', }) @@ -123,7 +123,7 @@ export default function createGetAlertStateTests({ getService }: FtrProviderCont const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get_alert_summary.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get_alert_summary.ts index 3becd487116f7..eb4e592a91d8a 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get_alert_summary.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get_alert_summary.ts @@ -10,7 +10,7 @@ import { omit } from 'lodash'; import { getUrlPrefix, ObjectRemover, - getTestAlertData, + getTestRuleData, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, } from '../../../common/lib'; @@ -34,7 +34,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo const { body: createdRule } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdRule.id, 'rule', 'alerting'); @@ -98,7 +98,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', }) @@ -154,7 +154,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo const { body: createdRule } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdRule.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/health.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/health.ts index 22bf2cdc4204b..d51cf8cc96af9 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/health.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/health.ts @@ -10,7 +10,7 @@ import { UserAtSpaceScenarios } from '../../scenarios'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, AlertUtils, ESTestIndexTool, @@ -105,7 +105,7 @@ export default function createFindTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ schedule: { interval: '5m', }, diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mustache_templates.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mustache_templates.ts index 8344d4a281ba1..7e3a7599a73e0 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mustache_templates.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mustache_templates.ts @@ -19,7 +19,7 @@ import httpProxy from 'http-proxy'; import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { getSlackServer } from '../../../common/fixtures/plugins/actions_simulators/server/plugin'; import { getHttpProxyServer } from '../../../common/lib/get_proxy_server'; @@ -81,7 +81,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces[0].id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ name: 'testing context variable kibanaBaseUrl', rule_type_id: 'test.patternFiring', params: { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mute_all.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mute_all.ts index 993b66353756f..bb570e5754e99 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mute_all.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mute_all.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, @@ -49,7 +49,7 @@ export default function createMuteAlertTests({ getService }: FtrProviderContext) .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, actions: [ { @@ -117,7 +117,7 @@ export default function createMuteAlertTests({ getService }: FtrProviderContext) .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', @@ -173,7 +173,7 @@ export default function createMuteAlertTests({ getService }: FtrProviderContext) .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', @@ -240,7 +240,7 @@ export default function createMuteAlertTests({ getService }: FtrProviderContext) .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.restricted-noop', consumer: 'alerts', diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mute_instance.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mute_instance.ts index 4948737e0778a..3948f910423a9 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mute_instance.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/mute_instance.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, @@ -49,7 +49,7 @@ export default function createMuteAlertInstanceTests({ getService }: FtrProvider .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, actions: [ { @@ -117,7 +117,7 @@ export default function createMuteAlertInstanceTests({ getService }: FtrProvider .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', @@ -173,7 +173,7 @@ export default function createMuteAlertInstanceTests({ getService }: FtrProvider .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', @@ -240,7 +240,7 @@ export default function createMuteAlertInstanceTests({ getService }: FtrProvider .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.restricted-noop', consumer: 'alerts', @@ -306,7 +306,7 @@ export default function createMuteAlertInstanceTests({ getService }: FtrProvider const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/unmute_all.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/unmute_all.ts index 526f809033646..f9c1bce2b0318 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/unmute_all.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/unmute_all.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, @@ -49,7 +49,7 @@ export default function createUnmuteAlertTests({ getService }: FtrProviderContex .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, actions: [ { @@ -122,7 +122,7 @@ export default function createUnmuteAlertTests({ getService }: FtrProviderContex .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', @@ -183,7 +183,7 @@ export default function createUnmuteAlertTests({ getService }: FtrProviderContex .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', @@ -255,7 +255,7 @@ export default function createUnmuteAlertTests({ getService }: FtrProviderContex .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.restricted-noop', consumer: 'alerts', diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/unmute_instance.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/unmute_instance.ts index 9c045db888391..17ee25e822a6d 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/unmute_instance.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/unmute_instance.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, @@ -49,7 +49,7 @@ export default function createMuteAlertInstanceTests({ getService }: FtrProvider .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, actions: [ { @@ -122,7 +122,7 @@ export default function createMuteAlertInstanceTests({ getService }: FtrProvider .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', @@ -183,7 +183,7 @@ export default function createMuteAlertInstanceTests({ getService }: FtrProvider .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', @@ -255,7 +255,7 @@ export default function createMuteAlertInstanceTests({ getService }: FtrProvider .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ enabled: false, rule_type_id: 'test.restricted-noop', consumer: 'alerts', diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts index e628f0b3d950e..b2a1ae223f62c 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts @@ -11,7 +11,7 @@ import { UserAtSpaceScenarios } from '../../scenarios'; import { checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, ensureDatetimeIsWithinRange, getConsumerUnauthorizedErrorMessage, @@ -55,7 +55,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -156,7 +156,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', }) @@ -240,7 +240,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', }) @@ -335,7 +335,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.restricted-noop', consumer: 'alerts', }) @@ -429,7 +429,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -522,7 +522,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -574,7 +574,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -618,7 +618,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -691,7 +691,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.validation', params: { param1: 'test', @@ -753,7 +753,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .auth(user.username, user.password) .send( - getTestAlertData({ + getTestRuleData({ schedule: { interval: '10x' }, enabled: undefined, consumer: undefined, @@ -785,7 +785,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ schedule: { interval: '30m' }, }) ) @@ -931,7 +931,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ schedule: { interval: '1m' }, }) ) diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update_api_key.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update_api_key.ts index a434109a18933..1c25ec550c41e 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update_api_key.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update_api_key.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, getConsumerUnauthorizedErrorMessage, getProducerUnauthorizedErrorMessage, @@ -50,7 +50,7 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ actions: [ { id: createdAction.id, @@ -116,7 +116,7 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.restricted-noop', consumer: 'alertsRestrictedFixture', }) @@ -170,7 +170,7 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.unrestricted-noop', consumer: 'alertsFixture', }) @@ -235,7 +235,7 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.restricted-noop', consumer: 'alerts', }) @@ -299,7 +299,7 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte const { body: createdAlert } = await supertest .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(space.id, createdAlert.id, 'rule', 'alerting'); @@ -363,7 +363,7 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte const { body: createdAlert } = await supertest .post(`${getUrlPrefix('other')}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add('other', createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/index.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/index.ts index 211fe9ec26863..2b26410afeaed 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/index.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/index.ts @@ -60,6 +60,7 @@ export default function alertingApiIntegrationTests({ loadTestFile }: FtrProvide describe('alerting api integration security and spaces enabled', function () { this.tags('ciGroup17'); + loadTestFile(require.resolve('./telemetry')); loadTestFile(require.resolve('./actions')); loadTestFile(require.resolve('./alerting')); }); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/telemetry/actions_telemetry.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/telemetry/actions_telemetry.ts new file mode 100644 index 0000000000000..350f0019641b8 --- /dev/null +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/telemetry/actions_telemetry.ts @@ -0,0 +1,241 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import { Spaces, Superuser } from '../../scenarios'; +import { + getUrlPrefix, + getEventLog, + getTestRuleData, + ObjectRemover, + TaskManagerDoc, +} from '../../../common/lib'; +import { FtrProviderContext } from '../../../common/ftr_provider_context'; + +// eslint-disable-next-line import/no-default-export +export default function createActionsTelemetryTests({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const es = getService('es'); + const retry = getService('retry'); + const supertestWithoutAuth = getService('supertestWithoutAuth'); + + describe('actions telemetry', () => { + const alwaysFiringRuleId: { [key: string]: string } = {}; + const objectRemover = new ObjectRemover(supertest); + + before(async () => { + // reset the state in the telemetry task + await es.update({ + id: `task:Actions-actions_telemetry`, + index: '.kibana_task_manager', + body: { + doc: { + task: { + state: '{}', + }, + }, + }, + }); + }); + after(() => objectRemover.removeAll()); + + async function createConnector(opts: { name: string; space: string; connectorTypeId: string }) { + const { name, space, connectorTypeId } = opts; + const { body: createdConnector } = await supertestWithoutAuth + .post(`${getUrlPrefix(space)}/api/actions/connector`) + .set('kbn-xsrf', 'foo') + .auth(Superuser.username, Superuser.password) + .send({ + name, + connector_type_id: connectorTypeId, + config: {}, + secrets: {}, + }) + .expect(200); + objectRemover.add(space, createdConnector.id, 'action', 'actions'); + return createdConnector.id; + } + + async function createRule(opts: { space: string; ruleOverwrites: any }) { + const { ruleOverwrites, space } = opts; + const ruleResponse = await supertestWithoutAuth + .post(`${getUrlPrefix(space)}/api/alerting/rule`) + .set('kbn-xsrf', 'foo') + .auth(Superuser.username, Superuser.password) + .send(getTestRuleData(ruleOverwrites)); + expect(ruleResponse.status).to.eql(200); + objectRemover.add(space, ruleResponse.body.id, 'rule', 'alerting'); + return ruleResponse.body.id; + } + + async function setup() { + // Create rules and connectors in multiple spaces + for (const space of Spaces) { + const noopConnectorId = await createConnector({ + name: 'noop connector', + space: space.id, + connectorTypeId: 'test.noop', + }); + const failingConnectorId = await createConnector({ + name: 'connector that throws', + space: space.id, + connectorTypeId: 'test.throw', + }); + + await createConnector({ + name: 'unused connector', + space: space.id, + connectorTypeId: 'test.excluded', + }); + await createRule({ + space: space.id, + ruleOverwrites: { + rule_type_id: 'test.noop', + schedule: { interval: '1s' }, + throttle: null, + notify_when: 'onActiveAlert', + params: {}, + actions: [ + { + id: noopConnectorId, + group: 'default', + params: {}, + }, + ], + }, + }); + await createRule({ + space: space.id, + ruleOverwrites: { + rule_type_id: 'test.noop', + schedule: { interval: '1s' }, + throttle: null, + params: {}, + notify_when: 'onActiveAlert', + actions: [ + { + id: failingConnectorId, + group: 'default', + params: {}, + }, + ], + }, + }); + + alwaysFiringRuleId[space.id] = await createRule({ + space: space.id, + ruleOverwrites: { + rule_type_id: 'test.cumulative-firing', + schedule: { interval: '3s' }, + throttle: null, + notify_when: 'onActiveAlert', + params: {}, + actions: [ + { + id: noopConnectorId, + group: 'default', + params: {}, + }, + { + id: failingConnectorId, + group: 'default', + params: {}, + }, + { + id: 'my-slack1', + group: 'other', + params: {}, + }, + ], + }, + }); + } + } + + it('should retrieve telemetry data in the expected format', async () => { + await setup(); + + // let it run for a bit + await retry.try(async () => { + return await getEventLog({ + getService, + spaceId: Spaces[0].id, + type: 'alert', + id: alwaysFiringRuleId[Spaces[0].id], + provider: 'alerting', + actions: new Map([['execute', { gte: 5 }]]), + }); + }); + + // request telemetry task to run + await supertest + .post('/api/alerting_actions_telemetry/run_now') + .set('kbn-xsrf', 'xxx') + .send({ taskId: 'Actions-actions_telemetry' }) + .expect(200); + + // get telemetry task doc + const telemetryTask = await es.get({ + id: `task:Actions-actions_telemetry`, + index: '.kibana_task_manager', + }); + const taskState = telemetryTask?._source?.task?.state; + expect(taskState).not.to.be(undefined); + const telemetry = JSON.parse(taskState!); + + // total number of connectors + expect(telemetry.count_total).to.equal(17); + + // total number of active connectors (used by a rule) + expect(telemetry.count_active_total).to.equal(7); + + // total number of connectors broken down by connector type + expect(telemetry.count_by_type['test.throw']).to.equal(3); + expect(telemetry.count_by_type['test.excluded']).to.equal(3); + expect(telemetry.count_by_type['test.noop']).to.equal(3); + expect(telemetry.count_by_type.__slack).to.equal(1); + expect(telemetry.count_by_type['system-abc-action-type']).to.equal(1); + expect(telemetry.count_by_type.__index).to.equal(1); + expect(telemetry.count_by_type['test.index-record']).to.equal(1); + expect(telemetry.count_by_type.__webhook).to.equal(4); + + // total number of active connectors broken down by connector type + expect(telemetry.count_active_by_type['test.throw']).to.equal(3); + expect(telemetry.count_active_by_type['test.noop']).to.equal(3); + expect(telemetry.count_active_by_type.__slack).to.equal(1); + + // total number of rules using the alert history connector + expect(telemetry.count_active_alert_history_connectors).to.equal(0); + + // total number of email connectors used by rules broken down by service type + // testing for existence of this field but we don't have any rules using email + // connectors in this test + expect(telemetry.count_active_email_connectors_by_service_type).to.be.empty(); + + // number of spaces with connectors + expect(telemetry.count_actions_namespaces).to.equal(3); + + // number of action executions - just checking for non-zero as we can't set an exact number + expect(telemetry.count_actions_executions_per_day > 0).to.be(true); + + // number of action executions broken down by connector type + expect(telemetry.count_actions_executions_by_type_per_day['test.noop'] > 0).to.be(true); + + // average execution time - just checking for non-zero as we can't set an exact number + expect(telemetry.avg_execution_time_per_day > 0).to.be(true); + + // average execution time broken down by rule type + expect(telemetry.avg_execution_time_by_type_per_day['test.noop'] > 0).to.be(true); + + // number of failed executions + expect(telemetry.count_actions_executions_failed_per_day > 0).to.be(true); + expect(telemetry.count_actions_executions_failed_by_type_per_day['test.throw'] > 0).to.be( + true + ); + }); + }); +} diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/telemetry/alerting_telemetry.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/telemetry/alerting_telemetry.ts new file mode 100644 index 0000000000000..9b8a96bc056ce --- /dev/null +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/telemetry/alerting_telemetry.ts @@ -0,0 +1,304 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import expect from '@kbn/expect'; +import { Spaces, Superuser } from '../../scenarios'; +import { + getUrlPrefix, + getEventLog, + getTestRuleData, + ObjectRemover, + TaskManagerDoc, +} from '../../../common/lib'; +import { FtrProviderContext } from '../../../common/ftr_provider_context'; + +// eslint-disable-next-line import/no-default-export +export default function createAlertingTelemetryTests({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const es = getService('es'); + const retry = getService('retry'); + const supertestWithoutAuth = getService('supertestWithoutAuth'); + + describe('alerting telemetry', () => { + const alwaysFiringRuleId: { [key: string]: string } = {}; + const objectRemover = new ObjectRemover(supertest); + + before(async () => { + // reset the state in the telemetry task + await es.update({ + id: `task:Alerting-alerting_telemetry`, + index: '.kibana_task_manager', + body: { + doc: { + task: { + state: '{}', + }, + }, + }, + }); + }); + after(() => objectRemover.removeAll()); + + async function createConnector(opts: { name: string; space: string; connectorTypeId: string }) { + const { name, space, connectorTypeId } = opts; + const { body: createdConnector } = await supertestWithoutAuth + .post(`${getUrlPrefix(space)}/api/actions/connector`) + .set('kbn-xsrf', 'foo') + .auth(Superuser.username, Superuser.password) + .send({ + name, + connector_type_id: connectorTypeId, + config: {}, + secrets: {}, + }) + .expect(200); + objectRemover.add(space, createdConnector.id, 'action', 'actions'); + return createdConnector.id; + } + + async function createRule(opts: { space: string; ruleOverwrites: any }) { + const { ruleOverwrites, space } = opts; + const ruleResponse = await supertestWithoutAuth + .post(`${getUrlPrefix(space)}/api/alerting/rule`) + .set('kbn-xsrf', 'foo') + .auth(Superuser.username, Superuser.password) + .send(getTestRuleData(ruleOverwrites)); + expect(ruleResponse.status).to.eql(200); + objectRemover.add(space, ruleResponse.body.id, 'rule', 'alerting'); + return ruleResponse.body.id; + } + + async function setup() { + // Create rules and connectors in multiple spaces + for (const space of Spaces) { + const noopConnectorId = await createConnector({ + name: 'noop connector', + space: space.id, + connectorTypeId: 'test.noop', + }); + await createConnector({ + name: 'connector that errors', + space: space.id, + connectorTypeId: 'test.throw', + }); + await createRule({ + space: space.id, + ruleOverwrites: { + rule_type_id: 'test.noop', + schedule: { interval: '30s' }, + throttle: '1s', + params: {}, + actions: [ + { + id: noopConnectorId, + group: 'default', + params: {}, + }, + ], + }, + }); + await createRule({ + space: space.id, + ruleOverwrites: { + rule_type_id: 'test.onlyContextVariables', + schedule: { interval: '10s' }, + throttle: '10m', + params: {}, + actions: [ + { + id: noopConnectorId, + group: 'default', + params: {}, + }, + ], + }, + }); + await createRule({ + space: space.id, + ruleOverwrites: { + rule_type_id: 'test.throw', + schedule: { interval: '1m' }, + throttle: '30s', + params: {}, + actions: [ + { + id: noopConnectorId, + group: 'default', + params: {}, + }, + ], + }, + }); + + alwaysFiringRuleId[space.id] = await createRule({ + space: space.id, + ruleOverwrites: { + rule_type_id: 'example.always-firing', + schedule: { interval: '3s' }, + throttle: null, + params: {}, + actions: [ + { + id: noopConnectorId, + group: 'small', + params: {}, + }, + { + id: noopConnectorId, + group: 'medium', + params: {}, + }, + { + id: noopConnectorId, + group: 'large', + params: {}, + }, + ], + }, + }); + + await createRule({ + space: space.id, + ruleOverwrites: { + rule_type_id: 'test.noop', + schedule: { interval: '5m' }, + throttle: null, + enabled: false, + params: {}, + actions: [ + { + id: noopConnectorId, + group: 'default', + params: {}, + }, + ], + }, + }); + } + } + + it('should retrieve telemetry data in the expected format', async () => { + await setup(); + + // let it run for a bit + await retry.try(async () => { + return await getEventLog({ + getService, + spaceId: Spaces[0].id, + type: 'alert', + id: alwaysFiringRuleId[Spaces[0].id], + provider: 'alerting', + actions: new Map([['execute', { gte: 5 }]]), + }); + }); + + // request telemetry task to run + await supertest + .post('/api/alerting_actions_telemetry/run_now') + .set('kbn-xsrf', 'xxx') + .send({ taskId: 'Alerting-alerting_telemetry' }) + .expect(200); + + // get telemetry task doc + const telemetryTask = await es.get({ + id: `task:Alerting-alerting_telemetry`, + index: '.kibana_task_manager', + }); + const taskState = telemetryTask?._source?.task?.state; + expect(taskState).not.to.be(undefined); + const telemetry = JSON.parse(taskState!); + + // total number of rules + expect(telemetry.count_total).to.equal(15); + + // total number of enabled rules + expect(telemetry.count_active_total).to.equal(12); + + // total number of disabled rules + expect(telemetry.count_disabled_total).to.equal(3); + + // total number of rules broken down by rule type + expect(telemetry.count_by_type.test__onlyContextVariables).to.equal(3); + expect(telemetry.count_by_type['example__always-firing']).to.equal(3); + expect(telemetry.count_by_type.test__throw).to.equal(3); + expect(telemetry.count_by_type.test__noop).to.equal(6); + + // total number of enabled rules broken down by rule type + expect(telemetry.count_active_by_type.test__onlyContextVariables).to.equal(3); + expect(telemetry.count_active_by_type['example__always-firing']).to.equal(3); + expect(telemetry.count_active_by_type.test__throw).to.equal(3); + expect(telemetry.count_active_by_type.test__noop).to.equal(3); + + // throttle time stats + expect(telemetry.throttle_time.min).to.equal('0s'); + expect(telemetry.throttle_time.avg).to.equal('157.75s'); + expect(telemetry.throttle_time.max).to.equal('600s'); + expect(telemetry.throttle_time_number_s.min).to.equal(0); + expect(telemetry.throttle_time_number_s.avg).to.equal(157.75); + expect(telemetry.throttle_time_number_s.max).to.equal(600); + + // schedule interval stats + expect(telemetry.schedule_time.min).to.equal('3s'); + expect(telemetry.schedule_time.avg).to.equal('80.6s'); + expect(telemetry.schedule_time.max).to.equal('300s'); + expect(telemetry.schedule_time_number_s.min).to.equal(3); + expect(telemetry.schedule_time_number_s.avg).to.equal(80.6); + expect(telemetry.schedule_time_number_s.max).to.equal(300); + + // attached connectors stats + expect(telemetry.connectors_per_alert.min).to.equal(1); + expect(telemetry.connectors_per_alert.avg).to.equal(1.4); + expect(telemetry.connectors_per_alert.max).to.equal(3); + + // number of spaces with rules + expect(telemetry.count_rules_namespaces).to.equal(3); + + // number of rule executions - just checking for non-zero as we can't set an exact number + // each rule should have had a chance to execute once + expect(telemetry.count_rules_executions_per_day >= 15).to.be(true); + + // number of rule executions broken down by rule type + expect(telemetry.count_by_type.test__onlyContextVariables >= 3).to.be(true); + expect(telemetry.count_by_type['example__always-firing'] >= 3).to.be(true); + expect(telemetry.count_by_type.test__throw >= 3).to.be(true); + expect(telemetry.count_by_type.test__noop >= 3).to.be(true); + + // average execution time - just checking for non-zero as we can't set an exact number + expect(telemetry.avg_execution_time_per_day > 0).to.be(true); + + // average execution time broken down by rule type + expect(telemetry.avg_execution_time_by_type_per_day.test__onlyContextVariables > 0).to.be( + true + ); + expect(telemetry.avg_execution_time_by_type_per_day['example__always-firing'] > 0).to.be( + true + ); + expect(telemetry.avg_execution_time_by_type_per_day.test__throw > 0).to.be(true); + expect(telemetry.avg_execution_time_by_type_per_day.test__noop > 0).to.be(true); + + // number of failed executions - we have one rule that always fails + expect(telemetry.count_rules_executions_failured_per_day >= 1).to.be(true); + expect(telemetry.count_rules_executions_failured_by_reason_per_day.execute >= 1).to.be(true); + expect( + telemetry.count_rules_executions_failured_by_reason_by_type_per_day.execute.test__throw >= 1 + ).to.be(true); + + // number of execution timeouts - testing for existence of this field but + // this test doesn't have any rules that timeout + expect(telemetry.count_rules_executions_timeouts_per_day).to.equal(0); + expect(telemetry.count_rules_executions_timeouts_by_type_per_day).to.be.empty(); + + // number of failed/unrecognized tasks - testing for existence of this field but + // this test doesn't have any unrecognized rule types + expect(telemetry.count_failed_and_unrecognized_rule_tasks_per_day).to.equal(0); + expect(telemetry.count_failed_and_unrecognized_rule_tasks_by_status_per_day).to.be.empty(); + expect( + telemetry.count_failed_and_unrecognized_rule_tasks_by_status_by_type_per_day + ).to.be.empty(); + }); + }); +} diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/telemetry/index.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/telemetry/index.ts new file mode 100644 index 0000000000000..9e73fafc9f7bd --- /dev/null +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/telemetry/index.ts @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { FtrProviderContext } from '../../../common/ftr_provider_context'; +import { setupSpacesAndUsers, tearDown } from '..'; + +// eslint-disable-next-line import/no-default-export +export default function actionsTests({ loadTestFile, getService }: FtrProviderContext) { + describe('Alerting and Actions Telemetry', () => { + before(async () => { + await setupSpacesAndUsers(getService); + }); + + after(async () => { + await tearDown(getService); + }); + + // run telemetry tests before anything else + loadTestFile(require.resolve('./actions_telemetry')); + loadTestFile(require.resolve('./alerting_telemetry')); + }); +} diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts index dea873073f61f..274e147898d9b 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/actions/builtin_action_types/preconfigured_alert_history_connector.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../../common/ftr_provider_context'; -import { getTestAlertData, ObjectRemover } from '../../../../common/lib'; +import { getTestRuleData, ObjectRemover } from '../../../../common/lib'; import { AlertHistoryDefaultIndexName } from '../../../../../../plugins/actions/common'; const ALERT_HISTORY_OVERRIDE_INDEX = 'kibana-alert-history-not-the-default'; @@ -27,7 +27,7 @@ export default function preconfiguredAlertHistoryConnectorTests({ const alertId = 'instance'; function getTestData(params = {}) { - return getTestAlertData({ + return getTestRuleData({ rule_type_id: ruleTypeId, schedule: { interval: '1s' }, params: { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/aggregate.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/aggregate.ts index cf7ebffef85a2..961a15dd5223d 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/aggregate.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/aggregate.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export @@ -239,7 +239,7 @@ export default function createAggregateTests({ getService }: FtrProviderContext) const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData(testAlertOverrides)) + .send(getTestRuleData(testAlertOverrides)) .expect(200); await waitForStatus(createdAlert.id, new Set([status])); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts index ea818a6e64b0d..58ddd5516d8a5 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts_base.ts @@ -16,7 +16,7 @@ import { ESTestIndexTool, ES_TEST_INDEX_NAME, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, AlertUtils, ensureDatetimeIsWithinRange, @@ -198,7 +198,7 @@ instanceStateValue: true .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', schedule: { interval: '1s' }, throttle: null, @@ -259,7 +259,7 @@ instanceStateValue: true .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', schedule: { interval: '1s' }, enabled: false, @@ -354,7 +354,7 @@ instanceStateValue: true .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ schedule: { interval: '1m' }, rule_type_id: 'test.always-firing', params: { @@ -427,7 +427,7 @@ instanceStateValue: true .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.authorization', params: { callClusterAuthorizationIndex: authorizationIndex, @@ -473,7 +473,7 @@ instanceStateValue: true .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.always-firing', params: { index: ES_TEST_INDEX_NAME, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts index b002e0668dc52..1d5eb16ff3f89 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts @@ -11,7 +11,7 @@ import { Spaces } from '../../scenarios'; import { checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, getConsumerUnauthorizedErrorMessage, TaskManagerDoc, @@ -53,7 +53,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ actions: [ { id: createdAction.id, @@ -132,7 +132,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ actions: [ { id: createdAction.id, @@ -244,7 +244,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ params: { ignoredButPersisted: lotsOfSpaces, }, @@ -288,7 +288,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ params: { risk_score: 40, severity: 'medium', @@ -325,7 +325,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { const response = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule/${customId}`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()); + .send(getTestRuleData()); expect(response.status).to.eql(200); objectRemover.add(Spaces.space1.id, response.body.id, 'rule', 'alerting'); @@ -344,7 +344,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { const response = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule/${customId}`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()); + .send(getTestRuleData()); expect(response.status).to.eql(200); objectRemover.add(Spaces.space1.id, response.body.id, 'rule', 'alerting'); @@ -363,7 +363,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { const response = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule/${customId}`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()); + .send(getTestRuleData()); expect(response.status).to.eql(400); expect(response.body).to.eql({ @@ -379,13 +379,13 @@ export default function createAlertTests({ getService }: FtrProviderContext) { const createdAlertResponse = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule/${customId}`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlertResponse.body.id, 'rule', 'alerting'); await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule/${customId}`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(409); }); @@ -393,7 +393,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { const response = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ consumer: 'some consumer patrick invented' })); + .send(getTestRuleData({ consumer: 'some consumer patrick invented' })); expect(response.status).to.eql(403); expect(response.body).to.eql({ @@ -411,7 +411,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { const response = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })); + .send(getTestRuleData({ enabled: false })); expect(response.status).to.eql(200); objectRemover.add(Spaces.space1.id, response.body.id, 'rule', 'alerting'); @@ -435,7 +435,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { rule_type_id: alertTypeId, notify_when: notifyWhen, ...testAlert - } = getTestAlertData({ + } = getTestRuleData({ actions: [ { id: createdAction.id, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/delete.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/delete.ts index 0a2df70b6316a..073d76dc859a5 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/delete.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/delete.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export @@ -31,7 +31,7 @@ export default function createDeleteTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); await supertest @@ -51,7 +51,7 @@ export default function createDeleteTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); await supertest @@ -69,7 +69,7 @@ export default function createDeleteTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); await supertest diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts index 51cb54aa5f9e5..2a1d27a4d3b39 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/disable.ts @@ -12,7 +12,7 @@ import { AlertUtils as RuleUtils, checkAAD, getUrlPrefix, - getTestAlertData as getTestRuleData, + getTestRuleData, ObjectRemover, getEventLog, } from '../../../common/lib'; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts index 611c2498dd9d3..c0c56ed354a84 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/enable.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, TaskManagerDoc, } from '../../../common/lib'; @@ -40,7 +40,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -72,7 +72,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.other.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.other.id, createdAlert.id, 'rule', 'alerting'); @@ -88,7 +88,7 @@ export default function createEnableAlertTests({ getService }: FtrProviderContex const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ephemeral.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ephemeral.ts index a3b8c75f79e62..ac095fd4c4419 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ephemeral.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/ephemeral.ts @@ -11,7 +11,7 @@ import { Spaces } from '../../scenarios'; import { getUrlPrefix, ObjectRemover, - getTestAlertData, + getTestRuleData, getEventLog, ESTestIndexTool, ES_TEST_INDEX_NAME, @@ -69,7 +69,7 @@ export default function createNotifyWhenTests({ getService }: FtrProviderContext const pattern = { instance: [true, true, true, false, true, true], }; - const alertData = getTestAlertData({ + const alertData = getTestRuleData({ rule_type_id: 'test.patternFiring', params: { pattern }, schedule: { interval: '1m' }, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts index c36f9a0da75bc..2cc2044653fd9 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts @@ -10,7 +10,7 @@ import uuid from 'uuid'; import { Spaces } from '../../scenarios'; import { getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, getEventLog, ESTestIndexTool, @@ -62,7 +62,7 @@ export default function eventLogTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', schedule: { interval: '1s' }, throttle: null, @@ -300,7 +300,7 @@ export default function eventLogTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.multipleSearches', schedule: { interval: '1s' }, throttle: null, @@ -405,7 +405,7 @@ export default function eventLogTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', schedule: { interval: '1s' }, throttle: null, @@ -599,7 +599,7 @@ export default function eventLogTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(space.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.throw', schedule: { interval: '1s' }, throttle: null, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log_alerts.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log_alerts.ts index 6fa3eb1a43b62..6d7f95df10d9b 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log_alerts.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log_alerts.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover, getEventLog } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover, getEventLog } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { IValidatedEvent } from '../../../../../plugins/event_log/server'; @@ -31,7 +31,7 @@ export default function eventLogAlertTests({ getService }: FtrProviderContext) { .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', schedule: { interval: '1s' }, throttle: null, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/execution_status.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/execution_status.ts index 0f7ed80cfd38d..d5bcd0c7a9ae2 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/execution_status.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/execution_status.ts @@ -10,7 +10,7 @@ import { Spaces } from '../../scenarios'; import { checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, ensureDatetimesAreOrdered, } from '../../../common/lib'; @@ -30,7 +30,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon const response = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()); + .send(getTestRuleData()); const dateEnd = Date.now(); expect(response.status).to.eql(200); objectRemover.add(Spaces.space1.id, response.body.id, 'rule', 'alerting'); @@ -61,7 +61,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.noop', schedule: { interval: '1s' }, }) @@ -94,7 +94,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', schedule: { interval: '1s' }, params: { @@ -130,7 +130,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.throw', schedule: { interval: '1s' }, }) @@ -166,7 +166,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.throw', schedule: { interval: '1s' }, }) @@ -188,7 +188,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.validation', schedule: { interval: '1s' }, params: { param1: 'valid now, but will change to a number soon!' }, @@ -227,7 +227,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.throw', schedule: { interval: '1s' }, }) diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/find.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/find.ts index 7a4a91bd575bb..5ab632c6a66b8 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/find.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/find.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import { SuperTest, Test } from 'supertest'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; async function createAlert( @@ -19,7 +19,7 @@ async function createAlert( const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData(overwrites)) + .send(getTestRuleData(overwrites)) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); return createdAlert; @@ -36,7 +36,7 @@ const findTestUtils = ( const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -82,7 +82,7 @@ const findTestUtils = ( const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -266,7 +266,7 @@ export default function createFindTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get.ts index 9a4be8951f8f0..81f67c8d49e33 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import { SuperTest, Test } from 'supertest'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; const getTestUtils = ( @@ -22,7 +22,7 @@ const getTestUtils = ( const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -64,7 +64,7 @@ const getTestUtils = ( const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -113,7 +113,7 @@ export default function createGetTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_state.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_state.ts index 318dfdfe065df..61d38b522bb59 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_state.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_state.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, ObjectRemover, getTestAlertData } from '../../../common/lib'; +import { getUrlPrefix, ObjectRemover, getTestRuleData } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export @@ -24,7 +24,7 @@ export default function createGetAlertStateTests({ getService }: FtrProviderCont const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_summary.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_summary.ts index 8cd9a0bbb1290..d13da4694bbe2 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_summary.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_summary.ts @@ -12,7 +12,7 @@ import { Spaces } from '../../scenarios'; import { getUrlPrefix, ObjectRemover, - getTestAlertData, + getTestRuleData, AlertUtils, getEventLog, } from '../../../common/lib'; @@ -44,7 +44,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo const { body: createdRule } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdRule.id, 'rule', 'alerting'); @@ -83,7 +83,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo const { body: createdRule } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdRule.id, 'rule', 'alerting'); @@ -122,7 +122,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo const { body: createdRule } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdRule.id, 'rule', 'alerting'); @@ -142,7 +142,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo const { body: createdRule } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdRule.id, 'rule', 'alerting'); @@ -165,7 +165,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo const { body: createdRule } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdRule.id, 'rule', 'alerting'); @@ -189,7 +189,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo const { body: createdRule } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ rule_type_id: 'test.throw' })) + .send(getTestRuleData({ rule_type_id: 'test.throw' })) .expect(200); objectRemover.add(Spaces.space1.id, createdRule.id, 'rule', 'alerting'); @@ -216,7 +216,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', params: { pattern }, schedule: { interval: '1s' }, @@ -271,7 +271,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', params: { pattern }, schedule: { interval: '1s' }, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/monitoring.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/monitoring.ts index 9b91d395d16c6..c08a28b3c3ca3 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/monitoring.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/monitoring.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export @@ -23,7 +23,7 @@ export default function monitoringAlertTests({ getService }: FtrProviderContext) const createResponse = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ schedule: { interval: '3s' } })); + .send(getTestRuleData({ schedule: { interval: '3s' } })); expect(createResponse.status).to.eql(200); objectRemover.add(Spaces.space1.id, createResponse.body.id, 'rule', 'alerting'); @@ -44,7 +44,7 @@ export default function monitoringAlertTests({ getService }: FtrProviderContext) const createResponse = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ schedule: { interval: '3s' } })); + .send(getTestRuleData({ schedule: { interval: '3s' } })); expect(createResponse.status).to.eql(200); objectRemover.add(Spaces.space1.id, createResponse.body.id, 'rule', 'alerting'); @@ -69,7 +69,7 @@ export default function monitoringAlertTests({ getService }: FtrProviderContext) .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternSuccessOrFailure', schedule: { interval: '3s' }, params: { @@ -102,7 +102,7 @@ export default function monitoringAlertTests({ getService }: FtrProviderContext) .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ schedule: { interval: '3s' }, }) ); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mustache_templates.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mustache_templates.ts index 8d300733bafc3..ff596db062b75 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mustache_templates.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mustache_templates.ts @@ -19,7 +19,7 @@ import axios from 'axios'; import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { getWebhookServer, @@ -88,7 +88,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ name: 'testing variable escapes for webhook', rule_type_id: 'test.patternFiring', params: { @@ -139,7 +139,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ name: 'testing variable escapes for slack', rule_type_id: 'test.patternFiring', params: { @@ -189,7 +189,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ name: 'testing context variable expansion', rule_type_id: 'test.patternFiring', params: { @@ -239,7 +239,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ name: 'testing context variable kibanaBaseUrl', rule_type_id: 'test.patternFiring', params: { @@ -290,7 +290,7 @@ export default function executionStatusAlertTests({ getService }: FtrProviderCon .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ name: 'testing variable escapes for webhook', rule_type_id: 'test.patternFiring', params: { diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mute_all.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mute_all.ts index c21a13edbf2cb..27475049ac9a6 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mute_all.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mute_all.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, } from '../../../common/lib'; @@ -30,7 +30,7 @@ export default function createMuteTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -56,7 +56,7 @@ export default function createMuteTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mute_instance.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mute_instance.ts index afe29280748a5..d32b74fd39447 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mute_instance.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/mute_instance.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, } from '../../../common/lib'; @@ -30,7 +30,7 @@ export default function createMuteInstanceTests({ getService }: FtrProviderConte const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -56,7 +56,7 @@ export default function createMuteInstanceTests({ getService }: FtrProviderConte const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/notify_when.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/notify_when.ts index 7f1b82614a100..5049f7c863a06 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/notify_when.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/notify_when.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; -import { getUrlPrefix, ObjectRemover, getTestAlertData, getEventLog } from '../../../common/lib'; +import { getUrlPrefix, ObjectRemover, getTestRuleData, getEventLog } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { IValidatedEvent } from '../../../../../plugins/event_log/server'; @@ -55,7 +55,7 @@ export default function createNotifyWhenTests({ getService }: FtrProviderContext .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', params: { pattern }, schedule: { interval: '1s' }, @@ -131,7 +131,7 @@ export default function createNotifyWhenTests({ getService }: FtrProviderContext .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', params: { pattern }, schedule: { interval: '1s' }, @@ -222,7 +222,7 @@ export default function createNotifyWhenTests({ getService }: FtrProviderContext .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') .send( - getTestAlertData({ + getTestRuleData({ rule_type_id: 'test.patternFiring', params: { pattern }, schedule: { interval: '1s' }, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/scheduled_task_id.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/scheduled_task_id.ts index 9f087b7392132..a83cd4241d144 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/scheduled_task_id.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/scheduled_task_id.ts @@ -6,7 +6,7 @@ */ import expect from '@kbn/expect'; -import { getUrlPrefix, TaskManagerDoc, ObjectRemover, getTestAlertData } from '../../../common/lib'; +import { getUrlPrefix, TaskManagerDoc, ObjectRemover, getTestRuleData } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; const MIGRATED_RULE_ID = '74f3e6d7-b7bb-477d-ac28-92ee22728e6e'; @@ -47,7 +47,7 @@ export default function createScheduledTaskIdTests({ getService }: FtrProviderCo await supertest .post(`${getUrlPrefix(``)}/api/alerting/rule/${MIGRATED_TASK_ID}`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(409); }); @@ -94,7 +94,7 @@ export default function createScheduledTaskIdTests({ getService }: FtrProviderCo const response = await supertestWithoutAuth .post(`${getUrlPrefix(``)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()); + .send(getTestRuleData()); expect(response.status).to.eql(200); objectRemover.add('default', response.body.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/unmute_all.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/unmute_all.ts index 2fffa9189e0ad..47f61250157a3 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/unmute_all.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/unmute_all.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, } from '../../../common/lib'; @@ -30,7 +30,7 @@ export default function createUnmuteTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -57,7 +57,7 @@ export default function createUnmuteTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/unmute_instance.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/unmute_instance.ts index e0c42136628d3..086f40d9febae 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/unmute_instance.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/unmute_instance.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, } from '../../../common/lib'; @@ -30,7 +30,7 @@ export default function createUnmuteInstanceTests({ getService }: FtrProviderCon const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -57,7 +57,7 @@ export default function createUnmuteInstanceTests({ getService }: FtrProviderCon const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData({ enabled: false })) + .send(getTestRuleData({ enabled: false })) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update.ts index d97ca18c52d4a..c5a9c93d45e81 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { Spaces } from '../../scenarios'; -import { checkAAD, getUrlPrefix, getTestAlertData, ObjectRemover } from '../../../common/lib'; +import { checkAAD, getUrlPrefix, getTestRuleData, ObjectRemover } from '../../../common/lib'; import { FtrProviderContext } from '../../../common/ftr_provider_context'; // eslint-disable-next-line import/no-default-export @@ -23,7 +23,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -94,7 +94,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -124,7 +124,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { const { body: createdAlert } = await supertest .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update_api_key.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update_api_key.ts index 78ceadec44a9a..9fe5c7e112c79 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update_api_key.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update_api_key.ts @@ -12,7 +12,7 @@ import { AlertUtils, checkAAD, getUrlPrefix, - getTestAlertData, + getTestRuleData, ObjectRemover, } from '../../../common/lib'; @@ -34,7 +34,7 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting'); @@ -59,7 +59,7 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.other.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.other.id, createdAlert.id, 'rule', 'alerting'); @@ -75,7 +75,7 @@ export default function createUpdateApiKeyTests({ getService }: FtrProviderConte const { body: createdAlert } = await supertestWithoutAuth .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerting/rule`) .set('kbn-xsrf', 'foo') - .send(getTestAlertData()) + .send(getTestRuleData()) .expect(200); objectRemover.add(Spaces.space1.id, createdAlert.id, 'rule', 'alerting');