diff --git a/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.ts b/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.ts index f968e90f70b2d..9ef19e58bada7 100644 --- a/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.ts +++ b/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.ts @@ -54,6 +54,7 @@ export const getLicenseExpiration = ( }), }, ], + defaultActionGroupId: 'default', async executor({ services, params, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts index 79337aa91b1fe..42b6efc5de14f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts @@ -41,6 +41,7 @@ export const signalRulesAlertType = ({ }), }, ], + defaultActionGroupId: 'default', validate: { params: schema.object({ description: schema.string(), diff --git a/x-pack/plugins/alerting/common/index.ts b/x-pack/plugins/alerting/common/index.ts index 03b3487f10f1d..8c6969cded85a 100644 --- a/x-pack/plugins/alerting/common/index.ts +++ b/x-pack/plugins/alerting/common/index.ts @@ -7,3 +7,8 @@ export * from './alert'; export * from './alert_instance'; export * from './alert_task_instance'; + +export interface ActionGroup { + id: string; + name: string; +} diff --git a/x-pack/plugins/alerting/server/alert_type_registry.test.ts b/x-pack/plugins/alerting/server/alert_type_registry.test.ts index 1a820d55af8a4..f4749772c7004 100644 --- a/x-pack/plugins/alerting/server/alert_type_registry.test.ts +++ b/x-pack/plugins/alerting/server/alert_type_registry.test.ts @@ -27,7 +27,13 @@ describe('has()', () => { registry.register({ id: 'foo', name: 'Foo', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', executor: jest.fn(), }); expect(registry.has('foo')).toEqual(true); @@ -39,7 +45,13 @@ describe('register()', () => { const alertType = { id: 'test', name: 'Test', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', executor: jest.fn(), }; // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -64,14 +76,26 @@ describe('register()', () => { registry.register({ id: 'test', name: 'Test', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', executor: jest.fn(), }); expect(() => registry.register({ id: 'test', name: 'Test', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', executor: jest.fn(), }) ).toThrowErrorMatchingInlineSnapshot(`"Alert type \\"test\\" is already registered."`); @@ -84,13 +108,25 @@ describe('get()', () => { registry.register({ id: 'test', name: 'Test', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', executor: jest.fn(), }); const alertType = registry.get('test'); expect(alertType).toMatchInlineSnapshot(` Object { - "actionGroups": Array [], + "actionGroups": Array [ + Object { + "id": "default", + "name": "Default", + }, + ], + "defaultActionGroupId": "default", "executor": [MockFunction], "id": "test", "name": "Test", @@ -124,6 +160,7 @@ describe('list()', () => { name: 'Test Action Group', }, ], + defaultActionGroupId: 'testActionGroup', executor: jest.fn(), }); const result = registry.list(); @@ -136,6 +173,7 @@ describe('list()', () => { "name": "Test Action Group", }, ], + "defaultActionGroupId": "testActionGroup", "id": "test", "name": "Test", }, diff --git a/x-pack/plugins/alerting/server/alert_type_registry.ts b/x-pack/plugins/alerting/server/alert_type_registry.ts index b0976d67c70a0..d9045fb986745 100644 --- a/x-pack/plugins/alerting/server/alert_type_registry.ts +++ b/x-pack/plugins/alerting/server/alert_type_registry.ts @@ -70,6 +70,7 @@ export class AlertTypeRegistry { id: alertTypeId, name: alertType.name, actionGroups: alertType.actionGroups, + defaultActionGroupId: alertType.defaultActionGroupId, })); } } diff --git a/x-pack/plugins/alerting/server/alerts_client.test.ts b/x-pack/plugins/alerting/server/alerts_client.test.ts index 629bd05a8c76a..ed6e7562e3acd 100644 --- a/x-pack/plugins/alerting/server/alerts_client.test.ts +++ b/x-pack/plugins/alerting/server/alerts_client.test.ts @@ -87,6 +87,7 @@ describe('create()', () => { id: '123', name: 'Test', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', async executor() {}, }); }); @@ -522,7 +523,13 @@ describe('create()', () => { alertTypeRegistry.get.mockReturnValue({ id: '123', name: 'Test', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', validate: { params: schema.object({ param1: schema.string(), @@ -1885,6 +1892,7 @@ describe('update()', () => { id: '123', name: 'Test', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', async executor() {}, }); }); @@ -2415,6 +2423,7 @@ describe('update()', () => { id: '123', name: 'Test', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', validate: { params: schema.object({ param1: schema.string(), @@ -2647,6 +2656,7 @@ describe('update()', () => { id: '123', name: 'Test', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', async executor() {}, }); savedObjectsClient.bulkGet.mockResolvedValueOnce({ diff --git a/x-pack/plugins/alerting/server/index.ts b/x-pack/plugins/alerting/server/index.ts index 58b77f0f510f7..727e38d9ba56b 100644 --- a/x-pack/plugins/alerting/server/index.ts +++ b/x-pack/plugins/alerting/server/index.ts @@ -12,6 +12,7 @@ export type AlertsClient = PublicMethodsOf; export { AlertType, + ActionGroup, AlertingPlugin, AlertExecutorOptions, AlertActionParams, diff --git a/x-pack/plugins/alerting/server/lib/validate_alert_type_params.test.ts b/x-pack/plugins/alerting/server/lib/validate_alert_type_params.test.ts index e9a61354001f1..67820e44f567e 100644 --- a/x-pack/plugins/alerting/server/lib/validate_alert_type_params.test.ts +++ b/x-pack/plugins/alerting/server/lib/validate_alert_type_params.test.ts @@ -12,7 +12,13 @@ test('should return passed in params when validation not defined', () => { { id: 'my-alert-type', name: 'My description', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', async executor() {}, }, { @@ -27,7 +33,13 @@ test('should validate and apply defaults when params is valid', () => { { id: 'my-alert-type', name: 'My description', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', validate: { params: schema.object({ param1: schema.string(), @@ -50,7 +62,13 @@ test('should validate and throw error when params is invalid', () => { { id: 'my-alert-type', name: 'My description', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', validate: { params: schema.object({ param1: schema.string(), diff --git a/x-pack/plugins/alerting/server/routes/list_alert_types.test.ts b/x-pack/plugins/alerting/server/routes/list_alert_types.test.ts index 3e9f57d55122d..96ee8c5717453 100644 --- a/x-pack/plugins/alerting/server/routes/list_alert_types.test.ts +++ b/x-pack/plugins/alerting/server/routes/list_alert_types.test.ts @@ -40,7 +40,13 @@ describe('listAlertTypesRoute', () => { { id: '1', name: 'name', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', }, ]; @@ -50,7 +56,13 @@ describe('listAlertTypesRoute', () => { Object { "body": Array [ Object { - "actionGroups": Array [], + "actionGroups": Array [ + Object { + "id": "default", + "name": "Default", + }, + ], + "defaultActionGroupId": "default", "id": "1", "name": "name", }, @@ -128,7 +140,13 @@ describe('listAlertTypesRoute', () => { { id: '1', name: 'name', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', }, ]; diff --git a/x-pack/plugins/alerting/server/task_runner/create_execution_handler.test.ts b/x-pack/plugins/alerting/server/task_runner/create_execution_handler.test.ts index 1b3a9ed8d7b06..32299680a1f8c 100644 --- a/x-pack/plugins/alerting/server/task_runner/create_execution_handler.test.ts +++ b/x-pack/plugins/alerting/server/task_runner/create_execution_handler.test.ts @@ -15,6 +15,7 @@ const alertType: AlertType = { { id: 'default', name: 'Default' }, { id: 'other-group', name: 'Other Group' }, ], + defaultActionGroupId: 'default', executor: jest.fn(), }; diff --git a/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts b/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts index af0e7b658240a..d1bc0de3ae0e2 100644 --- a/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts +++ b/x-pack/plugins/alerting/server/task_runner/task_runner.test.ts @@ -17,6 +17,7 @@ const alertType = { id: 'test', name: 'My test alert', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', executor: jest.fn(), }; let fakeTimer: sinon.SinonFakeTimers; diff --git a/x-pack/plugins/alerting/server/task_runner/task_runner_factory.test.ts b/x-pack/plugins/alerting/server/task_runner/task_runner_factory.test.ts index 4dad46ef32f21..f885b0bdbd046 100644 --- a/x-pack/plugins/alerting/server/task_runner/task_runner_factory.test.ts +++ b/x-pack/plugins/alerting/server/task_runner/task_runner_factory.test.ts @@ -14,6 +14,7 @@ const alertType = { id: 'test', name: 'My test alert', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', executor: jest.fn(), }; let fakeTimer: sinon.SinonFakeTimers; diff --git a/x-pack/plugins/alerting/server/types.ts b/x-pack/plugins/alerting/server/types.ts index 202a73f076859..90bc7996729a6 100644 --- a/x-pack/plugins/alerting/server/types.ts +++ b/x-pack/plugins/alerting/server/types.ts @@ -8,7 +8,7 @@ import { AlertInstance } from './alert_instance'; import { AlertTypeRegistry as OrigAlertTypeRegistry } from './alert_type_registry'; import { PluginSetupContract, PluginStartContract } from './plugin'; import { SavedObjectAttributes, SavedObjectsClientContract } from '../../../../src/core/server'; -import { Alert, AlertActionParams } from '../common'; +import { Alert, AlertActionParams, ActionGroup } from '../common'; import { AlertsClient } from './alerts_client'; export * from '../common'; @@ -52,11 +52,6 @@ export interface AlertExecutorOptions { updatedBy: string | null; } -export interface ActionGroup { - id: string; - name: string; -} - export interface AlertType { id: string; name: string; @@ -64,6 +59,7 @@ export interface AlertType { params?: { validate: (object: any) => any }; }; actionGroups: ActionGroup[]; + defaultActionGroupId: ActionGroup['id']; executor: ({ services, params, state }: AlertExecutorOptions) => Promise; } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts index 93a46862f4cd2..1e53e7d983848 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts @@ -40,6 +40,7 @@ describe('loadAlertTypes', () => { name: 'Test', actionVariables: ['var1'], actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', }, ]; http.get.mockResolvedValueOnce(resolvedValue); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.test.tsx index ce524ed8178ee..aa71621f1a914 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.test.tsx @@ -158,6 +158,7 @@ describe('alert_form', () => { alertTypeRegistry.has.mockReturnValue(true); actionTypeRegistry.list.mockReturnValue([actionType]); actionTypeRegistry.has.mockReturnValue(true); + actionTypeRegistry.get.mockReturnValue(actionType); const initialAlert = ({ name: 'test', diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.tsx index 95c049f32436a..18dc88f54e907 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.tsx @@ -40,7 +40,6 @@ import { ActionTypeIndex, ActionConnector, AlertTypeIndex, - ActionGroup, } from '../../../types'; import { SectionLoading } from '../../components/section_loading'; import { ConnectorAddModal } from '../action_connector_form/connector_add_modal'; @@ -119,7 +118,7 @@ export const AlertForm = ({ const [alertThrottleUnit, setAlertThrottleUnit] = useState('m'); const [isAddActionPanelOpen, setIsAddActionPanelOpen] = useState(true); const [connectors, setConnectors] = useState([]); - const [defaultActionGroup, setDefaultActionGroup] = useState(undefined); + const [defaultActionGroupId, setDefaultActionGroupId] = useState(undefined); const [activeActionItem, setActiveActionItem] = useState( undefined ); @@ -166,13 +165,14 @@ export const AlertForm = ({ ], name: 'threshold', actionVariables: ['ctx.metadata.name', 'ctx.metadata.test'], + defaultActionGroupId: 'alert', }); const index: AlertTypeIndex = {}; for (const alertTypeItem of alertTypes) { index[alertTypeItem.id] = alertTypeItem; } - if (alert.alertTypeId) { - setDefaultActionGroup(index[alert.alertTypeId].actionGroups[0]); + if (alert.alertTypeId && index[alert.alertTypeId]) { + setDefaultActionGroupId(index[alert.alertTypeId].defaultActionGroupId); } setAlertTypesIndex(index); } catch (e) { @@ -251,6 +251,14 @@ export const AlertForm = ({ : null; function addActionType(actionTypeModel: ActionTypeModel) { + if (!defaultActionGroupId) { + toastNotifications!.addDanger({ + title: i18n.translate('xpack.triggersActionsUI.sections.alertForm.unableToAddAction', { + defaultMessage: 'Unable to add action, because default action group is not defined', + }), + }); + return; + } setIsAddActionPanelOpen(false); const actionTypeConnectors = connectors.filter( field => field.actionTypeId === actionTypeModel.id @@ -266,7 +274,7 @@ export const AlertForm = ({ alert.actions.push({ id: '', actionTypeId: actionTypeModel.id, - group: defaultActionGroup?.id ?? 'Alert', + group: defaultActionGroupId, params: {}, }); setActionProperty('id', freeConnectors[0].id, alert.actions.length - 1); @@ -278,7 +286,7 @@ export const AlertForm = ({ alert.actions.push({ id: '', actionTypeId: actionTypeModel.id, - group: defaultActionGroup?.id ?? 'Alert', + group: defaultActionGroupId, params: {}, }); setActionProperty('id', alert.actions.length, alert.actions.length - 1); @@ -294,12 +302,8 @@ export const AlertForm = ({ onClick={() => { setAlertProperty('alertTypeId', item.id); setAlertTypeModel(item); - if ( - alertTypesIndex && - alertTypesIndex[item.id] && - alertTypesIndex[item.id].actionGroups.length > 0 - ) { - setDefaultActionGroup(alertTypesIndex[item.id].actionGroups[0]); + if (alertTypesIndex && alertTypesIndex[item.id]) { + setDefaultActionGroupId(alertTypesIndex[item.id].defaultActionGroupId); } }} > @@ -356,7 +360,7 @@ export const AlertForm = ({ id, })); const actionTypeRegisterd = actionTypeRegistry.get(actionConnector.actionTypeId); - if (actionTypeRegisterd === null || actionItem.group !== defaultActionGroup?.id) return null; + if (!actionTypeRegisterd || actionItem.group !== defaultActionGroupId) return null; const ParamsFieldsComponent = actionTypeRegisterd.actionParamsFields; const actionParamsErrors: { errors: IErrorObject } = Object.keys(actionsErrors).length > 0 ? actionsErrors[actionItem.id] : { errors: {} }; @@ -368,7 +372,7 @@ export const AlertForm = ({ id={index.toString()} className="euiAccordionForm" buttonContentClassName="euiAccordionForm__button" - data-test-subj="alertActionAccordion" + data-test-subj={`alertActionAccordion-${defaultActionGroupId}`} buttonContent={ @@ -465,7 +469,9 @@ export const AlertForm = ({ errors={actionParamsErrors.errors} editAction={setActionParamsProperty} messageVariables={ - alertTypesIndex ? alertTypesIndex[alert.alertTypeId].actionVariables : undefined + alertTypesIndex && alertTypesIndex[alert.alertTypeId] + ? alertTypesIndex[alert.alertTypeId].actionVariables + : undefined } defaultMessage={alertTypeModel?.defaultActionMessage ?? undefined} /> @@ -479,7 +485,7 @@ export const AlertForm = ({ ? actionTypesIndex[actionItem.actionTypeId].name : actionItem.actionTypeId; const actionTypeRegisterd = actionTypeRegistry.get(actionItem.actionTypeId); - if (actionTypeRegisterd === null || actionItem.group !== defaultActionGroup?.id) return null; + if (!actionTypeRegisterd || actionItem.group !== defaultActionGroupId) return null; return ( diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx index c67954bdc44fd..d2cf2decc4a16 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_details.test.tsx @@ -45,6 +45,7 @@ describe('alert_details', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -65,6 +66,7 @@ describe('alert_details', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -92,6 +94,7 @@ describe('alert_details', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -141,6 +144,7 @@ describe('alert_details', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; const actionTypes: ActionType[] = [ @@ -191,6 +195,7 @@ describe('alert_details', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -215,6 +220,7 @@ describe('alert_details', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -239,6 +245,7 @@ describe('alert_details', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -268,6 +275,7 @@ describe('enable button', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -293,6 +301,7 @@ describe('enable button', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -318,6 +327,7 @@ describe('enable button', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -352,6 +362,7 @@ describe('enable button', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -389,6 +400,7 @@ describe('mute button', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -415,6 +427,7 @@ describe('mute button', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -441,6 +454,7 @@ describe('mute button', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -476,6 +490,7 @@ describe('mute button', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; @@ -511,6 +526,7 @@ describe('mute button', () => { id: '.noop', name: 'No Op', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', actionVariables: [], }; diff --git a/x-pack/plugins/triggers_actions_ui/public/types.ts b/x-pack/plugins/triggers_actions_ui/public/types.ts index aa1d3d068ed77..2119c08bedc31 100644 --- a/x-pack/plugins/triggers_actions_ui/public/types.ts +++ b/x-pack/plugins/triggers_actions_ui/public/types.ts @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { ActionGroup } from '../../alerting/common'; import { ActionType } from '../../actions/common'; import { TypeRegistry } from './application/type_registry'; import { @@ -70,17 +71,16 @@ export interface ActionConnectorTableItem extends ActionConnector { actionType: ActionType['name']; } -export interface ActionGroup { - id: string; - name: string; -} export interface AlertType { id: string; name: string; actionGroups: ActionGroup[]; actionVariables: string[]; + defaultActionGroupId: ActionGroup['id']; } +export type SanitizedAlertType = Omit; + export type AlertWithoutId = Omit; export interface AlertTableItem extends Alert { diff --git a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/index.ts b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/index.ts index b06e0c9e0f8cd..2e7674f2b3eb7 100644 --- a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/index.ts +++ b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/index.ts @@ -206,6 +206,7 @@ export default function(kibana: any) { { id: 'default', name: 'Default' }, { id: 'other', name: 'Other' }, ], + defaultActionGroupId: 'default', async executor(alertExecutorOptions: AlertExecutorOptions) { const { services, @@ -260,6 +261,7 @@ export default function(kibana: any) { { id: 'default', name: 'Default' }, { id: 'other', name: 'Other' }, ], + defaultActionGroupId: 'default', async executor(alertExecutorOptions: AlertExecutorOptions) { const { services, state } = alertExecutorOptions; const group = 'default'; @@ -281,7 +283,13 @@ export default function(kibana: any) { const neverFiringAlertType: AlertType = { id: 'test.never-firing', name: 'Test: Never firing', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', async executor({ services, params, state }: AlertExecutorOptions) { await services.callCluster('index', { index: params.index, @@ -301,7 +309,13 @@ export default function(kibana: any) { const failingAlertType: AlertType = { id: 'test.failing', name: 'Test: Failing', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', async executor({ services, params, state }: AlertExecutorOptions) { await services.callCluster('index', { index: params.index, @@ -319,7 +333,13 @@ export default function(kibana: any) { const authorizationAlertType: AlertType = { id: 'test.authorization', name: 'Test: Authorization', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', validate: { params: schema.object({ callClusterAuthorizationIndex: schema.string(), @@ -378,7 +398,13 @@ export default function(kibana: any) { const validationAlertType: AlertType = { id: 'test.validation', name: 'Test: Validation', - actionGroups: [], + actionGroups: [ + { + id: 'default', + name: 'Default', + }, + ], + defaultActionGroupId: 'default', validate: { params: schema.object({ param1: schema.string(), @@ -390,6 +416,7 @@ export default function(kibana: any) { id: 'test.noop', name: 'Test: Noop', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', async executor({ services, params, state }: AlertExecutorOptions) {}, }; server.newPlatform.setup.plugins.alerting.registerType(alwaysFiringAlertType); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts index 517a60f77849e..30c1548b7db2a 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts @@ -41,6 +41,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) { ); expect(fixtureAlertType).to.eql({ actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', id: 'test.noop', name: 'Test: Noop', }); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts index 55570744f6af9..590de1ea7ce0b 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts @@ -21,6 +21,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) { const fixtureAlertType = response.body.find((alertType: any) => alertType.id === 'test.noop'); expect(fixtureAlertType).to.eql({ actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', id: 'test.noop', name: 'Test: Noop', }); diff --git a/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/index.ts b/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/index.ts index 678707af40bae..9069044b83ed9 100644 --- a/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/index.ts +++ b/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/index.ts @@ -23,6 +23,7 @@ function createNoopAlertType(setupContract: any) { id: 'test.noop', name: 'Test: Noop', actionGroups: [{ id: 'default', name: 'Default' }], + defaultActionGroupId: 'default', async executor() {}, }; setupContract.registerType(noopAlertType);