public
anord
read
Ledger
Why work hard when you can work easier?
Languages
Repository composition by tracked source files.
TypeScript
86%
CSS
10%
SQL
3%
Shell
1%
HTML
0%
Trace
apps/api/src/test/rbac.test.ts
Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.
Author
Date
Commit
Line
Code
1
import { describe, expect, it } from "vitest";
2
import { canReadVisibility } from "@ledger/shared";
4
describe("RBAC visibility", () => {
5
const viewer = {
6
id: "user-1",
7
email: "[email protected]",
8
displayName: "Viewer",
9
role: "viewer" as const,
10
groupIds: []
11
};
13
it("allows public pages for anonymous users", () => {
14
expect(canReadVisibility(null, "public")).toBe(true);
15
});
17
it("blocks internal pages for anonymous users", () => {
18
expect(canReadVisibility(null, "internal")).toBe(false);
19
});
21
it("allows restricted pages only when group and role match", () => {
22
expect(canReadVisibility(viewer, "restricted", ["viewer"], ["group-1"])).toBe(false);
23
expect(
24
canReadVisibility({ ...viewer, groupIds: ["group-1"] }, "restricted", ["viewer"], ["group-1"])
25
).toBe(true);
26
});
27
});