test: harden housekeeping capability context
This commit is contained in:
1 parent
c63c9830b2
commit
7edca410fa
2 files changed
+39
-2
No files matched your search
@@ -65,6 +65,32 @@ describe("housekeeping capability context", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("bypasses meaningful requirements without consulting permission methods", () => {
|
||||
const permissions: PermissionSet = {
|
||||
isSuperAdmin: true,
|
||||
has: vi.fn(() => false),
|
||||
hasAny: vi.fn(() => false),
|
||||
hasAll: vi.fn(() => false),
|
||||
};
|
||||
const context = createHousekeepingCapabilityContext(actor, permissions);
|
||||
|
||||
expect(
|
||||
satisfiesCapability(
|
||||
context,
|
||||
anyCapability("admin.users.view", "admin.logs.view"),
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
satisfiesCapability(
|
||||
context,
|
||||
allCapabilities("admin.users.view", "admin.logs.view"),
|
||||
),
|
||||
).toBe(true);
|
||||
expect(permissions.has).not.toHaveBeenCalled();
|
||||
expect(permissions.hasAny).not.toHaveBeenCalled();
|
||||
expect(permissions.hasAll).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("delegates capability checks without applying rank logic", () => {
|
||||
const permissions: PermissionSet = {
|
||||
isSuperAdmin: false,
|
||||
|
||||
Reference in new issue
Block a user