From 4ecc213db946aa85a55d032121012002f120adeb Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 7 Mar 2025 03:35:49 +1100 Subject: [PATCH] [8.18] [Siem Migrations] `GET /integrations` integration Test (#213251) (#213356) # Backport This will backport the following commits from `main` to `8.18`: - [[Siem Migrations] `GET /integrations` integration Test (#213251)](https://github.com/elastic/kibana/pull/213251) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) Co-authored-by: Jatin Kathuria --- .../get_integrations.ts | 27 +++++++++++++++++++ .../trial_license_complete_tier/index.ts | 1 + .../siem_migrations/utils/rules.ts | 19 +++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 x-pack/test/security_solution_api_integration/test_suites/siem_migrations/rules/trial_license_complete_tier/get_integrations.ts diff --git a/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/rules/trial_license_complete_tier/get_integrations.ts b/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/rules/trial_license_complete_tier/get_integrations.ts new file mode 100644 index 0000000000000..b1d5f91c7d369 --- /dev/null +++ b/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/rules/trial_license_complete_tier/get_integrations.ts @@ -0,0 +1,27 @@ +/* + * 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 '../../../../ftr_provider_context'; +import { migrationRulesRouteHelpersFactory } from '../../utils'; + +export default ({ getService }: FtrProviderContext) => { + const supertest = getService('supertest'); + const migrationRulesRoutes = migrationRulesRouteHelpersFactory(supertest); + + describe('Get Integrations', () => { + it('should return all integrations successfully', async () => { + const response = await migrationRulesRoutes.getIntegrations({}); + + const integrationsObj = response.body; + const integrationIds = Object.keys(integrationsObj); + + expect(integrationIds.length).to.be.greaterThan(0); + expect(integrationsObj[integrationIds[0]]).to.have.keys('package', 'version'); + }); + }); +}; diff --git a/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/rules/trial_license_complete_tier/index.ts b/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/rules/trial_license_complete_tier/index.ts index 83a2892824589..6085a1c14cfe2 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/rules/trial_license_complete_tier/index.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/rules/trial_license_complete_tier/index.ts @@ -16,5 +16,6 @@ export default function ({ loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./update')); loadTestFile(require.resolve('./start')); loadTestFile(require.resolve('./stop')); + loadTestFile(require.resolve('./get_integrations')); }); } diff --git a/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/utils/rules.ts b/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/utils/rules.ts index 5de59badaa960..8e283effdfeda 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/utils/rules.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/siem_migrations/utils/rules.ts @@ -22,10 +22,12 @@ import { SIEM_RULE_MIGRATION_STATS_PATH, SIEM_RULE_MIGRATION_TRANSLATION_STATS_PATH, SIEM_RULE_MIGRATION_STOP_PATH, + SIEM_RULE_MIGRATIONS_INTEGRATIONS_PATH, } from '@kbn/security-solution-plugin/common/siem_migrations/constants'; import { CreateRuleMigrationResponse, GetAllStatsRuleMigrationResponse, + GetRuleMigrationIntegrationsResponse, GetRuleMigrationPrebuiltRulesResponse, GetRuleMigrationRequestQuery, GetRuleMigrationResponse, @@ -262,5 +264,22 @@ export const migrationRulesRouteHelpersFactory = (supertest: SuperTest.Agent) => return response; }, + + getIntegrations: async ({ + expectStatusCode = 200, + }: RequestParams): Promise<{ + body: GetRuleMigrationIntegrationsResponse; + }> => { + const response = await supertest + .get(SIEM_RULE_MIGRATIONS_INTEGRATIONS_PATH) + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, API_VERSIONS.internal.v1) + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(); + + assertStatusCode(expectStatusCode, response); + + return response; + }, }; };