Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
criamico committed Oct 19, 2021
1 parent bcd2ed1 commit 07768cf
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions x-pack/test/fleet_api_integration/apis/package_policy/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,5 +276,53 @@ export default function (providerContext: FtrProviderContext) {
})
.expect(400);
});

it('should return a 400 if there is a package policy with the same name on a different policy', async function () {
const { body: agentPolicyResponse } = await supertest
.post(`/api/fleet/agent_policies`)
.set('kbn-xsrf', 'xxxx')
.send({
name: 'Test policy',
namespace: 'default',
});
const otherAgentPolicyId = agentPolicyResponse.item.id;

await supertest
.post(`/api/fleet/package_policies`)
.set('kbn-xsrf', 'xxxx')
.send({
name: 'same-name-test-2',
description: '',
namespace: 'default',
policy_id: otherAgentPolicyId,
enabled: true,
output_id: '',
inputs: [],
package: {
name: 'filetest',
title: 'For File Tests',
version: '0.1.0',
},
})
.expect(200);
await supertest
.post(`/api/fleet/package_policies`)
.set('kbn-xsrf', 'xxxx')
.send({
name: 'same-name-test-2',
description: '',
namespace: 'default',
policy_id: agentPolicyId,
enabled: true,
output_id: '',
inputs: [],
package: {
name: 'filetest',
title: 'For File Tests',
version: '0.1.0',
},
})
.expect(400);
});
});
}

0 comments on commit 07768cf

Please sign in to comment.