Skip to content
Merged
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 @@ -27,6 +27,40 @@ export class PrivateLocationTestService {
this.getService = getService;
}

async cleanupFleetPolicies() {
// Delete package policies first (they reference agent policies)
const packagePoliciesRes = await this.supertest
.get('/api/fleet/package_policies?perPage=1000')
.set('kbn-xsrf', 'true');

if (packagePoliciesRes.status === 200) {
const packagePolicies = packagePoliciesRes.body.items || [];
for (const packagePolicy of packagePolicies) {
await this.supertest
.delete(`/api/fleet/package_policies/${packagePolicy.id}?force=true`)
.set('kbn-xsrf', 'true');
}
}

// Then delete agent policies
const agentPoliciesRes = await this.supertest
.get('/api/fleet/agent_policies?perPage=1000')
.set('kbn-xsrf', 'true');

if (agentPoliciesRes.status === 200) {
const agentPolicies = agentPoliciesRes.body.items || [];
for (const agentPolicy of agentPolicies) {
if (agentPolicy.is_managed) {
continue;
}
await this.supertest
.post('/api/fleet/agent_policies/delete')
.set('kbn-xsrf', 'true')
.send({ agentPolicyId: agentPolicy.id });
}
}
}

async installSyntheticsPackage() {
await this.supertest.post('/api/fleet/setup').set('kbn-xsrf', 'true').send().expect(200);
// Attempt to delete any existing package so we can install a specific version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default function ({ getService }: FtrProviderContext) {
const params: Record<string, string> = {};

before(async () => {
await testPrivateLocations.cleanupFleetPolicies();
await kServer.savedObjects.cleanStandardList();
await testPrivateLocations.installSyntheticsPackage();
_browserMonitorJson = getFixtureJson('browser_monitor');
Expand Down