test(mvp0): complete remaining i18n, RBAC, and CRUD coverage
This commit is contained in:
@@ -28,4 +28,31 @@ describe("rbac model", () => {
|
||||
expect(permissionMatrix.editor.length).toBeGreaterThan(0)
|
||||
expect(permissionMatrix.manager.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
it("prevents privilege escalation for non-admin roles", () => {
|
||||
expect(hasPermission("editor", "users:manage_roles", "global")).toBe(false)
|
||||
expect(hasPermission("manager", "users:manage_roles", "global")).toBe(false)
|
||||
expect(hasPermission("editor", "dashboard:read", "global")).toBe(true)
|
||||
})
|
||||
|
||||
it("keeps role policy regressions visible for critical permissions", () => {
|
||||
const criticalChecks: Array<{
|
||||
role: "owner" | "support" | "admin" | "manager" | "editor"
|
||||
permission: Parameters<typeof hasPermission>[1]
|
||||
scope: Parameters<typeof hasPermission>[2]
|
||||
allowed: boolean
|
||||
}> = [
|
||||
{ role: "owner", permission: "users:manage_roles", scope: "global", allowed: true },
|
||||
{ role: "support", permission: "users:manage_roles", scope: "global", allowed: true },
|
||||
{ role: "admin", permission: "banner:write", scope: "global", allowed: true },
|
||||
{ role: "manager", permission: "users:write", scope: "global", allowed: false },
|
||||
{ role: "manager", permission: "users:write", scope: "team", allowed: true },
|
||||
{ role: "editor", permission: "news:publish", scope: "team", allowed: false },
|
||||
{ role: "editor", permission: "news:publish", scope: "own", allowed: true },
|
||||
]
|
||||
|
||||
for (const check of criticalChecks) {
|
||||
expect(hasPermission(check.role, check.permission, check.scope)).toBe(check.allowed)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user