-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spaces - NP updates for usage collection and capabilities (#57693)
* remove kibanaIndex from LegacyAPI * moving capabilities, adding tests * moving usage collection * cleanup * don't toggle capabilities on unauthenticated routes * reintroduce exception handling * pipe dat config * start addressing PR feedback * fix CoreSetup's generic type * fix usage collector tests * PR review updates Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
3f7abe3
commit 91330d2
Showing
23 changed files
with
409 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { loggingServiceMock } from '../../../core/server/mocks'; | ||
import { UsageCollectionSetup } from './plugin'; | ||
import { CollectorSet } from './collector'; | ||
|
||
const createSetupContract = () => { | ||
return { | ||
...new CollectorSet({ | ||
logger: loggingServiceMock.createLogger(), | ||
maximumWaitTimeForAllCollectorsInS: 1, | ||
}), | ||
registerLegacySavedObjects: jest.fn() as jest.Mocked< | ||
UsageCollectionSetup['registerLegacySavedObjects'] | ||
>, | ||
} as UsageCollectionSetup; | ||
}; | ||
|
||
export const usageCollectionPluginMock = { | ||
createSetupContract, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { PluginSetupContract, PluginStartContract } from './plugin'; | ||
|
||
const createSetup = (): jest.Mocked<PluginSetupContract> => { | ||
return { | ||
getFeatures: jest.fn(), | ||
getFeaturesUICapabilities: jest.fn(), | ||
registerFeature: jest.fn(), | ||
registerLegacyAPI: jest.fn(), | ||
}; | ||
}; | ||
|
||
const createStart = (): jest.Mocked<PluginStartContract> => { | ||
return { | ||
getFeatures: jest.fn(), | ||
}; | ||
}; | ||
|
||
export const featuresPluginMock = { | ||
createSetup, | ||
createStart, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/spaces/server/capabilities/capabilities_provider.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { capabilitiesProvider } from './capabilities_provider'; | ||
|
||
describe('Capabilities provider', () => { | ||
it('provides the expected capabilities', () => { | ||
expect(capabilitiesProvider()).toMatchInlineSnapshot(` | ||
Object { | ||
"management": Object { | ||
"kibana": Object { | ||
"spaces": true, | ||
}, | ||
}, | ||
"spaces": Object { | ||
"manage": true, | ||
}, | ||
} | ||
`); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
x-pack/plugins/spaces/server/capabilities/capabilities_provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const capabilitiesProvider = () => ({ | ||
spaces: { | ||
manage: true, | ||
}, | ||
management: { | ||
kibana: { | ||
spaces: true, | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.