diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/prebuilt_rules/fleet_integration.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/prebuilt_rules/fleet_integration.ts index 1433cb7cac2ff..9bd5dd2150f43 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/prebuilt_rules/fleet_integration.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/prebuilt_rules/fleet_integration.ts @@ -12,7 +12,7 @@ import { getPrebuiltRulesAndTimelinesStatus, } from '../../utils'; import { deleteAllPrebuiltRuleAssets } from '../../utils/prebuilt_rules/delete_all_prebuilt_rule_assets'; -import { installPrebuiltRulesFleetPackage } from '../../utils/prebuilt_rules/install_prebuilt_rules_fleet_package'; +import { installPrebuiltRulesPackageViaFleetAPI } from '../../utils/prebuilt_rules/install_fleet_package_by_url'; import { installPrebuiltRulesAndTimelines } from '../../utils/prebuilt_rules/install_prebuilt_rules_and_timelines'; import { deletePrebuiltRulesFleetPackage } from '../../utils/prebuilt_rules/delete_prebuilt_rules_fleet_package'; @@ -41,11 +41,7 @@ export default ({ getService }: FtrProviderContext): void => { expect(statusBeforePackageInstallation.rules_not_installed).toBe(0); expect(statusBeforePackageInstallation.rules_not_updated).toBe(0); - await installPrebuiltRulesFleetPackage({ - es, - supertest, - overrideExistingPackage: true, - }); + await installPrebuiltRulesPackageViaFleetAPI(es, supertest); // Verify that status is updated after package installation const statusAfterPackageInstallation = await getPrebuiltRulesAndTimelinesStatus(supertest); diff --git a/x-pack/test/detection_engine_api_integration/utils/index.ts b/x-pack/test/detection_engine_api_integration/utils/index.ts index 0e75e72a2d0ed..6de2b7282602b 100644 --- a/x-pack/test/detection_engine_api_integration/utils/index.ts +++ b/x-pack/test/detection_engine_api_integration/utils/index.ts @@ -112,3 +112,4 @@ export * from './prebuilt_rules/install_prebuilt_rules'; export * from './prebuilt_rules/upgrade_prebuilt_rules'; export * from './prebuilt_rules/install_mock_prebuilt_rules'; export * from './prebuilt_rules/install_prebuilt_rules_and_timelines'; +export * from './prebuilt_rules/get_prebuilt_rules_and_timelines_status'; diff --git a/x-pack/test/detection_engine_api_integration/utils/prebuilt_rules/install_fleet_package_by_url.ts b/x-pack/test/detection_engine_api_integration/utils/prebuilt_rules/install_fleet_package_by_url.ts index 802626881b8e6..bccdf28906e23 100644 --- a/x-pack/test/detection_engine_api_integration/utils/prebuilt_rules/install_fleet_package_by_url.ts +++ b/x-pack/test/detection_engine_api_integration/utils/prebuilt_rules/install_fleet_package_by_url.ts @@ -10,7 +10,7 @@ import { ALL_SAVED_OBJECT_INDICES } from '@kbn/core-saved-objects-server'; import { InstallPackageResponse } from '@kbn/fleet-plugin/common/types'; /** - * Installs prebuilt rules package `security_detection_engine` by version. + * Installs latest available non-prerelease prebuilt rules package `security_detection_engine`. * * @param es Elasticsearch client * @param supertest SuperTest instance @@ -18,13 +18,12 @@ import { InstallPackageResponse } from '@kbn/fleet-plugin/common/types'; * @returns Fleet install package response */ -export const installPrebuiltRulesPackageByVersion = async ( +export const installPrebuiltRulesPackageViaFleetAPI = async ( es: Client, - supertest: SuperTest.SuperTest, - version: string + supertest: SuperTest.SuperTest ): Promise => { const fleetResponse = await supertest - .post(`/api/fleet/epm/packages/security_detection_engine/${version}`) + .post(`/api/fleet/epm/packages/security_detection_engine`) .set('kbn-xsrf', 'xxxx') .type('application/json') .send({ force: true }) @@ -48,3 +47,29 @@ export const installPrebuiltRulesPackageByVersion = async ( return fleetResponse.body as InstallPackageResponse; }; +/** + * Installs prebuilt rules package `security_detection_engine`, passing in the version + * of the package as a parameter to the utl. + * + * @param es Elasticsearch client + * @param supertest SuperTest instance + * @param version Semver version of the `security_detection_engine` package to install + * @returns Fleet install package response + */ + +export const installPrebuiltRulesPackageByVersion = async ( + es: Client, + supertest: SuperTest.SuperTest, + version: string +): Promise => { + const fleetResponse = await supertest + .post(`/api/fleet/epm/packages/security_detection_engine/${version}`) + .set('kbn-xsrf', 'xxxx') + .type('application/json') + .send({ force: true }) + .expect(200); + + await es.indices.refresh({ index: ALL_SAVED_OBJECT_INDICES }); + + return fleetResponse.body as InstallPackageResponse; +};