From 1741ee635471b6bb437da77ade75431b4d728cea Mon Sep 17 00:00:00 2001 From: Yuliia Naumenko Date: Tue, 16 Mar 2021 12:59:46 -0700 Subject: [PATCH] [Connectors UI] Make UI use new connector APIs (#94180) * [Connectors UI] Make UI use new connector APIs * fixed tests * fixed due to comment * fixed due to comment * fixed test * fixed test * fixed test * moved rewrite_request_case to the common folder * fixed due to comments --- x-pack/plugins/actions/common/index.ts | 2 + .../routes => common}/rewrite_request_case.ts | 0 .../actions/server/routes/connector_types.ts | 3 +- .../plugins/actions/server/routes/create.ts | 3 +- .../plugins/actions/server/routes/execute.ts | 3 +- x-pack/plugins/actions/server/routes/get.ts | 3 +- .../plugins/actions/server/routes/get_all.ts | 3 +- .../plugins/actions/server/routes/update.ts | 3 +- .../builtin_action_types/jira/api.test.ts | 8 +- .../builtin_action_types/jira/api.ts | 8 +- .../resilient/api.test.ts | 4 +- .../builtin_action_types/resilient/api.ts | 4 +- .../servicenow/api.test.ts | 2 +- .../builtin_action_types/servicenow/api.ts | 2 +- .../lib/action_connector_api.test.ts | 161 ------------------ .../application/lib/action_connector_api.ts | 83 --------- .../connector_types.test.ts | 49 ++++++ .../action_connector_api/connector_types.ts | 32 ++++ .../action_connector_api/connectors.test.ts | 27 +++ .../lib/action_connector_api/connectors.ts | 37 ++++ .../lib/action_connector_api/create.test.ts | 48 ++++++ .../lib/action_connector_api/create.ts | 43 +++++ .../lib/action_connector_api/delete.test.ts | 35 ++++ .../lib/action_connector_api/delete.ts | 28 +++ .../lib/action_connector_api/execute.test.ts | 42 +++++ .../lib/action_connector_api/execute.ts | 38 +++++ .../lib/action_connector_api/index.ts | 13 ++ .../lib/action_connector_api/update.test.ts | 49 ++++++ .../lib/action_connector_api/update.ts | 42 +++++ .../triggers_actions_ui/public/types.ts | 2 +- .../apps/triggers_actions_ui/alerts_list.ts | 2 +- .../apps/triggers_actions_ui/connectors.ts | 2 +- .../apps/triggers_actions_ui/details.ts | 4 +- .../apps/triggers_actions_ui/home_page.ts | 2 +- .../lib/get_test_data.ts | 2 +- 35 files changed, 512 insertions(+), 277 deletions(-) rename x-pack/plugins/actions/{server/routes => common}/rewrite_request_case.ts (100%) delete mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api.test.ts delete mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connector_types.test.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connector_types.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.test.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.test.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/delete.test.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/delete.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/execute.test.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/execute.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/index.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.test.ts create mode 100644 x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.ts diff --git a/x-pack/plugins/actions/common/index.ts b/x-pack/plugins/actions/common/index.ts index f0e1439bce3e3..184ae9c226b8f 100644 --- a/x-pack/plugins/actions/common/index.ts +++ b/x-pack/plugins/actions/common/index.ts @@ -8,3 +8,5 @@ export * from './types'; export const BASE_ACTION_API_PATH = '/api/actions'; + +export * from './rewrite_request_case'; diff --git a/x-pack/plugins/actions/server/routes/rewrite_request_case.ts b/x-pack/plugins/actions/common/rewrite_request_case.ts similarity index 100% rename from x-pack/plugins/actions/server/routes/rewrite_request_case.ts rename to x-pack/plugins/actions/common/rewrite_request_case.ts diff --git a/x-pack/plugins/actions/server/routes/connector_types.ts b/x-pack/plugins/actions/server/routes/connector_types.ts index d686ddbdaee70..9f9ad5b2aea68 100644 --- a/x-pack/plugins/actions/server/routes/connector_types.ts +++ b/x-pack/plugins/actions/server/routes/connector_types.ts @@ -7,10 +7,9 @@ import { IRouter } from 'kibana/server'; import { ILicenseState } from '../lib'; -import { ActionType, BASE_ACTION_API_PATH } from '../../common'; +import { ActionType, BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common'; import { ActionsRequestHandlerContext } from '../types'; import { verifyAccessAndContext } from './verify_access_and_context'; -import { RewriteResponseCase } from './rewrite_request_case'; const rewriteBodyRes: RewriteResponseCase = (results) => { return results.map(({ enabledInConfig, enabledInLicense, minimumLicenseRequired, ...res }) => ({ diff --git a/x-pack/plugins/actions/server/routes/create.ts b/x-pack/plugins/actions/server/routes/create.ts index e1717891231db..c05f2180bd62b 100644 --- a/x-pack/plugins/actions/server/routes/create.ts +++ b/x-pack/plugins/actions/server/routes/create.ts @@ -9,9 +9,8 @@ import { schema } from '@kbn/config-schema'; import { IRouter } from 'kibana/server'; import { ActionResult, ActionsRequestHandlerContext } from '../types'; import { ILicenseState } from '../lib'; -import { BASE_ACTION_API_PATH } from '../../common'; +import { BASE_ACTION_API_PATH, RewriteRequestCase, RewriteResponseCase } from '../../common'; import { verifyAccessAndContext } from './verify_access_and_context'; -import { RewriteRequestCase, RewriteResponseCase } from './rewrite_request_case'; import { CreateOptions } from '../actions_client'; export const bodySchema = schema.object({ diff --git a/x-pack/plugins/actions/server/routes/execute.ts b/x-pack/plugins/actions/server/routes/execute.ts index 0d1bee83ed047..377fe1215b3fb 100644 --- a/x-pack/plugins/actions/server/routes/execute.ts +++ b/x-pack/plugins/actions/server/routes/execute.ts @@ -10,10 +10,9 @@ import { IRouter } from 'kibana/server'; import { ILicenseState } from '../lib'; import { ActionTypeExecutorResult, ActionsRequestHandlerContext } from '../types'; -import { BASE_ACTION_API_PATH } from '../../common'; +import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common'; import { asHttpRequestExecutionSource } from '../lib/action_execution_source'; import { verifyAccessAndContext } from './verify_access_and_context'; -import { RewriteResponseCase } from './rewrite_request_case'; const paramSchema = schema.object({ id: schema.string(), diff --git a/x-pack/plugins/actions/server/routes/get.ts b/x-pack/plugins/actions/server/routes/get.ts index 63f89d6b3ca49..59766fc133ba6 100644 --- a/x-pack/plugins/actions/server/routes/get.ts +++ b/x-pack/plugins/actions/server/routes/get.ts @@ -8,10 +8,9 @@ import { schema } from '@kbn/config-schema'; import { IRouter } from 'kibana/server'; import { ILicenseState } from '../lib'; -import { BASE_ACTION_API_PATH } from '../../common'; +import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common'; import { ActionResult, ActionsRequestHandlerContext } from '../types'; import { verifyAccessAndContext } from './verify_access_and_context'; -import { RewriteResponseCase } from './rewrite_request_case'; const paramSchema = schema.object({ id: schema.string(), diff --git a/x-pack/plugins/actions/server/routes/get_all.ts b/x-pack/plugins/actions/server/routes/get_all.ts index 32f48e32ab278..831722fd36eed 100644 --- a/x-pack/plugins/actions/server/routes/get_all.ts +++ b/x-pack/plugins/actions/server/routes/get_all.ts @@ -7,10 +7,9 @@ import { IRouter } from 'kibana/server'; import { ILicenseState } from '../lib'; -import { BASE_ACTION_API_PATH } from '../../common'; +import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common'; import { ActionsRequestHandlerContext, FindActionResult } from '../types'; import { verifyAccessAndContext } from './verify_access_and_context'; -import { RewriteResponseCase } from './rewrite_request_case'; const rewriteBodyRes: RewriteResponseCase = (results) => { return results.map(({ actionTypeId, isPreconfigured, referencedByCount, ...res }) => ({ diff --git a/x-pack/plugins/actions/server/routes/update.ts b/x-pack/plugins/actions/server/routes/update.ts index af55fa32b76ca..d1758717e80f9 100644 --- a/x-pack/plugins/actions/server/routes/update.ts +++ b/x-pack/plugins/actions/server/routes/update.ts @@ -8,10 +8,9 @@ import { schema } from '@kbn/config-schema'; import { IRouter } from 'kibana/server'; import { ILicenseState } from '../lib'; -import { BASE_ACTION_API_PATH } from '../../common'; +import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common'; import { ActionResult, ActionsRequestHandlerContext } from '../types'; import { verifyAccessAndContext } from './verify_access_and_context'; -import { RewriteResponseCase } from './rewrite_request_case'; const paramSchema = schema.object({ id: schema.string(), diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/api.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/api.test.ts index 3ad3c6ce02372..679bc3d53c40d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/api.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/api.test.ts @@ -102,7 +102,7 @@ describe('Jira API', () => { const res = await getIssueTypes({ http, signal: abortCtrl.signal, connectorId: 'test' }); expect(res).toEqual(issueTypesResponse); - expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', { + expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', { body: '{"params":{"subAction":"issueTypes","subActionParams":{}}}', signal: abortCtrl.signal, }); @@ -121,7 +121,7 @@ describe('Jira API', () => { }); expect(res).toEqual(fieldsResponse); - expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', { + expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', { body: '{"params":{"subAction":"fieldsByIssueType","subActionParams":{"id":"10006"}}}', signal: abortCtrl.signal, }); @@ -140,7 +140,7 @@ describe('Jira API', () => { }); expect(res).toEqual(issuesResponse); - expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', { + expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', { body: '{"params":{"subAction":"issues","subActionParams":{"title":"test issue"}}}', signal: abortCtrl.signal, }); @@ -159,7 +159,7 @@ describe('Jira API', () => { }); expect(res).toEqual(issuesResponse); - expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', { + expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', { body: '{"params":{"subAction":"issue","subActionParams":{"id":"RJ-107"}}}', signal: abortCtrl.signal, }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/api.ts b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/api.ts index 0184a1f0ca2e5..46ea9dea3aa56 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/api.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/api.ts @@ -17,7 +17,7 @@ export async function getIssueTypes({ signal: AbortSignal; connectorId: string; }): Promise> { - return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, { + return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, { body: JSON.stringify({ params: { subAction: 'issueTypes', subActionParams: {} }, }), @@ -36,7 +36,7 @@ export async function getFieldsByIssueType({ connectorId: string; id: string; }): Promise> { - return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, { + return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, { body: JSON.stringify({ params: { subAction: 'fieldsByIssueType', subActionParams: { id } }, }), @@ -55,7 +55,7 @@ export async function getIssues({ connectorId: string; title: string; }): Promise> { - return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, { + return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, { body: JSON.stringify({ params: { subAction: 'issues', subActionParams: { title } }, }), @@ -74,7 +74,7 @@ export async function getIssue({ connectorId: string; id: string; }): Promise> { - return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, { + return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, { body: JSON.stringify({ params: { subAction: 'issue', subActionParams: { id } }, }), diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/api.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/api.test.ts index 68edff4dc3950..01208f93405d2 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/api.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/api.test.ts @@ -61,7 +61,7 @@ describe('Resilient API', () => { }); expect(res).toEqual(incidentTypesResponse); - expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', { + expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', { body: '{"params":{"subAction":"incidentTypes","subActionParams":{}}}', signal: abortCtrl.signal, }); @@ -79,7 +79,7 @@ describe('Resilient API', () => { }); expect(res).toEqual(severityResponse); - expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', { + expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', { body: '{"params":{"subAction":"severity","subActionParams":{}}}', signal: abortCtrl.signal, }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/api.ts b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/api.ts index 46077fcaf6890..8ea3c3c63e50f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/api.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/resilient/api.ts @@ -17,7 +17,7 @@ export async function getIncidentTypes({ signal: AbortSignal; connectorId: string; }): Promise> { - return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, { + return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, { body: JSON.stringify({ params: { subAction: 'incidentTypes', subActionParams: {} }, }), @@ -34,7 +34,7 @@ export async function getSeverity({ signal: AbortSignal; connectorId: string; }): Promise> { - return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, { + return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, { body: JSON.stringify({ params: { subAction: 'severity', subActionParams: {} }, }), diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/api.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/api.test.ts index 9d9b3c5e64909..5c814bbfd6450 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/api.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/api.test.ts @@ -61,7 +61,7 @@ describe('ServiceNow API', () => { }); expect(res).toEqual(choicesResponse); - expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', { + expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', { body: '{"params":{"subAction":"getChoices","subActionParams":{"fields":["priority"]}}}', signal: abortCtrl.signal, }); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/api.ts b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/api.ts index 3e92515e49b49..bb90915591285 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/api.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/servicenow/api.ts @@ -19,7 +19,7 @@ export async function getChoices({ connectorId: string; fields: string[]; }): Promise> { - return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, { + return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, { body: JSON.stringify({ params: { subAction: 'getChoices', subActionParams: { fields } }, }), diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api.test.ts deleted file mode 100644 index bf70e4c5f2408..0000000000000 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api.test.ts +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ActionConnector, ActionConnectorWithoutId, ActionType } from '../../types'; -import { httpServiceMock } from '../../../../../../src/core/public/mocks'; -import { - createActionConnector, - deleteActions, - loadActionTypes, - loadAllActions, - updateActionConnector, - executeAction, -} from './action_connector_api'; - -const http = httpServiceMock.createStartContract(); - -beforeEach(() => jest.resetAllMocks()); - -describe('loadActionTypes', () => { - test('should call get types API', async () => { - const resolvedValue: ActionType[] = [ - { - id: 'test', - name: 'Test', - enabled: true, - enabledInConfig: true, - enabledInLicense: true, - minimumLicenseRequired: 'basic', - }, - ]; - http.get.mockResolvedValueOnce(resolvedValue); - - const result = await loadActionTypes({ http }); - expect(result).toEqual(resolvedValue); - expect(http.get.mock.calls[0]).toMatchInlineSnapshot(` - Array [ - "/api/actions/list_action_types", - ] - `); - }); -}); - -describe('loadAllActions', () => { - test('should call getAll actions API', async () => { - http.get.mockResolvedValueOnce([]); - - const result = await loadAllActions({ http }); - expect(result).toEqual([]); - expect(http.get.mock.calls[0]).toMatchInlineSnapshot(` - Array [ - "/api/actions", - ] - `); - }); -}); - -describe('createActionConnector', () => { - test('should call create action API', async () => { - const connector: ActionConnectorWithoutId<{}, {}> = { - actionTypeId: 'test', - isPreconfigured: false, - name: 'My test', - config: {}, - secrets: {}, - }; - const resolvedValue: ActionConnector = { ...connector, id: '123' }; - http.post.mockResolvedValueOnce(resolvedValue); - - const result = await createActionConnector({ http, connector }); - expect(result).toEqual(resolvedValue); - expect(http.post.mock.calls[0]).toMatchInlineSnapshot(` - Array [ - "/api/actions/action", - Object { - "body": "{\\"actionTypeId\\":\\"test\\",\\"isPreconfigured\\":false,\\"name\\":\\"My test\\",\\"config\\":{},\\"secrets\\":{}}", - }, - ] - `); - }); -}); - -describe('updateActionConnector', () => { - test('should call the update API', async () => { - const id = '123'; - const connector: ActionConnectorWithoutId<{}, {}> = { - actionTypeId: 'test', - isPreconfigured: false, - name: 'My test', - config: {}, - secrets: {}, - }; - const resolvedValue = { ...connector, id }; - http.put.mockResolvedValueOnce(resolvedValue); - - const result = await updateActionConnector({ http, connector, id }); - expect(result).toEqual(resolvedValue); - expect(http.put.mock.calls[0]).toMatchInlineSnapshot(` - Array [ - "/api/actions/action/123", - Object { - "body": "{\\"name\\":\\"My test\\",\\"config\\":{},\\"secrets\\":{}}", - }, - ] - `); - }); -}); - -describe('deleteActions', () => { - test('should call delete API per action', async () => { - const ids = ['1', '2', '3']; - - const result = await deleteActions({ ids, http }); - expect(result).toEqual({ errors: [], successes: [undefined, undefined, undefined] }); - expect(http.delete.mock.calls).toMatchInlineSnapshot(` - Array [ - Array [ - "/api/actions/action/1", - ], - Array [ - "/api/actions/action/2", - ], - Array [ - "/api/actions/action/3", - ], - ] - `); - }); -}); - -describe('executeAction', () => { - test('should call execute API', async () => { - const id = '123'; - const params = { - stringParams: 'someString', - numericParams: 123, - }; - - http.post.mockResolvedValueOnce({ - actionId: id, - status: 'ok', - }); - - const result = await executeAction({ id, http, params }); - expect(result).toEqual({ - actionId: id, - status: 'ok', - }); - expect(http.post.mock.calls[0]).toMatchInlineSnapshot(` - Array [ - "/api/actions/action/123/_execute", - Object { - "body": "{\\"params\\":{\\"stringParams\\":\\"someString\\",\\"numericParams\\":123}}", - }, - ] - `); - }); -}); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api.ts deleted file mode 100644 index 57fb079d97299..0000000000000 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { HttpSetup } from 'kibana/public'; -import { BASE_ACTION_API_PATH } from '../constants'; -import type { ActionConnector, ActionConnectorWithoutId, ActionType } from '../../types'; -import { ActionTypeExecutorResult } from '../../../../../plugins/actions/common'; - -export async function loadActionTypes({ http }: { http: HttpSetup }): Promise { - return await http.get(`${BASE_ACTION_API_PATH}/list_action_types`); -} - -export async function loadAllActions({ http }: { http: HttpSetup }): Promise { - return await http.get(`${BASE_ACTION_API_PATH}`); -} - -export async function createActionConnector({ - http, - connector, -}: { - http: HttpSetup; - connector: Omit; -}): Promise { - return await http.post(`${BASE_ACTION_API_PATH}/action`, { - body: JSON.stringify(connector), - }); -} - -export async function updateActionConnector({ - http, - connector, - id, -}: { - http: HttpSetup; - connector: Pick; - id: string; -}): Promise { - return await http.put(`${BASE_ACTION_API_PATH}/action/${id}`, { - body: JSON.stringify({ - name: connector.name, - config: connector.config, - secrets: connector.secrets, - }), - }); -} - -export async function deleteActions({ - ids, - http, -}: { - ids: string[]; - http: HttpSetup; -}): Promise<{ successes: string[]; errors: string[] }> { - const successes: string[] = []; - const errors: string[] = []; - await Promise.all(ids.map((id) => http.delete(`${BASE_ACTION_API_PATH}/action/${id}`))).then( - function (fulfilled) { - successes.push(...fulfilled); - }, - function (rejected) { - errors.push(...rejected); - } - ); - return { successes, errors }; -} - -export async function executeAction({ - id, - params, - http, -}: { - id: string; - http: HttpSetup; - params: Record; -}): Promise> { - return http.post(`${BASE_ACTION_API_PATH}/action/${id}/_execute`, { - body: JSON.stringify({ params }), - }); -} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connector_types.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connector_types.test.ts new file mode 100644 index 0000000000000..8815757df6af5 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connector_types.test.ts @@ -0,0 +1,49 @@ +/* + * 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 { ActionType } from '../../../types'; +import { httpServiceMock } from '../../../../../../../src/core/public/mocks'; +import { loadActionTypes } from './index'; + +const http = httpServiceMock.createStartContract(); + +beforeEach(() => jest.resetAllMocks()); + +describe('loadActionTypes', () => { + test('should call get types API', async () => { + const apiResponseValue = [ + { + id: 'test', + name: 'Test', + enabled: true, + enabled_in_config: true, + enabled_in_license: true, + minimum_license_required: 'basic', + }, + ]; + http.get.mockResolvedValueOnce(apiResponseValue); + + const resolvedValue: ActionType[] = [ + { + id: 'test', + name: 'Test', + enabled: true, + enabledInConfig: true, + enabledInLicense: true, + minimumLicenseRequired: 'basic', + }, + ]; + + const result = await loadActionTypes({ http }); + expect(result).toEqual(resolvedValue); + expect(http.get.mock.calls[0]).toMatchInlineSnapshot(` + Array [ + "/api/actions/connector_types", + ] + `); + }); +}); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connector_types.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connector_types.ts new file mode 100644 index 0000000000000..6f7e8b03658e0 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connector_types.ts @@ -0,0 +1,32 @@ +/* + * 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 { HttpSetup } from 'kibana/public'; + +import { AsApiContract, RewriteRequestCase } from '../../../../../actions/common'; +import { BASE_ACTION_API_PATH } from '../../constants'; +import type { ActionType } from '../../../types'; + +const rewriteResponseRes = (results: Array>): ActionType[] => { + return results.map((item) => rewriteBodyReq(item)); +}; + +const rewriteBodyReq: RewriteRequestCase = ({ + enabled_in_config: enabledInConfig, + enabled_in_license: enabledInLicense, + minimum_license_required: minimumLicenseRequired, + ...res +}: AsApiContract) => ({ + enabledInConfig, + enabledInLicense, + minimumLicenseRequired, + ...res, +}); + +export async function loadActionTypes({ http }: { http: HttpSetup }): Promise { + const res = await http.get(`${BASE_ACTION_API_PATH}/connector_types`); + return rewriteResponseRes(res); +} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.test.ts new file mode 100644 index 0000000000000..565cc0afebfea --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.test.ts @@ -0,0 +1,27 @@ +/* + * 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 { httpServiceMock } from '../../../../../../../src/core/public/mocks'; +import { loadAllActions } from './index'; + +const http = httpServiceMock.createStartContract(); + +beforeEach(() => jest.resetAllMocks()); + +describe('loadAllActions', () => { + test('should call getAll actions API', async () => { + http.get.mockResolvedValueOnce([]); + + const result = await loadAllActions({ http }); + expect(result).toEqual([]); + expect(http.get.mock.calls[0]).toMatchInlineSnapshot(` + Array [ + "/api/actions/connectors", + ] + `); + }); +}); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.ts new file mode 100644 index 0000000000000..cf424ea1e7317 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.ts @@ -0,0 +1,37 @@ +/* + * 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 { HttpSetup } from 'kibana/public'; +import { AsApiContract, RewriteRequestCase } from '../../../../../actions/common'; +import { BASE_ACTION_API_PATH } from '../../constants'; +import type { ActionConnector, ActionConnectorProps } from '../../../types'; + +const rewriteResponseRes = ( + results: Array< + AsApiContract, Record>> + > +): Array, Record>> => { + return results.map((item) => transformConnector(item)); +}; + +const transformConnector: RewriteRequestCase< + ActionConnectorProps, Record> +> = ({ + connector_type_id: actionTypeId, + is_preconfigured: isPreconfigured, + referenced_by_count: referencedByCount, + ...res +}) => ({ + actionTypeId, + isPreconfigured, + referencedByCount, + ...res, +}); + +export async function loadAllActions({ http }: { http: HttpSetup }): Promise { + const res = await http.get(`${BASE_ACTION_API_PATH}/connectors`); + return rewriteResponseRes(res); +} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.test.ts new file mode 100644 index 0000000000000..208970fbfc061 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.test.ts @@ -0,0 +1,48 @@ +/* + * 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 { ActionConnectorWithoutId } from '../../../types'; +import { httpServiceMock } from '../../../../../../../src/core/public/mocks'; +import { createActionConnector } from './index'; + +const http = httpServiceMock.createStartContract(); + +beforeEach(() => jest.resetAllMocks()); + +describe('createActionConnector', () => { + test('should call create action API', async () => { + const apiResponse = { + connector_type_id: 'test', + is_preconfigured: false, + name: 'My test', + config: {}, + secrets: {}, + id: '123', + }; + http.post.mockResolvedValueOnce(apiResponse); + + const connector: ActionConnectorWithoutId<{}, {}> = { + actionTypeId: 'test', + isPreconfigured: false, + name: 'My test', + config: {}, + secrets: {}, + }; + const resolvedValue = { ...connector, id: '123' }; + + const result = await createActionConnector({ http, connector }); + expect(result).toEqual(resolvedValue); + expect(http.post.mock.calls[0]).toMatchInlineSnapshot(` + Array [ + "/api/actions/connector", + Object { + "body": "{\\"name\\":\\"My test\\",\\"config\\":{},\\"secrets\\":{},\\"connector_type_id\\":\\"test\\",\\"is_preconfigured\\":false}", + }, + ] + `); + }); +}); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.ts new file mode 100644 index 0000000000000..e6e74f3f3c059 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.ts @@ -0,0 +1,43 @@ +/* + * 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 { HttpSetup } from 'kibana/public'; +import { RewriteRequestCase, RewriteResponseCase } from '../../../../../actions/common'; +import { BASE_ACTION_API_PATH } from '../../constants'; +import type { + ActionConnector, + ActionConnectorProps, + ActionConnectorWithoutId, +} from '../../../types'; + +const rewriteBodyRequest: RewriteResponseCase< + Omit +> = ({ actionTypeId, isPreconfigured, ...res }) => ({ + ...res, + connector_type_id: actionTypeId, + is_preconfigured: isPreconfigured, +}); + +const rewriteBodyRes: RewriteRequestCase< + ActionConnectorProps, Record> +> = ({ connector_type_id: actionTypeId, is_preconfigured: isPreconfigured, ...res }) => ({ + ...res, + actionTypeId, + isPreconfigured, +}); + +export async function createActionConnector({ + http, + connector, +}: { + http: HttpSetup; + connector: Omit; +}): Promise { + const res = await http.post(`${BASE_ACTION_API_PATH}/connector`, { + body: JSON.stringify(rewriteBodyRequest(connector)), + }); + return rewriteBodyRes(res); +} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/delete.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/delete.test.ts new file mode 100644 index 0000000000000..bb00c8c30e4ed --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/delete.test.ts @@ -0,0 +1,35 @@ +/* + * 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 { httpServiceMock } from '../../../../../../../src/core/public/mocks'; +import { deleteActions } from './index'; + +const http = httpServiceMock.createStartContract(); + +beforeEach(() => jest.resetAllMocks()); + +describe('deleteActions', () => { + test('should call delete API per action', async () => { + const ids = ['1', '2', '3']; + + const result = await deleteActions({ ids, http }); + expect(result).toEqual({ errors: [], successes: [undefined, undefined, undefined] }); + expect(http.delete.mock.calls).toMatchInlineSnapshot(` + Array [ + Array [ + "/api/actions/connector/1", + ], + Array [ + "/api/actions/connector/2", + ], + Array [ + "/api/actions/connector/3", + ], + ] + `); + }); +}); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/delete.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/delete.ts new file mode 100644 index 0000000000000..c9c25db676a06 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/delete.ts @@ -0,0 +1,28 @@ +/* + * 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 { HttpSetup } from 'kibana/public'; +import { BASE_ACTION_API_PATH } from '../../constants'; + +export async function deleteActions({ + ids, + http, +}: { + ids: string[]; + http: HttpSetup; +}): Promise<{ successes: string[]; errors: string[] }> { + const successes: string[] = []; + const errors: string[] = []; + await Promise.all(ids.map((id) => http.delete(`${BASE_ACTION_API_PATH}/connector/${id}`))).then( + function (fulfilled) { + successes.push(...fulfilled); + }, + function (rejected) { + errors.push(...rejected); + } + ); + return { successes, errors }; +} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/execute.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/execute.test.ts new file mode 100644 index 0000000000000..60cd3132aa756 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/execute.test.ts @@ -0,0 +1,42 @@ +/* + * 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 { httpServiceMock } from '../../../../../../../src/core/public/mocks'; +import { executeAction } from './index'; + +const http = httpServiceMock.createStartContract(); + +beforeEach(() => jest.resetAllMocks()); + +describe('executeAction', () => { + test('should call execute API', async () => { + const id = '123'; + const params = { + stringParams: 'someString', + numericParams: 123, + }; + + http.post.mockResolvedValueOnce({ + connector_id: id, + status: 'ok', + }); + + const result = await executeAction({ id, http, params }); + expect(result).toEqual({ + actionId: id, + status: 'ok', + }); + expect(http.post.mock.calls[0]).toMatchInlineSnapshot(` + Array [ + "/api/actions/connector/123/_execute", + Object { + "body": "{\\"params\\":{\\"stringParams\\":\\"someString\\",\\"numericParams\\":123}}", + }, + ] + `); + }); +}); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/execute.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/execute.ts new file mode 100644 index 0000000000000..638ceddb5652f --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/execute.ts @@ -0,0 +1,38 @@ +/* + * 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 { HttpSetup } from 'kibana/public'; +import { + ActionTypeExecutorResult, + RewriteRequestCase, +} from '../../../../../../plugins/actions/common'; +import { BASE_ACTION_API_PATH } from '../../constants'; + +const rewriteBodyRes: RewriteRequestCase> = ({ + connector_id: actionId, + service_message: serviceMessage, + ...res +}) => ({ + ...res, + actionId, + serviceMessage, +}); + +export async function executeAction({ + id, + params, + http, +}: { + id: string; + http: HttpSetup; + params: Record; +}): Promise> { + const res = await http.post(`${BASE_ACTION_API_PATH}/connector/${id}/_execute`, { + body: JSON.stringify({ params }), + }); + return rewriteBodyRes(res); +} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/index.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/index.ts new file mode 100644 index 0000000000000..7cc4f1df6a735 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/index.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +export { loadActionTypes } from './connector_types'; +export { loadAllActions } from './connectors'; +export { createActionConnector } from './create'; +export { deleteActions } from './delete'; +export { executeAction } from './execute'; +export { updateActionConnector } from './update'; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.test.ts new file mode 100644 index 0000000000000..29e7a1e4bed3d --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.test.ts @@ -0,0 +1,49 @@ +/* + * 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 { ActionConnectorWithoutId } from '../../../types'; +import { httpServiceMock } from '../../../../../../../src/core/public/mocks'; +import { updateActionConnector } from './index'; + +const http = httpServiceMock.createStartContract(); + +beforeEach(() => jest.resetAllMocks()); + +describe('updateActionConnector', () => { + test('should call the update API', async () => { + const id = '123'; + const apiResponse = { + connector_type_id: 'test', + is_preconfigured: false, + name: 'My test', + config: {}, + secrets: {}, + id, + }; + http.put.mockResolvedValueOnce(apiResponse); + + const connector: ActionConnectorWithoutId<{}, {}> = { + actionTypeId: 'test', + isPreconfigured: false, + name: 'My test', + config: {}, + secrets: {}, + }; + const resolvedValue = { ...connector, id }; + + const result = await updateActionConnector({ http, connector, id }); + expect(result).toEqual(resolvedValue); + expect(http.put.mock.calls[0]).toMatchInlineSnapshot(` + Array [ + "/api/actions/connector/123", + Object { + "body": "{\\"name\\":\\"My test\\",\\"config\\":{},\\"secrets\\":{}}", + }, + ] + `); + }); +}); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.ts new file mode 100644 index 0000000000000..18b8871ce25d1 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.ts @@ -0,0 +1,42 @@ +/* + * 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 { HttpSetup } from 'kibana/public'; +import { RewriteRequestCase } from '../../../../../actions/common'; +import { BASE_ACTION_API_PATH } from '../../constants'; +import type { + ActionConnector, + ActionConnectorProps, + ActionConnectorWithoutId, +} from '../../../types'; + +const rewriteBodyRes: RewriteRequestCase< + ActionConnectorProps, Record> +> = ({ connector_type_id: actionTypeId, is_preconfigured: isPreconfigured, ...res }) => ({ + ...res, + actionTypeId, + isPreconfigured, +}); + +export async function updateActionConnector({ + http, + connector, + id, +}: { + http: HttpSetup; + connector: Pick; + id: string; +}): Promise { + const res = await http.put(`${BASE_ACTION_API_PATH}/connector/${id}`, { + body: JSON.stringify({ + name: connector.name, + config: connector.config, + secrets: connector.secrets, + }), + }); + + return rewriteBodyRes(res); +} diff --git a/x-pack/plugins/triggers_actions_ui/public/types.ts b/x-pack/plugins/triggers_actions_ui/public/types.ts index 5c5dcf344b10b..cf2dda203bb2d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/types.ts +++ b/x-pack/plugins/triggers_actions_ui/public/types.ts @@ -121,7 +121,7 @@ export interface ConnectorValidationResult { secrets?: GenericValidationResult; } -interface ActionConnectorProps { +export interface ActionConnectorProps { secrets: Secrets; id: string; actionTypeId: string; diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts_list.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts_list.ts index 02b95a435fa98..ab79c2c1961a1 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts_list.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts_list.ts @@ -42,7 +42,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { async function createAction(overwrites: Record = {}) { const { body: createdAction } = await supertest - .post(`/api/actions/action`) + .post(`/api/actions/connector`) .set('kbn-xsrf', 'foo') .send(getTestActionData(overwrites)) .expect(200); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts index 7d43001bd0374..e40c821d98851 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts @@ -23,7 +23,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { before(async () => { const { body: createdAction } = await supertest - .post(`/api/actions/action`) + .post(`/api/actions/connector`) .set('kbn-xsrf', 'foo') .send(getTestActionData()) .expect(200); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts index d27be915be512..5c4566121d478 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts @@ -27,7 +27,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { async function createActionManualCleanup(overwrites: Record = {}) { const { body: createdAction } = await supertest - .post(`/api/actions/action`) + .post(`/api/actions/connector`) .set('kbn-xsrf', 'foo') .send(getTestActionData(overwrites)) .expect(200); @@ -372,7 +372,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('should show and update deleted connectors when there are no existing connectors of the same type', async () => { const action = await createActionManualCleanup({ name: `index-${testRunUuid}-${0}`, - actionTypeId: '.index', + connector_type_id: '.index', config: { index: `index-${testRunUuid}-${0}`, }, diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/home_page.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/home_page.ts index 1b1288e4b4db8..4aeadf5f1ae8a 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/home_page.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/home_page.ts @@ -84,7 +84,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('navigates to an alert details page', async () => { const { body: createdAction } = await supertest - .post(`/api/actions/action`) + .post(`/api/actions/connector`) .set('kbn-xsrf', 'foo') .send(getTestActionData()) .expect(200); diff --git a/x-pack/test/functional_with_es_ssl/lib/get_test_data.ts b/x-pack/test/functional_with_es_ssl/lib/get_test_data.ts index a93c9987fd640..11ccd15571259 100644 --- a/x-pack/test/functional_with_es_ssl/lib/get_test_data.ts +++ b/x-pack/test/functional_with_es_ssl/lib/get_test_data.ts @@ -30,7 +30,7 @@ export function getTestAlertData(overwrites = {}) { export function getTestActionData(overwrites = {}) { return { name: `slack-${Date.now()}`, - actionTypeId: '.slack', + connector_type_id: '.slack', config: {}, secrets: { webhookUrl: 'https://test',