[Cloud Security] add fleet package policies and agent policies cleanups as part of cis… (#213762)

## Summary

This PR adds some cleanup logic that resets all policies in the
integration creation FTRs.

### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
This commit is contained in:
Alex Prozorov 2025-03-11 17:48:03 +02:00 committed by GitHub
parent a2dbf325e4
commit 68f46ba10c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 51 additions and 4 deletions

View file

@ -7,6 +7,7 @@
import expect from '@kbn/expect';
import type { FtrProviderContext } from '../../../ftr_provider_context';
import { policiesSavedObjects } from '../constants';
// eslint-disable-next-line import/no-default-export
export default function (providerContext: FtrProviderContext) {
@ -21,6 +22,11 @@ export default function (providerContext: FtrProviderContext) {
const RETRY_COUNT = 5;
const RETRY_DELAY = 1000;
const retryOptions = { retryCount: RETRY_COUNT, retryDelay: RETRY_DELAY };
const kibanaServer = getService('kibanaServer');
before(async () => {
await kibanaServer.savedObjects.clean({ types: policiesSavedObjects });
});
beforeEach(async () => {
cisIntegration = pageObjects.cisAddIntegration;

View file

@ -0,0 +1,13 @@
/*
* 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.
*/
export const policiesSavedObjects = [
'ingest-agent-policies',
'fleet-agent-policies',
'ingest-package-policies',
'fleet-package-policies',
];

View file

@ -8,6 +8,7 @@
import expect from '@kbn/expect';
import type { FtrProviderContext } from '../../../ftr_provider_context';
import { testSubjectIds } from '../../../constants/test_subject_ids';
import { policiesSavedObjects } from '../constants';
const {
CIS_AWS_OPTION_TEST_ID,
@ -28,6 +29,7 @@ const {
export default function (providerContext: FtrProviderContext) {
const { getPageObjects, getService } = providerContext;
const pageObjects = getPageObjects(['cloudPostureDashboard', 'cisAddIntegration', 'header']);
const kibanaServer = getService('kibanaServer');
const retry = getService('retry');
const logger = getService('log');
const saveIntegrationPolicyTimeout = 1000 * 30; // 30 seconds
@ -37,6 +39,10 @@ export default function (providerContext: FtrProviderContext) {
let cisIntegrationAws: typeof pageObjects.cisAddIntegration.cisAws;
let cisIntegration: typeof pageObjects.cisAddIntegration;
before(async () => {
await kibanaServer.savedObjects.clean({ types: policiesSavedObjects });
});
beforeEach(async () => {
cisIntegration = pageObjects.cisAddIntegration;
cisIntegrationAws = pageObjects.cisAddIntegration.cisAws;
@ -78,7 +84,6 @@ export default function (providerContext: FtrProviderContext) {
});
});
// FLAKY: https://github.com/elastic/kibana/issues/187470
describe('CIS_AWS Organization Manual Assume Role', () => {
it('CIS_AWS Organization Manual Assume Role Workflow', async () => {
const roleArn = 'RoleArnTestValue';

View file

@ -8,6 +8,7 @@
import expect from '@kbn/expect';
import type { FtrProviderContext } from '../../../ftr_provider_context';
import { testSubjectIds } from '../../../constants/test_subject_ids';
import { policiesSavedObjects } from '../constants';
const {
CIS_AZURE_OPTION_TEST_ID,
@ -28,6 +29,7 @@ export default function (providerContext: FtrProviderContext) {
const { getPageObjects, getService } = providerContext;
const retry = getService('retry');
const pageObjects = getPageObjects(['cloudPostureDashboard', 'cisAddIntegration', 'header']);
const kibanaServer = getService('kibanaServer');
const saveIntegrationPolicyTimeout = 1000 * 30; // 30 seconds
describe('Test adding Cloud Security Posture Integrations CSPM AZURE', function () {
@ -35,10 +37,13 @@ export default function (providerContext: FtrProviderContext) {
let cisIntegration: typeof pageObjects.cisAddIntegration;
let cisIntegrationAzure: typeof pageObjects.cisAddIntegration.cisAzure;
before(async () => {
await kibanaServer.savedObjects.clean({ types: policiesSavedObjects });
});
beforeEach(async () => {
cisIntegration = pageObjects.cisAddIntegration;
cisIntegrationAzure = pageObjects.cisAddIntegration.cisAzure;
await cisIntegration.navigateToAddIntegrationCspmPage();
});

View file

@ -8,6 +8,7 @@
import expect from '@kbn/expect';
import type { FtrProviderContext } from '../../../ftr_provider_context';
import { testSubjectIds } from '../../../constants/test_subject_ids';
import { policiesSavedObjects } from '../constants';
const {
CIS_GCP_OPTION_TEST_ID,
@ -27,6 +28,8 @@ export default function (providerContext: FtrProviderContext) {
const { getPageObjects, getService } = providerContext;
const pageObjects = getPageObjects(['cloudPostureDashboard', 'cisAddIntegration', 'header']);
const retry = getService('retry');
const kibanaServer = getService('kibanaServer');
const saveIntegrationPolicyTimeout = 1000 * 30; // 30 seconds
describe('Test adding Cloud Security Posture Integrations CSPM GCP', function () {
@ -34,10 +37,13 @@ export default function (providerContext: FtrProviderContext) {
let cisIntegrationGcp: typeof pageObjects.cisAddIntegration.cisGcp;
let cisIntegration: typeof pageObjects.cisAddIntegration;
before(async () => {
await kibanaServer.savedObjects.clean({ types: policiesSavedObjects });
});
beforeEach(async () => {
cisIntegration = pageObjects.cisAddIntegration;
cisIntegrationGcp = pageObjects.cisAddIntegration.cisGcp;
await cisIntegration.navigateToAddIntegrationCspmPage();
});

View file

@ -7,6 +7,7 @@
import expect from '@kbn/expect';
import type { FtrProviderContext } from '../../../ftr_provider_context';
import { policiesSavedObjects } from '../constants';
const CIS_EKS_OPTION_TEST_ID = 'cisEksTestId';
const EKS_DIRECT_ACCESS_TEST_ID = 'directAccessKeyTestId';
@ -23,13 +24,18 @@ const SHARED_CREDETIALS_PROFILE_NAME_TEST_ID = 'credentialProfileName';
// eslint-disable-next-line import/no-default-export
export default function (providerContext: FtrProviderContext) {
const { getPageObjects } = providerContext;
const { getPageObjects, getService } = providerContext;
const pageObjects = getPageObjects(['cloudPostureDashboard', 'cisAddIntegration', 'header']);
const kibanaServer = getService('kibanaServer');
describe('Test adding Cloud Security Posture Integrations KSPM EKS', function () {
this.tags(['cloud_security_posture_cis_integration_kspm_eks']);
let cisIntegration: typeof pageObjects.cisAddIntegration;
before(async () => {
await kibanaServer.savedObjects.clean({ types: policiesSavedObjects });
});
beforeEach(async () => {
cisIntegration = pageObjects.cisAddIntegration;
await cisIntegration.navigateToAddIntegrationKspmPage();

View file

@ -7,18 +7,24 @@
import expect from '@kbn/expect';
import type { FtrProviderContext } from '../../../ftr_provider_context';
import { policiesSavedObjects } from '../constants';
// eslint-disable-next-line import/no-default-export
export default function (providerContext: FtrProviderContext) {
const { getPageObjects, getService } = providerContext;
const pageObjects = getPageObjects(['cloudPostureDashboard', 'cisAddIntegration', 'header']);
const retry = getService('retry');
const kibanaServer = getService('kibanaServer');
const saveIntegrationPolicyTimeout = 1000 * 30; // 30 seconds
describe('Test adding Cloud Security Posture Integrations KSPM K8S', function () {
this.tags(['cloud_security_posture_cis_integration_kspm_k8s']);
let cisIntegration: typeof pageObjects.cisAddIntegration;
before(async () => {
await kibanaServer.savedObjects.clean({ types: policiesSavedObjects });
});
beforeEach(async () => {
cisIntegration = pageObjects.cisAddIntegration;
await cisIntegration.navigateToAddIntegrationKspmPage();