Skip to content

Commit

Permalink
Remove getPrincipalsOfObjects in permission
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Wang <wonglam@amazon.com>
  • Loading branch information
wanglam committed Mar 5, 2024
1 parent 6e28b92 commit e09342a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 48 deletions.
34 changes: 0 additions & 34 deletions src/plugins/workspace/server/permission_control/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,6 @@ describe('PermissionControl', () => {
users: ['bar'],
}));
const mockAuth = httpServiceMock.createAuth();
it('should return principals when calling getPrincipalsOfObjects', async () => {
const permissionControlClient = new SavedObjectsPermissionControl(loggerMock.create());
const getScopedClient = jest.fn();
getScopedClient.mockImplementation((request) => {
const clientMock = savedObjectsClientMock.create();
clientMock.bulkGet.mockResolvedValue({
saved_objects: [
{
id: 'foo',
permissions: {
read: {
users: ['foo_user'],
},
},
},
],
});
return clientMock;
});
permissionControlClient.setup(getScopedClient, mockAuth);
const result = await permissionControlClient.getPrincipalsOfObjects(
httpServerMock.createOpenSearchDashboardsRequest(),
[]
);
expect(result).toEqual({
foo: [
{
type: 'users',
name: 'foo_user',
permissions: ['read'],
},
],
});
});

it('validate should return error when no saved objects can be found', async () => {
const permissionControlClient = new SavedObjectsPermissionControl(loggerMock.create());
Expand Down
13 changes: 0 additions & 13 deletions src/plugins/workspace/server/permission_control/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,4 @@ export class SavedObjectsPermissionControl {
result: hasPermissionToAllObjects,
};
}

public async getPrincipalsOfObjects(
request: OpenSearchDashboardsRequest,
savedObjects: SavedObjectsBulkGetObject[]
): Promise<Record<string, TransformedPermission>> {
const detailedSavedObjects = await this.bulkGetSavedObjects(request, savedObjects);
return detailedSavedObjects.reduce((total, current) => {
return {
...total,
[current.id]: new ACL(current.permissions).toFlatList(),
};
}, {});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const generateWorkspaceSavedObjectsClientWrapper = () => {
}),
validateSavedObjectsACL: jest.fn(),
batchValidate: jest.fn(),
getPrincipalsOfObjects: jest.fn(),
getPrincipalsFromRequest: jest.fn().mockImplementation(() => ({ users: ['user-1'] })),
};
const wrapper = new WorkspaceSavedObjectsClientWrapper(permissionControlMock);
Expand Down

0 comments on commit e09342a

Please sign in to comment.