-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Fleet] Restrict integration changes for managed policies #90675
Changes from 5 commits
30225be
6d9f231
90d93ac
66ba36a
45f420c
a810ce6
3399029
28526e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; | ||
import { warnAndSkipTest } from '../../helpers'; | ||
|
||
|
@@ -39,6 +39,52 @@ export default function ({ getService }: FtrProviderContext) { | |
.send({ agentPolicyId }); | ||
}); | ||
|
||
it('should fail for managed agent policies', async function () { | ||
if (server.enabled) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick we have a helper that does the same thing but I found it less verbose https://github.com/elastic/kibana/blob/master/x-pack/test/fleet_api_integration/apis/epm/data_stream.ts/#L37 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the reminder. I was just copy/pasting from the rest of the file. I'll update |
||
// get a managed policy | ||
const { | ||
body: { item: managedPolicy }, | ||
} = await supertest | ||
.post(`/api/fleet/agent_policies`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.send({ | ||
name: `Managed policy from ${Date.now()}`, | ||
namespace: 'default', | ||
is_managed: true, | ||
}); | ||
|
||
// try to add an integration to the managed policy | ||
const { body } = await supertest | ||
.post(`/api/fleet/package_policies`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.send({ | ||
name: 'filetest-1', | ||
description: '', | ||
namespace: 'default', | ||
policy_id: managedPolicy.id, | ||
enabled: true, | ||
output_id: '', | ||
inputs: [], | ||
package: { | ||
name: 'filetest', | ||
title: 'For File Tests', | ||
version: '0.1.0', | ||
}, | ||
}) | ||
.expect(400); | ||
|
||
expect(body.statusCode).to.be(400); | ||
expect(body.message).to.contain('Cannot add integrations to managed policy'); | ||
|
||
// delete policy we just made | ||
await supertest.post(`/api/fleet/agent_policies/delete`).set('kbn-xsrf', 'xxxx').send({ | ||
agentPolicyId: managedPolicy.id, | ||
}); | ||
} else { | ||
warnAndSkipTest(this, log); | ||
} | ||
}); | ||
|
||
it('should work with valid values', async function () { | ||
if (server.enabled) { | ||
await supertest | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(not blocking) I have the feeling that is time to refactor L64-L80 to a new function something like
_validateParentAgentPolicy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wanted to consolidate the two sources of the "There is already a package named..." errors
kibana/x-pack/plugins/fleet/server/services/package_policy.ts
Lines 297 to 304 in 45f420c
And perhaps give it a specific error name/type. I plan on circling back to that after I get the other features in.
I'll open a ticket