From 6a19a041972b12c94f6441b77a13b9a42c389506 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 5 Nov 2020 12:06:59 -0700 Subject: [PATCH] jira refactor, rename from commonFields to getFields --- x-pack/plugins/actions/README.md | 24 +++---- .../builtin_action_types/jira/api.test.ts | 12 +--- .../server/builtin_action_types/jira/api.ts | 6 +- .../server/builtin_action_types/jira/index.ts | 6 +- .../server/builtin_action_types/jira/mocks.ts | 72 +------------------ .../builtin_action_types/jira/schema.ts | 2 +- .../builtin_action_types/jira/service.test.ts | 69 +++++++++++++----- .../builtin_action_types/jira/service.ts | 63 ++++++++-------- .../server/builtin_action_types/jira/types.ts | 13 ++-- .../builtin_action_types/resilient/api.ts | 6 +- .../builtin_action_types/resilient/index.ts | 15 ++-- .../builtin_action_types/resilient/mocks.ts | 2 +- .../builtin_action_types/resilient/schema.ts | 2 +- .../resilient/service.test.ts | 8 +-- .../builtin_action_types/resilient/service.ts | 4 +- .../builtin_action_types/resilient/types.ts | 4 +- .../servicenow/api.test.ts | 4 +- .../builtin_action_types/servicenow/api.ts | 6 +- .../builtin_action_types/servicenow/index.ts | 10 +-- .../builtin_action_types/servicenow/mocks.ts | 2 +- .../builtin_action_types/servicenow/schema.ts | 4 +- .../servicenow/service.test.ts | 8 +-- .../servicenow/service.ts | 4 +- .../builtin_action_types/servicenow/types.ts | 4 +- .../actions/builtin_action_types/jira.ts | 10 +-- .../actions/builtin_action_types/resilient.ts | 10 +-- .../builtin_action_types/servicenow.ts | 10 +-- 27 files changed, 165 insertions(+), 215 deletions(-) diff --git a/x-pack/plugins/actions/README.md b/x-pack/plugins/actions/README.md index 6883883e5ec53..7d7e48dfc579b 100644 --- a/x-pack/plugins/actions/README.md +++ b/x-pack/plugins/actions/README.md @@ -69,21 +69,21 @@ Table of Contents - [`secrets`](#secrets-6) - [`params`](#params-6) - [`subActionParams (pushToService)`](#subactionparams-pushtoservice) - - [`subActionParams (commonFields)`](#subactionparams-commonfields-1) + - [`subActionParams (getFields)`](#subactionparams-getfields-1) - [Jira](#jira) - [`config`](#config-7) - [`secrets`](#secrets-7) - [`params`](#params-7) - [`subActionParams (pushToService)`](#subactionparams-pushtoservice-1) - [`subActionParams (issueTypes)`](#subactionparams-issuetypes) - - [`subActionParams (commonFields)`](#subactionparams-commonfields-2) + - [`subActionParams (getFields)`](#subactionparams-getfields-2) - [`subActionParams (pushToService)`](#subactionparams-pushtoservice-2) - [IBM Resilient](#ibm-resilient) - [`config`](#config-8) - [`secrets`](#secrets-8) - [`params`](#params-8) - [`subActionParams (pushToService)`](#subactionparams-pushtoservice-3) - - [`subActionParams (commonFields)`](#subactionparams-commonfields-3) + - [`subActionParams (getFields)`](#subactionparams-getfields-3) - [Command Line Utility](#command-line-utility) - [Developing New Action Types](#developing-new-action-types) - [licensing](#licensing) @@ -566,7 +566,7 @@ The ServiceNow action uses the [V2 Table API](https://developer.servicenow.com/a | Property | Description | Type | | --------------- | ------------------------------------------------------------------------------------ | ------ | -| subAction | The sub action to perform. It can be `commonFields`, `pushToService`, `handshake`, and `getIncident` | string | +| subAction | The sub action to perform. It can be `getFields`, `pushToService`, `handshake`, and `getIncident` | string | | subActionParams | The parameters of the sub action | object | #### `subActionParams (pushToService)` @@ -583,9 +583,9 @@ The ServiceNow action uses the [V2 Table API](https://developer.servicenow.com/a | urgency | The name of the urgency in ServiceNow. | string _(optional)_ | | impact | The name of the impact in ServiceNow. | string _(optional)_ | -#### `subActionParams (commonFields)` +#### `subActionParams (getFields)` -No parameters for `commonFields` sub-action. Provide an empty object `{}`. +No parameters for `getFields` sub-action. Provide an empty object `{}`. --- @@ -613,7 +613,7 @@ The Jira action uses the [V2 API](https://developer.atlassian.com/cloud/jira/pla | Property | Description | Type | | --------------- | ----------------------------------------------------------------------------------------------------------------------- | ------ | -| subAction | The sub action to perform. It can be `commonFields`, `pushToService`, `handshake`, `getIncident`, `issueTypes`, and `fieldsByIssueType` | string | +| subAction | The sub action to perform. It can be `getFields`, `pushToService`, `handshake`, `getIncident`, `issueTypes`, and `fieldsByIssueType` | string | | subActionParams | The parameters of the sub action | object | #### `subActionParams (pushToService)` @@ -634,9 +634,9 @@ The Jira action uses the [V2 API](https://developer.atlassian.com/cloud/jira/pla No parameters for `issueTypes` sub-action. Provide an empty object `{}`. -#### `subActionParams (commonFields)` +#### `subActionParams (getFields)` -No parameters for `commonFields` sub-action. Provide an empty object `{}`. +No parameters for `getFields` sub-action. Provide an empty object `{}`. #### `subActionParams (pushToService)` @@ -666,7 +666,7 @@ ID: `.resilient` | Property | Description | Type | | --------------- | ------------------------------------------------------------------------------------ | ------ | -| subAction | The sub action to perform. It can be `commonFields`, `pushToService`, `handshake`, and `getIncident` | string | +| subAction | The sub action to perform. It can be `getFields`, `pushToService`, `handshake`, and `getIncident` | string | | subActionParams | The parameters of the sub action | object | #### `subActionParams (pushToService)` @@ -681,9 +681,9 @@ ID: `.resilient` | incidentTypes | An array with the ids of IBM Resilient incident types. | number[] _(optional)_ | | severityCode | IBM Resilient id of the severity code. | number _(optional)_ | -#### `subActionParams (commonFields)` +#### `subActionParams (getFields)` -No parameters for `commonFields` sub-action. Provide an empty object `{}`. +No parameters for `getFields` sub-action. Provide an empty object `{}`. # Command Line Utility diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/api.test.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/api.test.ts index aff071eb88f26..5a7617ada1bf0 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/jira/api.test.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/jira/api.test.ts @@ -5,7 +5,7 @@ */ import { Logger } from '../../../../../../src/core/server'; -import { externalServiceMock, mapping, apiParams, jiraCommonFields } from './mocks'; +import { externalServiceMock, mapping, apiParams } from './mocks'; import { ExternalService } from './types'; import { api } from './api'; let mockedLogger: jest.Mocked; @@ -382,16 +382,6 @@ describe('api', () => { }); }); - describe('commonFields', () => { - test('it returns the fields correctly', async () => { - const res = await api.commonFields({ - externalService, - params: {}, - }); - expect(res).toEqual(jiraCommonFields); - }); - }); - describe('getIssues', () => { test('it returns the issues correctly', async () => { const res = await api.issues({ diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/api.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/api.ts index b194dce7cd466..feeb69b1d1a0e 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/jira/api.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/jira/api.ts @@ -40,8 +40,8 @@ const getIssueTypesHandler = async ({ externalService }: GetIssueTypesHandlerArg return res; }; -const getCommonFieldsHandler = async ({ externalService }: GetCommonFieldsHandlerArgs) => { - const res = await externalService.getCommonFields(); +const getFieldsHandler = async ({ externalService }: GetCommonFieldsHandlerArgs) => { + const res = await externalService.getFields(); return res; }; @@ -163,7 +163,7 @@ const pushToServiceHandler = async ({ }; export const api: ExternalServiceApi = { - commonFields: getCommonFieldsHandler, + getFields: getFieldsHandler, handshake: handshakeHandler, pushToService: pushToServiceHandler, getIncident: getIncidentHandler, diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/index.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/index.ts index 6ea8028f1b08f..c70c0810926f4 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/jira/index.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/jira/index.ts @@ -40,7 +40,7 @@ interface GetActionTypeParams { } const supportedSubActions: string[] = [ - 'commonFields', + 'getFields', 'pushToService', 'issueTypes', 'fieldsByIssueType', @@ -146,8 +146,8 @@ async function executor( }); } - if (subAction === 'commonFields') { - data = await api.commonFields({ + if (subAction === 'getFields') { + data = await api.getFields({ externalService, params: subActionParams, }); diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/mocks.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/mocks.ts index 9ab89d9ad243c..660c82dc38b84 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/jira/mocks.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/jira/mocks.ts @@ -73,7 +73,7 @@ const createMock = (): jest.Mocked => { key: 'RJ-107', title: 'Test title', })), - getCommonFields: jest.fn().mockImplementation(() => jiraCommonFields), + getFields: jest.fn().mockImplementation(() => jiraCommonFields), }; service.createComment.mockImplementationOnce(() => @@ -98,74 +98,6 @@ const createMock = (): jest.Mocked => { const externalServiceMock = { create: createMock, }; -const jiraFields = [ - { - id: 'issuetype', - key: 'issuetype', - name: 'Issue Type', - custom: false, - orderable: true, - navigable: true, - searchable: true, - clauseNames: ['issuetype', 'type'], - schema: { type: 'issuetype', system: 'issuetype' }, - }, - { - id: 'parent', - key: 'parent', - name: 'Parent', - custom: false, - orderable: false, - navigable: true, - searchable: false, - clauseNames: ['parent'], - }, - { - id: 'summary', - key: 'summary', - name: 'Summary', - custom: false, - orderable: true, - navigable: true, - searchable: true, - clauseNames: ['summary'], - schema: { type: 'string', system: 'summary' }, - }, - { - id: 'reporter', - key: 'reporter', - name: 'Reporter', - custom: false, - orderable: true, - navigable: true, - searchable: true, - clauseNames: ['reporter'], - schema: { type: 'user', system: 'reporter' }, - }, - { - id: 'priority', - key: 'priority', - name: 'Priority', - custom: false, - orderable: true, - navigable: true, - searchable: true, - clauseNames: ['priority'], - schema: { type: 'priority', system: 'priority' }, - }, - { - id: 'description', - key: 'description', - name: 'Description', - custom: false, - orderable: true, - navigable: true, - searchable: true, - clauseNames: ['description'], - schema: { type: 'string', system: 'description' }, - }, -]; -const jiraCommonFields = jiraFields.filter(({ id }) => id === 'summary' || id === 'description'); const mapping: Map> = new Map(); mapping.set('title', { @@ -226,4 +158,4 @@ const apiParams: PushToServiceApiParams = { externalObject: { summary: 'Incident title', description: 'Incident description' }, }; -export { jiraCommonFields, jiraFields, externalServiceMock, mapping, executorParams, apiParams }; +export { externalServiceMock, mapping, executorParams, apiParams }; diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/schema.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/schema.ts index a95387f390d08..70b60ada9c386 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/jira/schema.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/jira/schema.ts @@ -67,7 +67,7 @@ export const ExecutorSubActionGetIssueParamsSchema = schema.object({ id: schema. export const ExecutorParamsSchema = schema.oneOf([ schema.object({ - subAction: schema.literal('commonFields'), + subAction: schema.literal('getFields'), subActionParams: ExecutorSubActionCommonFieldsParamsSchema, }), schema.object({ diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/service.test.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/service.test.ts index 4035bf1df30c5..2165ba56428c9 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/jira/service.test.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/jira/service.test.ts @@ -11,7 +11,6 @@ import * as utils from '../lib/axios_utils'; import { ExternalService } from './types'; import { Logger } from '../../../../../../src/core/server'; import { loggingSystemMock } from '../../../../../../src/core/server/mocks'; -import { jiraCommonFields, jiraFields } from './mocks'; const logger = loggingSystemMock.create().get() as jest.Mocked; interface ResponseError extends Error { @@ -58,8 +57,10 @@ const fieldsResponse = { id: '10006', name: 'Task', fields: { - summary: { fieldId: 'summary' }, + summary: { required: true, schema: { type: 'string' }, fieldId: 'summary' }, priority: { + required: false, + schema: { type: 'string' }, fieldId: 'priority', allowedValues: [ { @@ -766,6 +767,8 @@ describe('Jira service', () => { expect(res).toEqual({ priority: { + required: false, + schema: { type: 'string' }, allowedValues: [ { id: '1', name: 'Highest' }, { id: '2', name: 'High' }, @@ -775,7 +778,12 @@ describe('Jira service', () => { ], defaultValue: { id: '3', name: 'Medium' }, }, - summary: { allowedValues: [], defaultValue: {} }, + summary: { + required: true, + schema: { type: 'string' }, + allowedValues: [], + defaultValue: {}, + }, }); }); @@ -838,8 +846,10 @@ describe('Jira service', () => { requestMock.mockImplementationOnce(() => ({ data: { values: [ - { fieldId: 'summary' }, + { required: true, schema: { type: 'string' }, fieldId: 'summary' }, { + required: false, + schema: { type: 'string' }, fieldId: 'priority', allowedValues: [ { @@ -860,10 +870,17 @@ describe('Jira service', () => { expect(res).toEqual({ priority: { + required: false, + schema: { type: 'string' }, allowedValues: [{ id: '3', name: 'Medium' }], defaultValue: { id: '3', name: 'Medium' }, }, - summary: { allowedValues: [], defaultValue: {} }, + summary: { + required: true, + schema: { type: 'string' }, + allowedValues: [], + defaultValue: {}, + }, }); }); @@ -882,8 +899,10 @@ describe('Jira service', () => { requestMock.mockImplementationOnce(() => ({ data: { values: [ - { fieldId: 'summary' }, + { required: true, schema: { type: 'string' }, fieldId: 'summary' }, { + required: true, + schema: { type: 'string' }, fieldId: 'priority', allowedValues: [ { @@ -1027,10 +1046,9 @@ describe('Jira service', () => { }); }); - describe('getCommonFields', () => { + describe('getFields', () => { const callMocks = () => { requestMock - .mockImplementationOnce(() => ({ data: jiraFields })) .mockImplementationOnce(() => ({ data: { capabilities: { @@ -1069,9 +1087,11 @@ describe('Jira service', () => { .mockImplementationOnce(() => ({ data: { values: [ - { fieldId: 'summary' }, - { fieldId: 'description' }, + { required: true, schema: { type: 'string' }, fieldId: 'summary' }, + { required: true, schema: { type: 'string' }, fieldId: 'description' }, { + required: false, + schema: { type: 'string' }, fieldId: 'priority', allowedValues: [ { @@ -1089,7 +1109,10 @@ describe('Jira service', () => { })) .mockImplementationOnce(() => ({ data: { - values: [{ fieldId: 'summary' }, { fieldId: 'description' }], + values: [ + { required: true, schema: { type: 'string' }, fieldId: 'summary' }, + { required: true, schema: { type: 'string' }, fieldId: 'description' }, + ], }, })); }; @@ -1098,9 +1121,8 @@ describe('Jira service', () => { }); test('it should call request with correct arguments', async () => { callMocks(); - await service.getCommonFields(); + await service.getFields(); const callUrls = [ - 'https://siem-kibana.atlassian.net/rest/api/2/field', 'https://siem-kibana.atlassian.net/rest/capabilities', 'https://siem-kibana.atlassian.net/rest/api/2/issue/createmeta/CK/issuetypes', 'https://siem-kibana.atlassian.net/rest/capabilities', @@ -1114,8 +1136,21 @@ describe('Jira service', () => { }); test('it returns common fields correctly', async () => { callMocks(); - const res = await service.getCommonFields(); - expect(res).toEqual(jiraCommonFields); + const res = await service.getFields(); + expect(res).toEqual({ + description: { + allowedValues: [], + defaultValue: {}, + required: true, + schema: { type: 'string' }, + }, + summary: { + allowedValues: [], + defaultValue: {}, + required: true, + schema: { type: 'string' }, + }, + }); }); test('it should throw an error', async () => { @@ -1124,8 +1159,8 @@ describe('Jira service', () => { error.response = { data: { errors: { summary: 'Required field' } } }; throw error; }); - await expect(service.getCommonFields()).rejects.toThrow( - '[Action][Jira]: Unable to get fields. Error: An error has occurred Reason: Required field' + await expect(service.getFields()).rejects.toThrow( + '[Action][Jira]: Unable to get capabilities. Error: An error has occurred. Reason: Required field' ); }); }); diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/service.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/service.ts index 08b0b356b5976..5f583d31a70e7 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/jira/service.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/jira/service.ts @@ -21,6 +21,9 @@ import { ExternalServiceCommentResponse, ExternalServiceIncidentResponse, ExternalServiceFields, + FieldSchema, + GetFieldsByIssueTypeResponse, + GetCommonFieldsResponse, } from './types'; import * as i18n from './translations'; @@ -47,7 +50,6 @@ export const createExternalService = ( throw Error(`[Action]${i18n.NAME}: Wrong configuration.`); } - const fieldsUrl = `${url}/${BASE_URL}/field`; const incidentUrl = `${url}/${BASE_URL}/issue`; const capabilitiesUrl = `${url}/${CAPABILITIES_URL}`; const commentUrl = `${incidentUrl}/{issueId}/comment`; @@ -129,14 +131,21 @@ export const createExternalService = ( issueTypes.map((type) => ({ id: type.id, name: type.name })); const normalizeFields = (fields: { - [key: string]: { allowedValues?: Array<{}>; defaultValue?: {} }; + [key: string]: { + allowedValues?: Array<{}>; + defaultValue?: {}; + required: boolean; + schema: FieldSchema; + }; }) => Object.keys(fields ?? {}).reduce((fieldsAcc, fieldKey) => { return { ...fieldsAcc, [fieldKey]: { + required: fields[fieldKey]?.required, allowedValues: fields[fieldKey]?.allowedValues ?? [], defaultValue: fields[fieldKey]?.defaultValue ?? {}, + schema: fields[fieldKey]?.schema, }, }; }, {}); @@ -152,28 +161,6 @@ export const createExternalService = ( title: issue.fields?.summary ?? null, }); - const getFields = async (): Promise => { - try { - const res = await request({ - axios: axiosInstance, - url: fieldsUrl, - logger, - proxySettings, - }); - - return res.data; - } catch (error) { - throw new Error( - getErrorMessage( - i18n.NAME, - `Unable to get fields. Error: ${error.message} Reason: ${createErrorMessage( - error.response?.data - )}` - ) - ); - } - }; - const getIncident = async (id: string) => { try { const res = await request({ @@ -400,6 +387,7 @@ export const createExternalService = ( }); const fields = res.data.projects[0]?.issuetypes[0]?.fields || {}; + return normalizeFields(fields); } else { const res = await request({ @@ -431,19 +419,24 @@ export const createExternalService = ( } }; - const getCommonFields = async () => { + const getFields = async () => { try { - const [fields, issueTypes] = await Promise.all([getFields(), getIssueTypes()]); - const fieldTypes = await Promise.all( + const issueTypes = await getIssueTypes(); + const fieldsPerIssueType = await Promise.all( issueTypes.map((issueType) => getFieldsByIssueType(issueType.id)) ); - const commonFields = fieldTypes.reduce((acc: string[], fieldTypesByIssue) => { - const newKeys = Object.keys(fieldTypesByIssue); - return acc.length === 0 - ? [...newKeys] - : acc.reduce((add: string[], key) => (newKeys.includes(key) ? [...add, key] : add), []); - }, []); - return fields.filter((f) => commonFields.includes(f.id)); + return fieldsPerIssueType.reduce((acc: GetCommonFieldsResponse, fieldTypesByIssue) => { + const currentListOfFields = Object.keys(acc); + return currentListOfFields.length === 0 + ? fieldTypesByIssue + : currentListOfFields.reduce( + (add: GetCommonFieldsResponse, field) => + Object.keys(fieldTypesByIssue).includes(field) + ? { ...add, [field]: acc[field] } + : add, + {} + ); + }, {}); } catch (error) { // errors that happen here would be thrown in the contained async calls throw error; @@ -502,7 +495,7 @@ export const createExternalService = ( }; return { - getCommonFields, + getFields, getIncident, createIncident, updateIncident, diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/types.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/types.ts index 685f1f5352049..e142637010a98 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/jira/types.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/jira/types.ts @@ -95,13 +95,18 @@ export interface ExternalServiceFields { schema: FieldsSchema; searchable: boolean; } -export type GetCommonFieldsResponse = ExternalServiceFields[]; export type GetIssueTypesResponse = Array<{ id: string; name: string }>; + +export interface FieldSchema { + type: string; + items?: string; +} export type GetFieldsByIssueTypeResponse = Record< string, - { allowedValues: Array<{}>; defaultValue: {} } + { allowedValues: Array<{}>; defaultValue: {}; required: boolean; schema: FieldSchema } >; +export type GetCommonFieldsResponse = GetFieldsByIssueTypeResponse; export type GetIssuesResponse = Array<{ id: string; key: string; title: string }>; export interface GetIssueResponse { @@ -113,7 +118,7 @@ export interface GetIssueResponse { export interface ExternalService { createComment: (params: CreateCommentParams) => Promise; createIncident: (params: CreateIncidentParams) => Promise; - getCommonFields: () => Promise; + getFields: () => Promise; getCapabilities: () => Promise; getFieldsByIssueType: (issueTypeId: string) => Promise; getIncident: (id: string) => Promise; @@ -201,7 +206,7 @@ export interface GetIssueHandlerArgs { } export interface ExternalServiceApi { - commonFields: (args: GetCommonFieldsHandlerArgs) => Promise; + getFields: (args: GetCommonFieldsHandlerArgs) => Promise; getIncident: (args: GetIncidentApiHandlerArgs) => Promise; handshake: (args: HandshakeApiHandlerArgs) => Promise; issueTypes: (args: GetIssueTypesHandlerArgs) => Promise; diff --git a/x-pack/plugins/actions/server/builtin_action_types/resilient/api.ts b/x-pack/plugins/actions/server/builtin_action_types/resilient/api.ts index 1dd936962d1f5..29f2594d2b6f8 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/resilient/api.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/resilient/api.ts @@ -33,8 +33,8 @@ const getIncidentHandler = async ({ params, }: GetIncidentApiHandlerArgs) => {}; -const getCommonFieldsHandler = async ({ externalService }: GetCommonFieldsHandlerArgs) => { - const res = await externalService.getCommonFields(); +const getFieldsHandler = async ({ externalService }: GetCommonFieldsHandlerArgs) => { + const res = await externalService.getFields(); return res; }; const getIncidentTypesHandler = async ({ externalService }: GetIncidentTypesHandlerArgs) => { @@ -141,7 +141,7 @@ const pushToServiceHandler = async ({ }; export const api: ExternalServiceApi = { - commonFields: getCommonFieldsHandler, + getFields: getFieldsHandler, getIncident: getIncidentHandler, handshake: handshakeHandler, incidentTypes: getIncidentTypesHandler, diff --git a/x-pack/plugins/actions/server/builtin_action_types/resilient/index.ts b/x-pack/plugins/actions/server/builtin_action_types/resilient/index.ts index 13e0cf4fe2205..6203dda4120f5 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/resilient/index.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/resilient/index.ts @@ -38,12 +38,7 @@ interface GetActionTypeParams { configurationUtilities: ActionsConfigurationUtilities; } -const supportedSubActions: string[] = [ - 'commonFields', - 'pushToService', - 'incidentTypes', - 'severity', -]; +const supportedSubActions: string[] = ['getFields', 'pushToService', 'incidentTypes', 'severity']; // action type definition export function getActionType( @@ -128,11 +123,11 @@ async function executor( logger.debug(`response push to service for incident id: ${data.id}`); } - if (subAction === 'commonFields') { - const commonFieldsParams = subActionParams as ExecutorSubActionCommonFieldsParams; - data = await api.commonFields({ + if (subAction === 'getFields') { + const getFieldsParams = subActionParams as ExecutorSubActionCommonFieldsParams; + data = await api.getFields({ externalService, - params: commonFieldsParams, + params: getFieldsParams, }); } diff --git a/x-pack/plugins/actions/server/builtin_action_types/resilient/mocks.ts b/x-pack/plugins/actions/server/builtin_action_types/resilient/mocks.ts index 51f58077044c8..2b2a22a66b709 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/resilient/mocks.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/resilient/mocks.ts @@ -276,7 +276,7 @@ export const resilientFields = [ const createMock = (): jest.Mocked => { const service = { - getCommonFields: jest.fn().mockImplementation(() => Promise.resolve(resilientFields)), + getFields: jest.fn().mockImplementation(() => Promise.resolve(resilientFields)), getIncident: jest.fn().mockImplementation(() => Promise.resolve({ id: '1', diff --git a/x-pack/plugins/actions/server/builtin_action_types/resilient/schema.ts b/x-pack/plugins/actions/server/builtin_action_types/resilient/schema.ts index aadd59e60e471..c7ceba94140fb 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/resilient/schema.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/resilient/schema.ts @@ -60,7 +60,7 @@ export const ExecutorSubActionGetSeverityParamsSchema = schema.object({}); export const ExecutorParamsSchema = schema.oneOf([ schema.object({ - subAction: schema.literal('commonFields'), + subAction: schema.literal('getFields'), subActionParams: ExecutorSubActionCommonFieldsParamsSchema, }), schema.object({ diff --git a/x-pack/plugins/actions/server/builtin_action_types/resilient/service.test.ts b/x-pack/plugins/actions/server/builtin_action_types/resilient/service.test.ts index 19c67e4695b5a..ecf246cb8fe3c 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/resilient/service.test.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/resilient/service.test.ts @@ -584,12 +584,12 @@ describe('IBM Resilient service', () => { }); }); - describe('getCommonFields', () => { + describe('getFields', () => { test('it should call request with correct arguments', async () => { requestMock.mockImplementation(() => ({ data: resilientFields, })); - await service.getCommonFields(); + await service.getFields(); expect(requestMock).toHaveBeenCalledWith({ axios, @@ -601,7 +601,7 @@ describe('IBM Resilient service', () => { requestMock.mockImplementation(() => ({ data: resilientFields, })); - const res = await service.getCommonFields(); + const res = await service.getFields(); expect(res).toEqual(resilientFields); }); @@ -609,7 +609,7 @@ describe('IBM Resilient service', () => { requestMock.mockImplementation(() => { throw new Error('An error has occurred'); }); - await expect(service.getCommonFields()).rejects.toThrow( + await expect(service.getFields()).rejects.toThrow( 'Unable to get fields. Error: An error has occurred' ); }); diff --git a/x-pack/plugins/actions/server/builtin_action_types/resilient/service.ts b/x-pack/plugins/actions/server/builtin_action_types/resilient/service.ts index be4ebf9cb662e..a13204f8bb1d8 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/resilient/service.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/resilient/service.ts @@ -303,7 +303,7 @@ export const createExternalService = ( } }; - const getCommonFields = async () => { + const getFields = async () => { try { const res = await request({ axios: axiosInstance, @@ -320,7 +320,7 @@ export const createExternalService = ( return { createComment, createIncident, - getCommonFields, + getFields, getIncident, getIncidentTypes, getSeverity, diff --git a/x-pack/plugins/actions/server/builtin_action_types/resilient/types.ts b/x-pack/plugins/actions/server/builtin_action_types/resilient/types.ts index 28269828fbae4..a70420b30a092 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/resilient/types.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/resilient/types.ts @@ -101,7 +101,7 @@ export type GetSeverityResponse = Array<{ id: string; name: string }>; export interface ExternalService { createComment: (params: CreateCommentParams) => Promise; createIncident: (params: CreateIncidentParams) => Promise; - getCommonFields: () => Promise; + getFields: () => Promise; getIncident: (id: string) => Promise; getIncidentTypes: () => Promise; getSeverity: () => Promise; @@ -166,7 +166,7 @@ export interface PushToServiceResponse extends ExternalServiceIncidentResponse { } export interface ExternalServiceApi { - commonFields: (args: GetCommonFieldsHandlerArgs) => Promise; + getFields: (args: GetCommonFieldsHandlerArgs) => Promise; handshake: (args: HandshakeApiHandlerArgs) => Promise; pushToService: (args: PushToServiceApiHandlerArgs) => Promise; getIncident: (args: GetIncidentApiHandlerArgs) => Promise; diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.test.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.test.ts index cef837de74229..4683b661e21da 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.test.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.test.ts @@ -621,9 +621,9 @@ describe('api', () => { }); }); - describe('commonFields', () => { + describe('getFields', () => { test('it returns the fields correctly', async () => { - const res = await api.commonFields({ + const res = await api.getFields({ externalService, params: {}, }); diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.ts index 3b58546668284..fbd8fdd635d70 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.ts @@ -129,15 +129,15 @@ const pushToServiceHandler = async ({ return res; }; -const getCommonFieldsHandler = async ({ +const getFieldsHandler = async ({ externalService, }: GetCommonFieldsHandlerArgs): Promise => { - const res = await externalService.getCommonFields(); + const res = await externalService.getFields(); return res; }; export const api: ExternalServiceApi = { - commonFields: getCommonFieldsHandler, + getFields: getFieldsHandler, getIncident: getIncidentHandler, handshake: handshakeHandler, pushToService: pushToServiceHandler, diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.ts index f0b34821ad720..d1182b0d3b2fa 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.ts @@ -65,7 +65,7 @@ export function getActionType( } // action executor -const supportedSubActions: string[] = ['commonFields', 'pushToService']; +const supportedSubActions: string[] = ['getFields', 'pushToService']; async function executor( { logger }: { logger: Logger }, execOptions: ActionTypeExecutorOptions< @@ -119,11 +119,11 @@ async function executor( logger.debug(`response push to service for incident id: ${data.id}`); } - if (subAction === 'commonFields') { - const commonFieldsParams = subActionParams as ExecutorSubActionCommonFieldsParams; - data = await api.commonFields({ + if (subAction === 'getFields') { + const getFieldsParams = subActionParams as ExecutorSubActionCommonFieldsParams; + data = await api.getFields({ externalService, - params: commonFieldsParams, + params: getFieldsParams, }); } diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/mocks.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/mocks.ts index f82028fa47e98..2351be36a50c4 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/mocks.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/mocks.ts @@ -36,7 +36,7 @@ export const serviceNowCommonFields = [ ]; const createMock = (): jest.Mocked => { const service = { - getCommonFields: jest.fn().mockImplementation(() => Promise.resolve(serviceNowCommonFields)), + getFields: jest.fn().mockImplementation(() => Promise.resolve(serviceNowCommonFields)), getIncident: jest.fn().mockImplementation(() => Promise.resolve({ short_description: 'title from servicenow', diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/schema.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/schema.ts index f6b89b793b990..77c48aab1f309 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/schema.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/schema.ts @@ -28,7 +28,7 @@ export const ExternalIncidentServiceSecretConfigurationSchema = schema.object( ); export const ExecutorSubActionSchema = schema.oneOf([ - schema.literal('commonFields'), + schema.literal('getFields'), schema.literal('getIncident'), schema.literal('pushToService'), schema.literal('handshake'), @@ -58,7 +58,7 @@ export const ExecutorSubActionCommonFieldsParamsSchema = schema.object({}); export const ExecutorParamsSchema = schema.oneOf([ schema.object({ - subAction: schema.literal('commonFields'), + subAction: schema.literal('getFields'), subActionParams: ExecutorSubActionCommonFieldsParamsSchema, }), schema.object({ diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.test.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.test.ts index d21c51246fe8c..8ec80be1e2b09 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.test.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.test.ts @@ -236,12 +236,12 @@ describe('ServiceNow service', () => { }); }); - describe('getCommonFields', () => { + describe('getFields', () => { test('it should call request with correct arguments', async () => { requestMock.mockImplementation(() => ({ data: { result: serviceNowCommonFields }, })); - await service.getCommonFields(); + await service.getFields(); expect(requestMock).toHaveBeenCalledWith({ axios, @@ -254,7 +254,7 @@ describe('ServiceNow service', () => { requestMock.mockImplementation(() => ({ data: { result: serviceNowCommonFields }, })); - const res = await service.getCommonFields(); + const res = await service.getFields(); expect(res).toEqual(serviceNowCommonFields); }); @@ -262,7 +262,7 @@ describe('ServiceNow service', () => { requestMock.mockImplementation(() => { throw new Error('An error has occurred'); }); - await expect(service.getCommonFields()).rejects.toThrow( + await expect(service.getFields()).rejects.toThrow( 'Unable to get common fields. Error: An error has occurred' ); }); diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.ts index 5855f906c839e..57f7176e2353c 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.ts @@ -128,7 +128,7 @@ export const createExternalService = ( } }; - const getCommonFields = async () => { + const getFields = async () => { try { const res = await request({ axios: axiosInstance, @@ -148,7 +148,7 @@ export const createExternalService = ( return { createIncident, findIncidents, - getCommonFields, + getFields, getIncident, updateIncident, }; diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/types.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/types.ts index 76026358d530b..0ee03f883ec05 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/types.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/types.ts @@ -66,7 +66,7 @@ export interface PushToServiceResponse extends ExternalServiceIncidentResponse { export type ExternalServiceParams = Record; export interface ExternalService { - getCommonFields: () => Promise; + getFields: () => Promise; getIncident: (id: string) => Promise; createIncident: (params: ExternalServiceParams) => Promise; updateIncident: (params: ExternalServiceParams) => Promise; @@ -127,7 +127,7 @@ export interface GetCommonFieldsHandlerArgs { } export interface ExternalServiceApi { - commonFields: (args: GetCommonFieldsHandlerArgs) => Promise; + getFields: (args: GetCommonFieldsHandlerArgs) => Promise; handshake: (args: HandshakeApiHandlerArgs) => Promise; pushToService: (args: PushToServiceApiHandlerArgs) => Promise; getIncident: (args: GetIncidentApiHandlerArgs) => Promise; diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/jira.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/jira.ts index 9de0f53bd7265..4e9293b74c99e 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/jira.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/jira.ts @@ -333,7 +333,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subAction]: expected value to equal [pushToService]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subAction]: expected value to equal [pushToService]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]', }); }); }); @@ -351,7 +351,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]', }); }); }); @@ -374,7 +374,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]', }); }); }); @@ -402,7 +402,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments]: types that failed validation:\n - [subActionParams.comments.0.0.commentId]: expected value of type [string] but got [undefined]\n - [subActionParams.comments.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments]: types that failed validation:\n - [subActionParams.comments.0.0.commentId]: expected value of type [string] but got [undefined]\n - [subActionParams.comments.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]', }); }); }); @@ -430,7 +430,7 @@ export default function jiraTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments]: types that failed validation:\n - [subActionParams.comments.0.0.comment]: expected value of type [string] but got [undefined]\n - [subActionParams.comments.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments]: types that failed validation:\n - [subActionParams.comments.0.0.comment]: expected value of type [string] but got [undefined]\n - [subActionParams.comments.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]', }); }); }); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/resilient.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/resilient.ts index 7e862c2499173..34c1c757ab119 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/resilient.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/resilient.ts @@ -334,7 +334,7 @@ export default function resilientTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subAction]: expected value to equal [pushToService]\n- [4.subAction]: expected value to equal [incidentTypes]\n- [5.subAction]: expected value to equal [severity]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subAction]: expected value to equal [pushToService]\n- [4.subAction]: expected value to equal [incidentTypes]\n- [5.subAction]: expected value to equal [severity]', }); }); }); @@ -352,7 +352,7 @@ export default function resilientTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]\n- [4.subAction]: expected value to equal [incidentTypes]\n- [5.subAction]: expected value to equal [severity]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]\n- [4.subAction]: expected value to equal [incidentTypes]\n- [5.subAction]: expected value to equal [severity]', }); }); }); @@ -375,7 +375,7 @@ export default function resilientTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]\n- [4.subAction]: expected value to equal [incidentTypes]\n- [5.subAction]: expected value to equal [severity]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]\n- [4.subAction]: expected value to equal [incidentTypes]\n- [5.subAction]: expected value to equal [severity]', }); }); }); @@ -403,7 +403,7 @@ export default function resilientTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments]: types that failed validation:\n - [subActionParams.comments.0.0.commentId]: expected value of type [string] but got [undefined]\n - [subActionParams.comments.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [incidentTypes]\n- [5.subAction]: expected value to equal [severity]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments]: types that failed validation:\n - [subActionParams.comments.0.0.commentId]: expected value of type [string] but got [undefined]\n - [subActionParams.comments.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [incidentTypes]\n- [5.subAction]: expected value to equal [severity]', }); }); }); @@ -431,7 +431,7 @@ export default function resilientTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments]: types that failed validation:\n - [subActionParams.comments.0.0.comment]: expected value of type [string] but got [undefined]\n - [subActionParams.comments.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [incidentTypes]\n- [5.subAction]: expected value to equal [severity]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments]: types that failed validation:\n - [subActionParams.comments.0.0.comment]: expected value of type [string] but got [undefined]\n - [subActionParams.comments.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [incidentTypes]\n- [5.subAction]: expected value to equal [severity]', }); }); }); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/servicenow.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/servicenow.ts index 1347b4d078b0a..5b4db53a59a41 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/servicenow.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/servicenow.ts @@ -328,7 +328,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subAction]: expected value to equal [pushToService]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subAction]: expected value to equal [pushToService]', }); }); }); @@ -346,7 +346,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]', }); }); }); @@ -369,7 +369,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.title]: expected value of type [string] but got [undefined]', }); }); }); @@ -397,7 +397,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments.0.commentId]: expected value of type [string] but got [undefined]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments.0.commentId]: expected value of type [string] but got [undefined]', }); }); }); @@ -425,7 +425,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) { status: 'error', retry: false, message: - 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [commonFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments.0.comment]: expected value of type [string] but got [undefined]', + 'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.comments.0.comment]: expected value of type [string] but got [undefined]', }); }); });