mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Allow reserved privileges to get their capabilities (#63698)
This commit is contained in:
parent
871f7209f9
commit
d0b4ae7e29
2 changed files with 39 additions and 0 deletions
|
@ -135,6 +135,42 @@ describe('populateUICapabilities', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it(`supports capabilities from reserved privileges`, () => {
|
||||
expect(
|
||||
uiCapabilitiesForFeatures([
|
||||
new Feature({
|
||||
id: 'newFeature',
|
||||
name: 'my new feature',
|
||||
navLinkId: 'newFeatureNavLink',
|
||||
app: ['bar-app'],
|
||||
privileges: null,
|
||||
reserved: {
|
||||
description: '',
|
||||
privileges: [
|
||||
{
|
||||
id: 'rp_1',
|
||||
privilege: createFeaturePrivilege(['capability1', 'capability2']),
|
||||
},
|
||||
{
|
||||
id: 'rp_2',
|
||||
privilege: createFeaturePrivilege(['capability3', 'capability4', 'capability5']),
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
])
|
||||
).toEqual({
|
||||
catalogue: {},
|
||||
newFeature: {
|
||||
capability1: true,
|
||||
capability2: true,
|
||||
capability3: true,
|
||||
capability4: true,
|
||||
capability5: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it(`supports merging features with sub privileges`, () => {
|
||||
expect(
|
||||
uiCapabilitiesForFeatures([
|
||||
|
|
|
@ -45,6 +45,9 @@ function getCapabilitiesFromFeature(feature: Feature): FeatureCapabilities {
|
|||
...feature.subFeatures.map(sf => sf.privilegeGroups.map(pg => pg.privileges)).flat(2)
|
||||
);
|
||||
}
|
||||
if (feature.reserved?.privileges) {
|
||||
featurePrivileges.push(...feature.reserved.privileges.map(rp => rp.privilege));
|
||||
}
|
||||
|
||||
featurePrivileges.forEach(privilege => {
|
||||
UIFeatureCapabilities[feature.id] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue