mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
This commit is contained in:
parent
7e8eed447a
commit
0846cde660
2 changed files with 40 additions and 1 deletions
|
@ -1386,7 +1386,7 @@ export async function incrementPackageName(
|
|||
? packagePolicyData.items
|
||||
.filter((ds) => Boolean(ds.name.match(pkgPoliciesNamePattern)))
|
||||
.map((ds) => parseInt(ds.name.match(pkgPoliciesNamePattern)![1], 10))
|
||||
.sort()
|
||||
.sort((a, b) => a - b)
|
||||
: [];
|
||||
|
||||
return `${packageName}-${
|
||||
|
|
|
@ -133,6 +133,45 @@ export default function (providerContext: FtrProviderContext) {
|
|||
.expect(409);
|
||||
});
|
||||
|
||||
it('should allow to create policy with the system integration policy and increment correctly the name if there is more than 10 package policy', async () => {
|
||||
// load a bunch of fake system integration policy
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await kibanaServer.savedObjects.create({
|
||||
id: `package-policy-test-${i}`,
|
||||
type: PACKAGE_POLICY_SAVED_OBJECT_TYPE,
|
||||
overwrite: true,
|
||||
attributes: {
|
||||
name: `system-${i + 1}`,
|
||||
package: {
|
||||
name: 'system',
|
||||
},
|
||||
},
|
||||
});
|
||||
packagePoliciesToDeleteIds.push(`package-policy-test-${i}`);
|
||||
}
|
||||
|
||||
// first one succeeds
|
||||
const res = await supertest
|
||||
.post(`/api/fleet/agent_policies`)
|
||||
.query({
|
||||
sys_monitoring: true,
|
||||
})
|
||||
.set('kbn-xsrf', 'xxxx')
|
||||
.send({
|
||||
name: `Policy with system monitoring ${Date.now()}`,
|
||||
namespace: 'default',
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
const {
|
||||
body: { items: policies },
|
||||
} = await supertest.get(`/api/fleet/agent_policies?full=true`).expect(200);
|
||||
|
||||
const policy = policies.find((p: any) => (p.id = res.body.item.id));
|
||||
|
||||
expect(policy.package_policies[0].name).be('system-11');
|
||||
});
|
||||
|
||||
it('should allow to create policy with the system integration policy and increment correctly the name', async () => {
|
||||
// load a bunch of fake system integration policy
|
||||
await kibanaServer.savedObjects.create({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue