Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Soluiton] Add logging and unskip rule bootstrap test #203799

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default ({ getService }: FtrProviderContext): void => {
beforeEach(async () => {
await deleteAllRules(supertest, log);
await deleteAllPrebuiltRuleAssets(es, log);
await deletePrebuiltRulesFleetPackage(supertest);
await deletePrebuiltRulesFleetPackage(supertest, log);
});

it('should install latest stable version and ignore prerelease packages', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ import { deleteEndpointFleetPackage } from '../../../../utils/rules/prebuilt_rul
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const securitySolutionApi = getService('securitySolutionApi');
const log = getService('log');

// Failing: See https://github.com/elastic/kibana/issues/197108
describe.skip('@ess @serverless @skipInServerlessMKI Bootstrap Prebuilt Rules', () => {
describe('@ess @serverless @skipInServerlessMKI Bootstrap Prebuilt Rules', () => {
beforeEach(async () => {
await deletePrebuiltRulesFleetPackage(supertest);
await deleteEndpointFleetPackage(supertest);
await deletePrebuiltRulesFleetPackage(supertest, log);
await deleteEndpointFleetPackage(supertest, log);
});

it('should install fleet packages required for detection engine to function', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default ({ getService }: FtrProviderContext): void => {

describe('@ess @serverless @skipInServerlessMKI install_prebuilt_rules_from_real_package', () => {
beforeEach(async () => {
await deletePrebuiltRulesFleetPackage(supertest);
await deletePrebuiltRulesFleetPackage(supertest, log);
await deleteAllRules(supertest, log);
await deleteAllTimelines(es, log);
await deleteAllPrebuiltRuleAssets(es, log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,28 @@
import { epmRouteService } from '@kbn/fleet-plugin/common';
import { ENDPOINT_PACKAGE_NAME } from '@kbn/security-solution-plugin/common/detection_engine/constants';
import type SuperTest from 'supertest';
import { ToolingLog } from '@kbn/tooling-log';

/**
* Delete the endpoint package using fleet API.
*
* @param supertest Supertest instance
*/
export async function deleteEndpointFleetPackage(supertest: SuperTest.Agent) {
export async function deleteEndpointFleetPackage(supertest: SuperTest.Agent, log: ToolingLog) {
log.debug('Checking if endpoint package is installed');
const resp = await supertest
.get(epmRouteService.getInfoPath(ENDPOINT_PACKAGE_NAME))
.set('kbn-xsrf', 'true')
.set('elastic-api-version', '2023-10-31')
.send();

if (resp.status === 200 && resp.body.response.status === 'installed') {
log.debug('Deleting endpoint package');
await supertest
.delete(epmRouteService.getRemovePath(ENDPOINT_PACKAGE_NAME, resp.body.response.version))
.set('kbn-xsrf', 'true')
.send({ force: true });

log.debug('Deleted endpoint package');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,32 @@

import { epmRouteService } from '@kbn/fleet-plugin/common';
import { PREBUILT_RULES_PACKAGE_NAME } from '@kbn/security-solution-plugin/common/detection_engine/constants';
import { ToolingLog } from '@kbn/tooling-log';
import type SuperTest from 'supertest';

/**
* Delete the security_detection_engine package using fleet API.
*
* @param supertest Supertest instance
*/
export async function deletePrebuiltRulesFleetPackage(supertest: SuperTest.Agent) {
export async function deletePrebuiltRulesFleetPackage(supertest: SuperTest.Agent, log: ToolingLog) {
banderror marked this conversation as resolved.
Show resolved Hide resolved
log.debug('Checking if prebuilt rules package is installed');
const resp = await supertest
.get(epmRouteService.getInfoPath(PREBUILT_RULES_PACKAGE_NAME))
.set('kbn-xsrf', 'true')
.set('elastic-api-version', '2023-10-31')
.send();

if (resp.status === 200 && resp.body.response.status === 'installed') {
log.debug('Deleting prebuilt rules package');
await supertest
.delete(
epmRouteService.getRemovePath(PREBUILT_RULES_PACKAGE_NAME, resp.body.response.version)
)
.set('kbn-xsrf', 'true')
.timeout(60000)
.send({ force: true });

log.debug('Deleted prebuilt rules package');
}
}