From 5144c9bbf1200d9a38a71834f1da4611b508fadd Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Tue, 18 Aug 2020 10:13:58 -0600 Subject: [PATCH] fix tests and enable in CI --- x-pack/scripts/functional_tests.js | 1 + .../basic/tests/configure/get_connectors.ts | 18 ++++++++-- .../case_api_integration/common/config.ts | 3 +- .../case_api_integration/common/lib/utils.ts | 35 ++++++++++++++++++- 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/x-pack/scripts/functional_tests.js b/x-pack/scripts/functional_tests.js index 205ff500a36ec..439975c9419a1 100644 --- a/x-pack/scripts/functional_tests.js +++ b/x-pack/scripts/functional_tests.js @@ -22,6 +22,7 @@ const onlyNotInCoverageTests = [ require.resolve('../test/alerting_api_integration/basic/config.ts'), require.resolve('../test/alerting_api_integration/spaces_only/config.ts'), require.resolve('../test/alerting_api_integration/security_and_spaces/config.ts'), + require.resolve('../test/case_api_integration/basic/config.ts'), require.resolve('../test/apm_api_integration/basic/config.ts'), require.resolve('../test/apm_api_integration/trial/config.ts'), require.resolve('../test/detection_engine_api_integration/security_and_spaces/config.ts'), diff --git a/x-pack/test/case_api_integration/basic/tests/configure/get_connectors.ts b/x-pack/test/case_api_integration/basic/tests/configure/get_connectors.ts index f5f290476dd0b..5ba1aac4c8f92 100644 --- a/x-pack/test/case_api_integration/basic/tests/configure/get_connectors.ts +++ b/x-pack/test/case_api_integration/basic/tests/configure/get_connectors.ts @@ -9,7 +9,11 @@ import { FtrProviderContext } from '../../../common/ftr_provider_context'; import { CASE_CONFIGURE_CONNECTORS_URL } from '../../../../../plugins/case/common/constants'; import { ObjectRemover as ActionsRemover } from '../../../../alerting_api_integration/common/lib'; -import { getServiceNowConnector, getJiraConnector } from '../../../common/lib/utils'; +import { + getServiceNowConnector, + getJiraConnector, + getResilientConnector, +} from '../../../common/lib/utils'; // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext): void => { @@ -61,9 +65,16 @@ export default ({ getService }: FtrProviderContext): void => { .send(getJiraConnector()) .expect(200); + const { body: connectorFour } = await supertest + .post('/api/actions/action') + .set('kbn-xsrf', 'true') + .send(getResilientConnector()) + .expect(200); + actionsRemover.add('default', connectorOne.id, 'action', 'actions'); actionsRemover.add('default', connectorTwo.id, 'action', 'actions'); actionsRemover.add('default', connectorThree.id, 'action', 'actions'); + actionsRemover.add('default', connectorFour.id, 'action', 'actions'); const { body: connectors } = await supertest .get(`${CASE_CONFIGURE_CONNECTORS_URL}/_find`) @@ -71,13 +82,16 @@ export default ({ getService }: FtrProviderContext): void => { .send() .expect(200); - expect(connectors.length).to.equal(2); + expect(connectors.length).to.equal(3); expect( connectors.some((c: { actionTypeId: string }) => c.actionTypeId === '.servicenow') ).to.equal(true); expect(connectors.some((c: { actionTypeId: string }) => c.actionTypeId === '.jira')).to.equal( true ); + expect( + connectors.some((c: { actionTypeId: string }) => c.actionTypeId === '.resilient') + ).to.equal(true); }); }); }; diff --git a/x-pack/test/case_api_integration/common/config.ts b/x-pack/test/case_api_integration/common/config.ts index 098d94f35d9ca..9b048813b479a 100644 --- a/x-pack/test/case_api_integration/common/config.ts +++ b/x-pack/test/case_api_integration/common/config.ts @@ -21,10 +21,11 @@ interface CreateTestConfigOptions { const enabledActionTypes = [ '.email', '.index', + '.jira', '.pagerduty', + '.resilient', '.server-log', '.servicenow', - '.jira', '.slack', '.webhook', 'test.authorization', diff --git a/x-pack/test/case_api_integration/common/lib/utils.ts b/x-pack/test/case_api_integration/common/lib/utils.ts index a24e17f9e5efb..fb6f4fce3c29a 100644 --- a/x-pack/test/case_api_integration/common/lib/utils.ts +++ b/x-pack/test/case_api_integration/common/lib/utils.ts @@ -33,7 +33,7 @@ export const getServiceNowConnector = () => ({ }, config: { apiUrl: 'http://some.non.existent.com', - casesConfiguration: { + incidentConfiguration: { mapping: [ { source: 'title', @@ -52,6 +52,7 @@ export const getServiceNowConnector = () => ({ }, ], }, + isCaseOwned: true, }, }); @@ -87,6 +88,38 @@ export const getJiraConnector = () => ({ }, }); +export const getResilientConnector = () => ({ + name: 'Resilient Connector', + actionTypeId: '.resilient', + secrets: { + apiKeyId: 'id', + apiKeySecret: 'secret', + }, + config: { + apiUrl: 'http://some.non.existent.com', + orgId: 'pkey', + casesConfiguration: { + mapping: [ + { + source: 'title', + target: 'summary', + actionType: 'overwrite', + }, + { + source: 'description', + target: 'description', + actionType: 'overwrite', + }, + { + source: 'comments', + target: 'comments', + actionType: 'append', + }, + ], + }, + }, +}); + export const removeServerGeneratedPropertiesFromConfigure = ( config: Partial ): Partial => {