mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Fleet] [Synthetics] force auto upgrade of managed policies (#144949)
## Summary Resolves https://github.com/elastic/kibana/issues/142896 Passes `{ force: true }` option when upgrading packages via the `managed_package_policy` flow. This ensures that Synthetics packages are able to be auto-upgraded via the Fleet setup flow when a new package version is available, while still restricting users from editing managed Synthetics packages from the UI. ### 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 Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
ccd670eab4
commit
b308e9e69c
4 changed files with 69 additions and 4 deletions
|
@ -92,7 +92,7 @@ describe('upgradeManagedPackagePolicies', () => {
|
|||
soClient,
|
||||
esClient,
|
||||
['managed-package-id'],
|
||||
undefined,
|
||||
{ force: true },
|
||||
packagePolicy,
|
||||
'1.0.0'
|
||||
);
|
||||
|
|
|
@ -118,7 +118,7 @@ async function upgradePackagePolicy(
|
|||
soClient,
|
||||
esClient,
|
||||
[packagePolicy.id],
|
||||
undefined,
|
||||
{ force: true },
|
||||
packagePolicy,
|
||||
installedPackage.version
|
||||
);
|
||||
|
|
|
@ -112,7 +112,7 @@ export interface PackagePolicyClient {
|
|||
soClient: SavedObjectsClientContract,
|
||||
esClient: ElasticsearchClient,
|
||||
ids: string[],
|
||||
options?: { user?: AuthenticatedUser },
|
||||
options?: { user?: AuthenticatedUser; force?: boolean },
|
||||
packagePolicy?: PackagePolicy,
|
||||
pkgVersion?: string
|
||||
): Promise<UpgradePackagePolicyResponse>;
|
||||
|
|
|
@ -222,7 +222,8 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
);
|
||||
|
||||
const packagePolicy = apiResponsePolicy.body.items.find(
|
||||
(pkgPolicy: PackagePolicy) => pkgPolicy.id === newMonitorId + '-' + testFleetPolicyID
|
||||
(pkgPolicy: PackagePolicy) =>
|
||||
pkgPolicy.id === newMonitorId + '-' + testFleetPolicyID + '-default'
|
||||
);
|
||||
|
||||
expect(packagePolicy).eql(undefined);
|
||||
|
@ -307,10 +308,74 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
formatKibanaNamespace(SPACE_ID)
|
||||
)
|
||||
);
|
||||
await supertestWithoutAuth
|
||||
.delete(`/s/${SPACE_ID}${API_URLS.SYNTHETICS_MONITORS}/${monitorId}`)
|
||||
.auth(username, password)
|
||||
.set('kbn-xsrf', 'true')
|
||||
.send()
|
||||
.expect(200);
|
||||
} finally {
|
||||
await security.user.delete(username);
|
||||
await security.role.delete(roleName);
|
||||
}
|
||||
});
|
||||
|
||||
it('handles auto upgrading policies', async () => {
|
||||
let monitorId = '';
|
||||
|
||||
const monitor = {
|
||||
...httpMonitorJson,
|
||||
name: `Test monitor ${uuid.v4()}`,
|
||||
[ConfigKey.NAMESPACE]: 'default',
|
||||
locations: [
|
||||
{
|
||||
id: testFleetPolicyID,
|
||||
label: 'Test private location 0',
|
||||
isServiceManaged: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
try {
|
||||
const apiResponse = await supertestAPI
|
||||
.post(API_URLS.SYNTHETICS_MONITORS)
|
||||
.set('kbn-xsrf', 'true')
|
||||
.send(monitor);
|
||||
|
||||
monitorId = apiResponse.body.id;
|
||||
|
||||
const policyResponse = await supertestAPI.get(
|
||||
'/api/fleet/package_policies?page=1&perPage=2000&kuery=ingest-package-policies.package.name%3A%20synthetics'
|
||||
);
|
||||
|
||||
const packagePolicy = policyResponse.body.items.find(
|
||||
(pkgPolicy: PackagePolicy) =>
|
||||
pkgPolicy.id === monitorId + '-' + testFleetPolicyID + `-default`
|
||||
);
|
||||
|
||||
expect(packagePolicy.package.version).eql('0.10.3');
|
||||
|
||||
await supertestAPI
|
||||
.post('/api/fleet/epm/packages/synthetics/0.11.2')
|
||||
.set('kbn-xsrf', 'true')
|
||||
.send({ force: true });
|
||||
|
||||
await supertestAPI.post('/api/fleet/setup').set('kbn-xsrf', 'true').send().expect(200);
|
||||
const policyResponseAfterUpgrade = await supertestAPI.get(
|
||||
'/api/fleet/package_policies?page=1&perPage=2000&kuery=ingest-package-policies.package.name%3A%20synthetics'
|
||||
);
|
||||
const packagePolicyAfterUpgrade = policyResponseAfterUpgrade.body.items.find(
|
||||
(pkgPolicy: PackagePolicy) =>
|
||||
pkgPolicy.id === monitorId + '-' + testFleetPolicyID + `-default`
|
||||
);
|
||||
expect(packagePolicyAfterUpgrade.package.version).eql('0.11.2');
|
||||
} finally {
|
||||
await supertestAPI
|
||||
.delete(API_URLS.SYNTHETICS_MONITORS + '/' + monitorId)
|
||||
.set('kbn-xsrf', 'true')
|
||||
.send()
|
||||
.expect(200);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue