[AAE-9365] - Auth guards should return true when no roles to check are passed (#7695)

This commit is contained in:
Ardit Domi
2022-06-30 09:38:48 +01:00
committed by GitHub
parent e27833d770
commit ad9a468b11
2 changed files with 25 additions and 3 deletions

View File

@@ -51,6 +51,22 @@ describe('UserAccessService', () => {
});
}
it('should return true when no roles to check are passed in global access', async () => {
spyUserAccess(['MOCK_USER_ROLE'], {});
await userAccessService.fetchUserAccess();
const hasGlobalAccess = userAccessService.hasGlobalAccess([]);
expect(hasGlobalAccess).toBe(true);
});
it('should return true when no roles to check are passed in application access', async () => {
spyUserAccess([], { mockApp: { roles: ['MOCK_APP_ROLE'] } });
await userAccessService.fetchUserAccess();
const hasApplicationAccess = userAccessService.hasApplicationAccess('mockApp', []);
expect(hasApplicationAccess).toBe(true);
});
describe('Access from JWT token', () => {
it('should return true when the user has one of the global roles', async () => {