Skip to content

Commit

Permalink
fix(rbac): log when plugin has no permissions (#1917)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzemanov authored Aug 2, 2024
1 parent 3d669d2 commit cc8752b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/rbac-backend/src/service/plugin-endpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('plugin-endpoint', () => {
]);
});

it('should skip not found error for not found endpoint', async () => {
it('should log warning for not found endpoint', async () => {
backendPluginIDsProviderMock.getPluginIds.mockReturnValue([
'permission',
'unknown-plugin-id',
Expand All @@ -145,6 +145,7 @@ describe('plugin-endpoint', () => {
'{"permissions":[{"type":"resource","resourceType":"policy-entity","name":"policy.entity.read","attributes":{"action":"read"}}]}',
);

const errorSpy = jest.spyOn(logger, 'warn').mockClear();
const collector = new PluginPermissionMetadataCollector(
mockPluginEndpointDiscovery,
backendPluginIDsProviderMock,
Expand All @@ -162,6 +163,10 @@ describe('plugin-endpoint', () => {
policy: 'read',
},
]);

expect(errorSpy).toHaveBeenCalledWith(
'No permission metadata found for unknown-plugin-id. NotFoundError',
);
});

it('should log error when it is not possible to retrieve permission metadata for known endpoint', async () => {
Expand Down
3 changes: 3 additions & 0 deletions plugins/rbac-backend/src/service/plugin-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ export class PluginPermissionMetadataCollector {
}
} catch (err) {
if (isError(err) && err.name === 'NotFoundError') {
this.logger.warn(
`No permission metadata found for ${pluginId}. ${err}`,
);
return undefined;
}
this.logger.error(
Expand Down

0 comments on commit cc8752b

Please sign in to comment.