mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Fleet] Fix migrating enrollment api keys for space awareness (#207847)
This commit is contained in:
parent
59e81ee2be
commit
0d32932f6b
3 changed files with 16 additions and 2 deletions
|
@ -119,7 +119,10 @@ export async function getEnrollmentAPIKey(
|
|||
|
||||
if (spaceId) {
|
||||
if (spaceId === DEFAULT_SPACE_ID) {
|
||||
if (body._source?.namespaces && !body._source?.namespaces.includes(DEFAULT_SPACE_ID)) {
|
||||
if (
|
||||
(body._source?.namespaces?.length ?? 0) > 0 &&
|
||||
!body._source?.namespaces?.includes(DEFAULT_SPACE_ID)
|
||||
) {
|
||||
throw new EnrollmentKeyNotFoundError(`Enrollment api key ${id} not found in namespace`);
|
||||
}
|
||||
} else if (!body._source?.namespaces?.includes(spaceId)) {
|
||||
|
|
|
@ -517,7 +517,8 @@ export class SpaceTestApiClient {
|
|||
.post(`${this.getBaseUrl(spaceId)}/internal/fleet/enable_space_awareness`)
|
||||
.auth(this.auth.username, this.auth.password)
|
||||
.set('kbn-xsrf', 'xxxx')
|
||||
.set('elastic-api-version', '1');
|
||||
.set('elastic-api-version', '1')
|
||||
.expect(200);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -123,6 +123,16 @@ export default function (providerContext: FtrProviderContext) {
|
|||
expect(policiesTestSpaceIds.length).to.eql(0);
|
||||
});
|
||||
|
||||
it('enrollment api keys should be available', async () => {
|
||||
const defaultSpaceEnrollmentApiKeys = await apiClient.getEnrollmentApiKeys();
|
||||
expect(defaultSpaceEnrollmentApiKeys.items.length).to.eql(3);
|
||||
|
||||
await apiClient.getEnrollmentApiKeys(defaultSpaceEnrollmentApiKeys.items[0].id);
|
||||
|
||||
const testSpaceEnrollmentApiKeys = await apiClient.getEnrollmentApiKeys(TEST_SPACE_1);
|
||||
expect(testSpaceEnrollmentApiKeys.items.length).to.eql(0);
|
||||
});
|
||||
|
||||
it('package policies should be migrated to the default space', async () => {
|
||||
const policiesDefaultSpaceIds = (await apiClient.getPackagePolicies()).items
|
||||
.map(({ id }) => id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue