mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
21 lines
861 B
TypeScript
21 lines
861 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { hasPermission } from './usePermissions';
|
|
|
|
describe('hasPermission', () => {
|
|
it('grants everything to a wildcard holder', () => {
|
|
expect(hasPermission(['*'], 'ext.votes.view')).toBe(true);
|
|
});
|
|
|
|
it('matches group wildcards only within that group', () => {
|
|
expect(hasPermission(['file.read'], 'file.*')).toBe(true);
|
|
expect(hasPermission(['ext.votes.view'], 'ext.votes.*')).toBe(true);
|
|
expect(hasPermission(['ext.polls.view'], 'ext.votes.*')).toBe(false);
|
|
expect(hasPermission(['control.console'], 'file.*')).toBe(false);
|
|
});
|
|
|
|
it('requires an exact grant otherwise', () => {
|
|
expect(hasPermission(['ext.votes.view'], 'ext.votes.view')).toBe(true);
|
|
expect(hasPermission(['ext.votes.view'], 'ext.votes.reset')).toBe(false);
|
|
});
|
|
});
|