From e93a5a6dcd59807e88d74bd55f1aa0ec10ff39a5 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Wed, 27 Apr 2022 12:13:25 +0300 Subject: [PATCH] [Cases] Revert preconfigured connectors support for Cases (#130372) * Fix bug with deprecated connectors * Add integration test * Improve integration tests * Fix grammar * Fix CI Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 12fdfd63adfd196528b1a61b1f3a07d2d484bcc0) # Conflicts: # x-pack/plugins/cases/server/client/configure/client.test.ts --- .../servicenow_itsm_case_fields.test.tsx | 19 +++ .../servicenow_sir_case_fields.test.tsx | 19 +++ .../connectors/servicenow/validator.test.ts | 13 +- .../connectors/servicenow/validator.ts | 16 +- .../cases/public/components/utils.test.ts | 11 ++ .../plugins/cases/public/components/utils.ts | 8 +- .../server/client/configure/client.test.ts | 150 ++++++++++++++---- .../cases/server/client/configure/client.ts | 4 +- .../cases_api_integration/common/config.ts | 14 +- .../cases_api_integration/common/lib/utils.ts | 13 ++ .../tests/basic/configure/create_connector.ts | 20 --- .../configure/get_connectors.ts | 15 +- .../security_and_spaces/tests/basic/index.ts | 1 + .../security_and_spaces/tests/common/index.ts | 1 - .../tests/trial/configure/get_connectors.ts | 58 +++---- .../tests/trial/configure/get_connectors.ts | 60 ++++--- 16 files changed, 287 insertions(+), 135 deletions(-) delete mode 100644 x-pack/test/cases_api_integration/security_and_spaces/tests/basic/configure/create_connector.ts rename x-pack/test/cases_api_integration/security_and_spaces/tests/{common => basic}/configure/get_connectors.ts (64%) diff --git a/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_itsm_case_fields.test.tsx b/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_itsm_case_fields.test.tsx index 66ff8c751c461..cfc16f1fb6e8b 100644 --- a/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_itsm_case_fields.test.tsx +++ b/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_itsm_case_fields.test.tsx @@ -146,6 +146,25 @@ describe('ServiceNowITSM Fields', () => { expect(screen.queryByTestId('deprecated-connector-warning-callout')).not.toBeInTheDocument(); }); + it('does not show the deprecated callout when the connector is preconfigured', async () => { + render( + + ); + expect(screen.queryByTestId('deprecated-connector-warning-callout')).not.toBeInTheDocument(); + }); + + it('does not show the deprecated callout when the config of the connector is undefined', async () => { + render( + // @ts-expect-error + + ); + expect(screen.queryByTestId('deprecated-connector-warning-callout')).not.toBeInTheDocument(); + }); + it('should hide subcategory if selecting a category without subcategories', async () => { // Failed Login doesn't have defined subcategories const customFields = { diff --git a/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_sir_case_fields.test.tsx b/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_sir_case_fields.test.tsx index 279cab7e6f879..a2c61ac78be0b 100644 --- a/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_sir_case_fields.test.tsx +++ b/x-pack/plugins/cases/public/components/connectors/servicenow/servicenow_sir_case_fields.test.tsx @@ -180,6 +180,25 @@ describe('ServiceNowSIR Fields', () => { expect(screen.queryByTestId('deprecated-connector-warning-callout')).not.toBeInTheDocument(); }); + it('does not show the deprecated callout when the connector is preconfigured', async () => { + render( + + ); + expect(screen.queryByTestId('deprecated-connector-warning-callout')).not.toBeInTheDocument(); + }); + + it('does not show the deprecated callout when the config of the connector is undefined', async () => { + render( + // @ts-expect-error + + ); + expect(screen.queryByTestId('deprecated-connector-warning-callout')).not.toBeInTheDocument(); + }); + test('it should hide subcategory if selecting a category without subcategories', async () => { // Failed Login doesn't have defined subcategories const customFields = { diff --git a/x-pack/plugins/cases/public/components/connectors/servicenow/validator.test.ts b/x-pack/plugins/cases/public/components/connectors/servicenow/validator.test.ts index aa643191ac62e..ab21a6b5c779c 100644 --- a/x-pack/plugins/cases/public/components/connectors/servicenow/validator.test.ts +++ b/x-pack/plugins/cases/public/components/connectors/servicenow/validator.test.ts @@ -22,7 +22,7 @@ describe('ServiceNow validator', () => { expect(connectorValidator(invalidConnector)).toEqual({ message: 'Deprecated connector' }); }); - test('it does not returns an error message if the connector does not uses the table API', () => { + test('it does not return an error message if the connector does not uses the table API', () => { const invalidConnector = { ...connector, config: { @@ -33,5 +33,16 @@ describe('ServiceNow validator', () => { expect(connectorValidator(invalidConnector)).toBeFalsy(); }); + + test('it does not return an error message if the config of the connector is undefined', () => { + const { config, ...invalidConnector } = connector; + + // @ts-expect-error + expect(connectorValidator(invalidConnector)).toBeFalsy(); + }); + + test('it does not return an error message if the config of the connector is preconfigured', () => { + expect(connectorValidator({ ...connector, isPreconfigured: true })).toBeFalsy(); + }); }); }); diff --git a/x-pack/plugins/cases/public/components/connectors/servicenow/validator.ts b/x-pack/plugins/cases/public/components/connectors/servicenow/validator.ts index 7d56163c48350..fed2900715527 100644 --- a/x-pack/plugins/cases/public/components/connectors/servicenow/validator.ts +++ b/x-pack/plugins/cases/public/components/connectors/servicenow/validator.ts @@ -15,10 +15,18 @@ import { CaseActionConnector } from '../../types'; export const connectorValidator = ( connector: CaseActionConnector ): ReturnType => { - const { - config: { usesTableApi }, - } = connector; - if (usesTableApi) { + /** + * It is not possible to know if a preconfigured connector + * is deprecated or not as the config property of a + * preconfigured connector is not returned by the + * actions framework + */ + + if (connector.isPreconfigured || connector.config == null) { + return; + } + + if (connector.config?.usesTableApi) { return { message: 'Deprecated connector', }; diff --git a/x-pack/plugins/cases/public/components/utils.test.ts b/x-pack/plugins/cases/public/components/utils.test.ts index e3cc753e75746..ed8d37cf5120a 100644 --- a/x-pack/plugins/cases/public/components/utils.test.ts +++ b/x-pack/plugins/cases/public/components/utils.test.ts @@ -83,5 +83,16 @@ describe('Utils', () => { }) ).toBe(true); }); + + it('returns false if the connector preconfigured', () => { + expect(isDeprecatedConnector({ ...connector, isPreconfigured: true })).toBe(false); + }); + + it('returns false if the config is undefined', () => { + expect( + // @ts-expect-error + isDeprecatedConnector({ ...connector, config: undefined }) + ).toBe(false); + }); }); }); diff --git a/x-pack/plugins/cases/public/components/utils.ts b/x-pack/plugins/cases/public/components/utils.ts index 5ff675a31ce61..34ebffb4eacb4 100644 --- a/x-pack/plugins/cases/public/components/utils.ts +++ b/x-pack/plugins/cases/public/components/utils.ts @@ -74,7 +74,13 @@ export const getConnectorIcon = ( // TODO: Remove when the applications are certified export const isDeprecatedConnector = (connector?: CaseActionConnector): boolean => { - if (connector == null) { + /** + * It is not possible to know if a preconfigured connector + * is deprecated or not as the config property of a + * preconfigured connector is not returned by the + * actions framework + */ + if (connector == null || connector.config == null || connector.isPreconfigured) { return false; } diff --git a/x-pack/plugins/cases/server/client/configure/client.test.ts b/x-pack/plugins/cases/server/client/configure/client.test.ts index 971748bd8295a..8790695bbd416 100644 --- a/x-pack/plugins/cases/server/client/configure/client.test.ts +++ b/x-pack/plugins/cases/server/client/configure/client.test.ts @@ -9,7 +9,6 @@ import { CasesClientArgs } from '../types'; import { loggingSystemMock } from '../../../../../../src/core/server/mocks'; import { getConnectors } from './client'; import { actionsClientMock } from '../../../../actions/server/mocks'; -import { ActionType } from '../../../../actions/common/types'; describe('client', () => { describe('getConnectors', () => { @@ -18,66 +17,153 @@ describe('client', () => { const args = { actionsClient, logger } as unknown as CasesClientArgs; - const jiraType: ActionType = { - id: '.jira', - name: '1', - enabled: true, - enabledInConfig: true, - enabledInLicense: true, - minimumLicenseRequired: 'basic', - }; + const actionTypes = [ + { + id: '.jira', + name: '1', + enabled: true, + enabledInConfig: true, + enabledInLicense: true, + minimumLicenseRequired: 'basic' as const, + }, + { + id: '.servicenow', + name: '2', + enabled: true, + enabledInConfig: true, + enabledInLicense: true, + minimumLicenseRequired: 'basic' as const, + }, + { + id: '.unsupported', + name: '3', + enabled: true, + enabledInConfig: true, + enabledInLicense: true, + minimumLicenseRequired: 'basic' as const, + }, + { + id: '.swimlane', + name: 'swimlane', + enabled: true, + enabledInConfig: true, + enabledInLicense: false, + minimumLicenseRequired: 'basic' as const, + }, + ]; + + const connectors = [ + { + id: '1', + actionTypeId: '.jira', + name: '1', + config: {}, + isPreconfigured: false, + referencedByCount: 1, + }, + { + id: '2', + actionTypeId: '.servicenow', + name: '2', + config: {}, + isPreconfigured: false, + referencedByCount: 1, + }, + { + id: '3', + actionTypeId: '.unsupported', + name: '3', + config: {}, + isPreconfigured: false, + referencedByCount: 1, + }, + ]; beforeEach(() => { jest.clearAllMocks(); }); - it('removes connectors without a config field defined', async () => { - actionsClient.listTypes.mockImplementation(async () => [jiraType]); + it('remove unsupported connectors', async () => { + actionsClient.listTypes.mockImplementation(async () => actionTypes); + actionsClient.getAll.mockImplementation(async () => connectors); - actionsClient.getAll.mockImplementation(async () => [ + expect(await getConnectors(args)).toEqual([ { id: '1', actionTypeId: '.jira', name: '1', + config: {}, + isPreconfigured: false, + referencedByCount: 1, + }, + { + id: '2', + actionTypeId: '.servicenow', + name: '2', + config: {}, isPreconfigured: false, referencedByCount: 1, }, ]); - - expect(await getConnectors(args)).toEqual([]); }); - it('removes connectors that are pre configured', async () => { - actionsClient.listTypes.mockImplementation(async () => [jiraType]); - + it('returns preconfigured connectors', async () => { + actionsClient.listTypes.mockImplementation(async () => actionTypes); actionsClient.getAll.mockImplementation(async () => [ + ...connectors, + { + id: '4', + actionTypeId: '.servicenow', + name: 'sn-preconfigured', + config: {}, + isPreconfigured: true, + referencedByCount: 1, + }, + ]); + + expect(await getConnectors(args)).toEqual([ { id: '1', actionTypeId: '.jira', name: '1', config: {}, + isPreconfigured: false, + referencedByCount: 1, + }, + { + id: '2', + actionTypeId: '.servicenow', + name: '2', + config: {}, + isPreconfigured: false, + referencedByCount: 1, + }, + { + id: '4', + actionTypeId: '.servicenow', + name: 'sn-preconfigured', + config: {}, isPreconfigured: true, referencedByCount: 1, }, ]); - - expect(await getConnectors(args)).toEqual([]); }); - it('includes connectors that have a config and are not pre configured', async () => { - actionsClient.listTypes.mockImplementation(async () => [ - jiraType, + it('filter out connectors that are unsupported by the current license', async () => { + actionsClient.listTypes.mockImplementation(async () => actionTypes); + actionsClient.getAll.mockImplementation(async () => [ + ...connectors, { - id: '.servicenow', - name: '2', - enabled: true, - enabledInConfig: true, - enabledInLicense: true, - minimumLicenseRequired: 'basic', + id: '4', + actionTypeId: '.swimlane', + name: 'swimlane', + config: {}, + isPreconfigured: false, + referencedByCount: 1, }, ]); - const connectors = [ + expect(await getConnectors(args)).toEqual([ { id: '1', actionTypeId: '.jira', @@ -94,11 +180,7 @@ describe('client', () => { isPreconfigured: false, referencedByCount: 1, }, - ]; - - actionsClient.getAll.mockImplementation(async () => connectors); - - expect(await getConnectors(args)).toEqual(connectors); + ]); }); }); }); diff --git a/x-pack/plugins/cases/server/client/configure/client.ts b/x-pack/plugins/cases/server/client/configure/client.ts index 831fe273af92e..bc6c865c36660 100644 --- a/x-pack/plugins/cases/server/client/configure/client.ts +++ b/x-pack/plugins/cases/server/client/configure/client.ts @@ -227,9 +227,7 @@ function isConnectorSupported( ): boolean { return ( SUPPORTED_CONNECTORS.includes(action.actionTypeId) && - actionTypes[action.actionTypeId]?.enabledInLicense && - action.config != null && - !action.isPreconfigured + actionTypes[action.actionTypeId]?.enabledInLicense ); } diff --git a/x-pack/test/cases_api_integration/common/config.ts b/x-pack/test/cases_api_integration/common/config.ts index a59b78d87ebe5..26459e9a427ef 100644 --- a/x-pack/test/cases_api_integration/common/config.ts +++ b/x-pack/test/cases_api_integration/common/config.ts @@ -20,7 +20,6 @@ interface CreateTestConfigOptions { testFiles?: string[]; } -// test.not-enabled is specifically not enabled const enabledActionTypes = [ '.email', '.index', @@ -139,6 +138,19 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions) (pluginDir) => `--plugin-path=${path.resolve(__dirname, 'fixtures', 'plugins', pluginDir)}` ), + `--xpack.actions.preconfigured=${JSON.stringify({ + 'preconfigured-servicenow': { + name: 'preconfigured-servicenow', + actionTypeId: '.servicenow', + config: { + apiUrl: 'https://example.com', + }, + secrets: { + username: 'elastic', + password: 'elastic', + }, + }, + })}`, `--server.xsrf.allowlist=${JSON.stringify(getAllExternalServiceSimulatorPaths())}`, ...(ssl ? [ diff --git a/x-pack/test/cases_api_integration/common/lib/utils.ts b/x-pack/test/cases_api_integration/common/lib/utils.ts index 9c56db80e45fc..68a6e659ec1aa 100644 --- a/x-pack/test/cases_api_integration/common/lib/utils.ts +++ b/x-pack/test/cases_api_integration/common/lib/utils.ts @@ -286,6 +286,19 @@ export const getWebhookConnector = () => ({ }, }); +export const getEmailConnector = () => ({ + name: 'An email action', + connector_type_id: '.email', + config: { + service: '__json', + from: 'bob@example.com', + }, + secrets: { + user: 'bob', + password: 'supersecret', + }, +}); + interface CommonSavedObjectAttributes { id?: string | null; created_at?: string | null; diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/configure/create_connector.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/configure/create_connector.ts deleted file mode 100644 index fe8e311b5e4f6..0000000000000 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/configure/create_connector.ts +++ /dev/null @@ -1,20 +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 { createConnector, getServiceNowConnector } from '../../../../common/lib/utils'; -import { FtrProviderContext } from '../../../../common/ftr_provider_context'; - -// eslint-disable-next-line import/no-default-export -export default function serviceNow({ getService }: FtrProviderContext) { - const supertest = getService('supertest'); - - describe('create service now action', () => { - it('should return 403 when creating a service now action', async () => { - await createConnector({ supertest, req: getServiceNowConnector(), expectedHttpCode: 403 }); - }); - }); -} diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/configure/get_connectors.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/configure/get_connectors.ts similarity index 64% rename from x-pack/test/cases_api_integration/security_and_spaces/tests/common/configure/get_connectors.ts rename to x-pack/test/cases_api_integration/security_and_spaces/tests/basic/configure/get_connectors.ts index 46f712ff84aa3..57854075c20fb 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/configure/get_connectors.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/configure/get_connectors.ts @@ -15,13 +15,18 @@ export default ({ getService }: FtrProviderContext): void => { const supertest = getService('supertest'); describe('get_connectors', () => { - it('should return an empty find body correctly if no connectors are loaded', async () => { + /** + * A ServiceNow preconfigured connector is registered here + * x-pack/test/cases_api_integration/common/config.ts + * + * The license for this test is set to basic. ServiceNow connectors + * needs license >= platinum. The test below ensures + * that connectors without valid license are being filtered correctly + */ + it('should return an empty list of connectors', async () => { const connectors = await getCaseConnectors({ supertest }); - expect(connectors).to.eql([]); - }); - it.skip('filters out connectors that are not enabled in license', async () => { - // TODO: Should find a way to downgrade license to gold and upgrade back to trial + expect(connectors).to.eql([]); }); }); }; diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/index.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/index.ts index ce2f59a115e69..b618cf5b4df68 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/index.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/index.ts @@ -24,6 +24,7 @@ export default ({ loadTestFile, getService }: FtrProviderContext): void => { // Basic loadTestFile(require.resolve('./cases/push_case')); + loadTestFile(require.resolve('./configure/get_connectors')); // Common loadTestFile(require.resolve('../common')); diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/index.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/index.ts index a4733d0c87038..187261c3d0b87 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/index.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/index.ts @@ -31,7 +31,6 @@ export default ({ loadTestFile }: FtrProviderContext): void => { loadTestFile(require.resolve('./cases/tags/get_tags')); loadTestFile(require.resolve('./user_actions/get_all_user_actions')); loadTestFile(require.resolve('./configure/get_configure')); - loadTestFile(require.resolve('./configure/get_connectors')); loadTestFile(require.resolve('./configure/patch_configure')); loadTestFile(require.resolve('./configure/post_configure')); loadTestFile(require.resolve('./metrics/get_case_metrics')); diff --git a/x-pack/test/cases_api_integration/security_and_spaces/tests/trial/configure/get_connectors.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/trial/configure/get_connectors.ts index a4e69ab928325..d1915fa49d99f 100644 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/trial/configure/get_connectors.ts +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/trial/configure/get_connectors.ts @@ -16,6 +16,8 @@ import { getResilientConnector, createConnector, getServiceNowSIRConnector, + getEmailConnector, + getCaseConnectors, } from '../../../../common/lib/utils'; // eslint-disable-next-line import/no-default-export @@ -29,41 +31,10 @@ export default ({ getService }: FtrProviderContext): void => { }); it('should return the correct connectors', async () => { - const { body: snConnector } = await supertest - .post('/api/actions/connector') - .set('kbn-xsrf', 'true') - .send(getServiceNowConnector()) - .expect(200); - - const { body: emailConnector } = await supertest - .post('/api/actions/connector') - .set('kbn-xsrf', 'true') - .send({ - name: 'An email action', - connector_type_id: '.email', - config: { - service: '__json', - from: 'bob@example.com', - }, - secrets: { - user: 'bob', - password: 'supersecret', - }, - }) - .expect(200); - - const { body: jiraConnector } = await supertest - .post('/api/actions/connector') - .set('kbn-xsrf', 'true') - .send(getJiraConnector()) - .expect(200); - - const { body: resilientConnector } = await supertest - .post('/api/actions/connector') - .set('kbn-xsrf', 'true') - .send(getResilientConnector()) - .expect(200); - + const snConnector = await createConnector({ supertest, req: getServiceNowConnector() }); + const emailConnector = await createConnector({ supertest, req: getEmailConnector() }); + const jiraConnector = await createConnector({ supertest, req: getJiraConnector() }); + const resilientConnector = await createConnector({ supertest, req: getResilientConnector() }); const sir = await createConnector({ supertest, req: getServiceNowSIRConnector() }); actionsRemover.add('default', sir.id, 'action', 'actions'); @@ -72,11 +43,7 @@ export default ({ getService }: FtrProviderContext): void => { actionsRemover.add('default', jiraConnector.id, 'action', 'actions'); actionsRemover.add('default', resilientConnector.id, 'action', 'actions'); - const { body: connectors } = await supertest - .get(`${CASE_CONFIGURE_CONNECTORS_URL}/_find`) - .set('kbn-xsrf', 'true') - .send() - .expect(200); + const connectors = await getCaseConnectors({ supertest }); expect(connectors).to.eql([ { @@ -91,6 +58,17 @@ export default ({ getService }: FtrProviderContext): void => { isMissingSecrets: false, referencedByCount: 0, }, + /** + * Preconfigured connectors are being registered here: + * x-pack/test/cases_api_integration/common/config.ts + */ + { + actionTypeId: '.servicenow', + id: 'preconfigured-servicenow', + isPreconfigured: true, + name: 'preconfigured-servicenow', + referencedByCount: 0, + }, { id: resilientConnector.id, actionTypeId: '.resilient', diff --git a/x-pack/test/cases_api_integration/spaces_only/tests/trial/configure/get_connectors.ts b/x-pack/test/cases_api_integration/spaces_only/tests/trial/configure/get_connectors.ts index 02b91c9f0b918..d91e48cff559b 100644 --- a/x-pack/test/cases_api_integration/spaces_only/tests/trial/configure/get_connectors.ts +++ b/x-pack/test/cases_api_integration/spaces_only/tests/trial/configure/get_connectors.ts @@ -18,6 +18,7 @@ import { getAuthWithSuperUser, getCaseConnectors, getActionsSpace, + getEmailConnector, } from '../../../../common/lib/utils'; // eslint-disable-next-line import/no-default-export @@ -38,32 +39,25 @@ export default ({ getService }: FtrProviderContext): void => { req: getServiceNowConnector(), auth: authSpace1, }); + const emailConnector = await createConnector({ supertest, - req: { - name: 'An email action', - connector_type_id: '.email', - config: { - service: '__json', - from: 'bob@example.com', - }, - secrets: { - user: 'bob', - password: 'supersecret', - }, - }, + req: getEmailConnector(), auth: authSpace1, }); + const jiraConnector = await createConnector({ supertest, req: getJiraConnector(), auth: authSpace1, }); + const resilientConnector = await createConnector({ supertest, req: getResilientConnector(), auth: authSpace1, }); + const sir = await createConnector({ supertest, req: getServiceNowSIRConnector(), @@ -91,6 +85,17 @@ export default ({ getService }: FtrProviderContext): void => { isMissingSecrets: false, referencedByCount: 0, }, + /** + * Preconfigured connectors are being registered here: + * x-pack/test/cases_api_integration/common/config.ts + */ + { + actionTypeId: '.servicenow', + id: 'preconfigured-servicenow', + isPreconfigured: true, + name: 'preconfigured-servicenow', + referencedByCount: 0, + }, { id: resilientConnector.id, actionTypeId: '.resilient', @@ -136,32 +141,25 @@ export default ({ getService }: FtrProviderContext): void => { req: getServiceNowConnector(), auth: authSpace1, }); + const emailConnector = await createConnector({ supertest, - req: { - name: 'An email action', - connector_type_id: '.email', - config: { - service: '__json', - from: 'bob@example.com', - }, - secrets: { - user: 'bob', - password: 'supersecret', - }, - }, + req: getEmailConnector(), auth: authSpace1, }); + const jiraConnector = await createConnector({ supertest, req: getJiraConnector(), auth: authSpace1, }); + const resilientConnector = await createConnector({ supertest, req: getResilientConnector(), auth: authSpace1, }); + const sir = await createConnector({ supertest, req: getServiceNowSIRConnector(), @@ -179,7 +177,19 @@ export default ({ getService }: FtrProviderContext): void => { auth: getAuthWithSuperUser('space2'), }); - expect(connectors).to.eql([]); + expect(connectors).to.eql([ + /** + * Preconfigured connectors are being registered here: + * x-pack/test/cases_api_integration/common/config.ts + */ + { + actionTypeId: '.servicenow', + id: 'preconfigured-servicenow', + isPreconfigured: true, + name: 'preconfigured-servicenow', + referencedByCount: 0, + }, + ]); }); }); };