Skip to content

Commit

Permalink
Some minor change
Browse files Browse the repository at this point in the history
Signed-off-by: gaobinlong <[email protected]>
  • Loading branch information
gaobinlong committed Sep 22, 2023
1 parent ab08ab9 commit c180e87
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
40 changes: 38 additions & 2 deletions src/core/server/saved_objects/permission_control/acl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { Principals, Permissions, ACL } from './acl';

describe('SavedObjectTypeRegistry', () => {
describe('acl', () => {
it('test has permission', () => {
const principals: Principals = {
users: ['user1'],
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('SavedObjectTypeRegistry', () => {
expect(result).toEqual({});
});

it('test transform permission', () => {
it('test toFlatList', () => {
const principals: Principals = {
users: ['user1'],
groups: ['group1', 'group2'],
Expand Down Expand Up @@ -257,5 +257,41 @@ describe('SavedObjectTypeRegistry', () => {
},
},
});

result = ACL.generateGetPermittedSavedObjectsQueryDSL(['read'], principals);
expect(result).toEqual({
query: {
bool: {
filter: [
{
bool: {
should: [
{
terms: {
'permissions.read.users': ['user1'],
},
},
{
term: {
'permissions.read.users': '*',
},
},
{
terms: {
'permissions.read.groups': ['group1'],
},
},
{
term: {
'permissions.read.groups': '*',
},
},
],
},
},
],
},
},
});
});
});
3 changes: 2 additions & 1 deletion src/core/server/saved_objects/permission_control/acl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export class ACL {
}

/**
* transform permissions format
* transform permissions format, change the format from permissionType->principals to principal->permissionTypes,
* which is used to clearyly dispaly user/group list and their granted permissions in the UI
* original permissions: {
* read: {
* users:['user1']
Expand Down

0 comments on commit c180e87

Please sign in to comment.