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 a433f5da1d74a..322bc3567211d 100644 --- a/x-pack/test/cases_api_integration/common/lib/utils.ts +++ b/x-pack/test/cases_api_integration/common/lib/utils.ts @@ -289,6 +289,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/basic/configure/get_connectors.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/configure/get_connectors.ts new file mode 100644 index 0000000000000..57854075c20fb --- /dev/null +++ b/x-pack/test/cases_api_integration/security_and_spaces/tests/basic/configure/get_connectors.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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../../../common/ftr_provider_context'; + +import { getCaseConnectors } from '../../../../common/lib/utils'; + +// eslint-disable-next-line import/no-default-export +export default ({ getService }: FtrProviderContext): void => { + const supertest = getService('supertest'); + + describe('get_connectors', () => { + /** + * 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([]); + }); + }); +}; 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/configure/get_connectors.ts b/x-pack/test/cases_api_integration/security_and_spaces/tests/common/configure/get_connectors.ts deleted file mode 100644 index 5209f65cf4feb..0000000000000 --- a/x-pack/test/cases_api_integration/security_and_spaces/tests/common/configure/get_connectors.ts +++ /dev/null @@ -1,55 +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 expect from '@kbn/expect'; -import { FtrProviderContext } from '../../../../../common/ftr_provider_context'; - -import { - createConnector, - getCaseConnectors, - getServiceNowConnector, - getWebhookConnector, -} from '../../../../common/lib/utils'; - -// eslint-disable-next-line import/no-default-export -export default ({ getService }: FtrProviderContext): void => { - const supertest = getService('supertest'); - - /** - * Preconfigured connectors are being registered here: - * x-pack/test/cases_api_integration/common/config.ts - */ - describe('get_connectors', () => { - it('should return only supported connectors including preconfigured connectors', async () => { - await createConnector({ supertest, req: getServiceNowConnector() }); - await createConnector({ supertest, req: getWebhookConnector() }); - const connectors = await getCaseConnectors({ supertest }); - - expect(connectors).to.eql([ - { - actionTypeId: '.servicenow', - id: 'preconfigured-servicenow', - isPreconfigured: true, - name: 'preconfigured-servicenow', - referencedByCount: 0, - }, - { - actionTypeId: '.servicenow', - config: { - apiUrl: 'http://some.non.existent.com', - usesTableApi: false, - }, - id: '35e75fd0-bfbe-11ec-b200-cdb35f39b10d', - isMissingSecrets: false, - isPreconfigured: false, - name: 'ServiceNow Connector', - referencedByCount: 0, - }, - ]); - }); - }); -}; 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 f70c8593d3c94..25f39164f7c28 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 b5a58d3af5086..91309462d98be 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 @@ -6,7 +6,6 @@ */ import expect from '@kbn/expect'; -import { CASE_CONFIGURE_CONNECTORS_URL } from '@kbn/cases-plugin/common/constants'; import { FtrProviderContext } from '../../../../../common/ftr_provider_context'; import { ObjectRemover as ActionsRemover } from '../../../../../alerting_api_integration/common/lib'; @@ -16,6 +15,8 @@ import { getResilientConnector, createConnector, getServiceNowSIRConnector, + getEmailConnector, + getCaseConnectors, } from '../../../../common/lib/utils'; // eslint-disable-next-line import/no-default-export @@ -29,41 +30,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 +42,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 +57,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, + }, + ]); }); }); };