From cad32cac38be5e26e223c4a21f069ceebf144312 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Tue, 19 Apr 2022 12:01:46 +0300 Subject: [PATCH] Add integration test --- .../cases_api_integration/common/config.ts | 14 ++++++- .../tests/common/configure/get_connectors.ts | 40 ++++++++++++++++--- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/x-pack/test/cases_api_integration/common/config.ts b/x-pack/test/cases_api_integration/common/config.ts index 803327cd037d3..421f2f823442e 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/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 index 46f712ff84aa3..5209f65cf4feb 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/common/configure/get_connectors.ts @@ -8,20 +8,48 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../../../common/ftr_provider_context'; -import { getCaseConnectors } from '../../../../common/lib/utils'; +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 an empty find body correctly if no connectors are loaded', async () => { + 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([]); - }); - 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([ + { + 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, + }, + ]); }); }); };