-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unskip tests for the prebuilt rules bootstrap endpoint
- Loading branch information
Showing
7 changed files
with
131 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
...st_suites/detections_response/utils/rules/prebuilt_rules/delete_endpoint_fleet_package.ts
This file was deleted.
Oops, something went wrong.
111 changes: 111 additions & 0 deletions
111
...ation/test_suites/detections_response/utils/rules/prebuilt_rules/delete_fleet_packages.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* 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 type { Client } from '@elastic/elasticsearch'; | ||
import { epmRouteService } from '@kbn/fleet-plugin/common'; | ||
import { RetryService } from '@kbn/ftr-common-functional-services'; | ||
import { | ||
ENDPOINT_PACKAGE_NAME, | ||
PREBUILT_RULES_PACKAGE_NAME, | ||
} from '@kbn/security-solution-plugin/common/detection_engine/constants'; | ||
import { ToolingLog } from '@kbn/tooling-log'; | ||
import type SuperTest from 'supertest'; | ||
import { refreshSavedObjectIndices } from '../../refresh_index'; | ||
|
||
interface DeleteFleetPackageDeps { | ||
supertest: SuperTest.Agent; | ||
retryService: RetryService; | ||
log: ToolingLog; | ||
es: Client; | ||
} | ||
|
||
interface DeleteFleetPackageArgs { | ||
packageName: string; | ||
dependencies: DeleteFleetPackageDeps; | ||
} | ||
|
||
/** | ||
* Delete the security_detection_engine package using fleet API. | ||
*/ | ||
export async function deletePrebuiltRulesFleetPackage(params: DeleteFleetPackageDeps) { | ||
await deleteFleetPackage({ | ||
packageName: PREBUILT_RULES_PACKAGE_NAME, | ||
dependencies: params, | ||
}); | ||
} | ||
|
||
/** | ||
* Delete the endpoint package using fleet API. | ||
*/ | ||
export async function deleteEndpointFleetPackage(params: DeleteFleetPackageDeps) { | ||
await deleteFleetPackage({ | ||
packageName: ENDPOINT_PACKAGE_NAME, | ||
dependencies: params, | ||
}); | ||
} | ||
|
||
async function deleteFleetPackage(params: DeleteFleetPackageArgs): Promise<void> { | ||
const { packageName, dependencies } = params; | ||
const { supertest, retryService, log, es } = dependencies; | ||
|
||
const resp = await retryService.tryWithRetries( | ||
'deleteFleetPackage.check', | ||
async () => { | ||
log.debug(`Checking if ${packageName} package is installed`); | ||
|
||
return await supertest | ||
.get(epmRouteService.getInfoPath(packageName)) | ||
.set('kbn-xsrf', 'true') | ||
.set('elastic-api-version', '2023-10-31') | ||
.send(); | ||
}, | ||
{ | ||
retryCount: 2, | ||
timeout: 3 * 30000, | ||
} | ||
); | ||
|
||
if (resp.status === 200 && resp.body.item.status === 'installed') { | ||
await retryService.tryWithRetries( | ||
'deleteFleetPackage.delete', | ||
async () => { | ||
log.debug(`Deleting ${packageName} package`); | ||
|
||
await supertest | ||
.delete(epmRouteService.getRemovePath(packageName, resp.body.item.version)) | ||
.set('kbn-xsrf', 'true') | ||
.send({ force: true }) | ||
.expect(200); | ||
|
||
log.debug(`Deleted ${packageName} package`); | ||
}, | ||
{ | ||
retryCount: 2, | ||
timeout: 3 * 60000, | ||
} | ||
); | ||
|
||
await refreshSavedObjectIndices(es); | ||
} | ||
|
||
// log.debug(`Checking if ${packageName} package is installed`); | ||
// const resp = await supertest | ||
// .get(epmRouteService.getInfoPath(packageName)) | ||
// .set('kbn-xsrf', 'true') | ||
// .set('elastic-api-version', '2023-10-31') | ||
// .send(); | ||
|
||
// if (resp.status === 200 && resp.body.item.status === 'installed') { | ||
// log.debug(`Deleting ${packageName} package`); | ||
// await supertest | ||
// .delete(epmRouteService.getRemovePath(packageName, resp.body.item.version)) | ||
// .set('kbn-xsrf', 'true') | ||
// .send({ force: true }); | ||
|
||
// log.debug(`Deleted ${packageName} package`); | ||
// } | ||
} |
30 changes: 0 additions & 30 deletions
30
...tes/detections_response/utils/rules/prebuilt_rules/delete_prebuilt_rules_fleet_package.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters