style: format code with prettier
Local Build and Deploy / deploy (push) Successful in 49s

This commit is contained in:
openhands committed 2026-07-12 21:07:34 +02:00
1 parent e85e4d74ea
commit 2e4ed76121
378 files changed
+22404 -20686

No files matched your search

+27 -5
View File
@@ -2,7 +2,11 @@ import { describe, expect, it } from "vitest";
import { decideAuthorization, isDynamicSuperAdmin } from "@/lib/admin/authorization-policy";
describe("isDynamicSuperAdmin", () => {
it.each([[7, 7], [11, 11], [2000, 2000]])("accepts highest rank %i", (rank, highest) => {
it.each([
[7, 7],
[11, 11],
[2000, 2000],
])("accepts highest rank %i", (rank, highest) => {
expect(isDynamicSuperAdmin(rank, highest)).toBe(true);
});
it("demotes the previous highest rank", () => expect(isDynamicSuperAdmin(2000, 2001)).toBe(false));
@@ -11,8 +15,26 @@ describe("isDynamicSuperAdmin", () => {
describe("decideAuthorization", () => {
const actor = { id: 1, username: "admin", rank: 11 };
it("allows the dynamically highest rank", () => expect(decideAuthorization({ actor, highestRank: 11, permission: "admin.any", hasPermission: false }).allowed).toBe(true));
it("allows explicit ACL permission below highest", () => expect(decideAuthorization({ actor, highestRank: 12, permission: "admin.news.view", hasPermission: true }).allowed).toBe(true));
it("denies invalid ranks", () => expect(decideAuthorization({ actor: { ...actor, rank: 0 }, highestRank: 11, permission: "admin.any", hasPermission: true })).toMatchObject({ allowed: false, reason: "invalid_rank" }));
it("denies missing permission", () => expect(decideAuthorization({ actor, highestRank: 12, permission: "admin.any", hasPermission: false })).toMatchObject({ allowed: false, reason: "permission_denied" }));
it("allows the dynamically highest rank", () =>
expect(
decideAuthorization({ actor, highestRank: 11, permission: "admin.any", hasPermission: false }).allowed,
).toBe(true));
it("allows explicit ACL permission below highest", () =>
expect(
decideAuthorization({ actor, highestRank: 12, permission: "admin.news.view", hasPermission: true })
.allowed,
).toBe(true));
it("denies invalid ranks", () =>
expect(
decideAuthorization({
actor: { ...actor, rank: 0 },
highestRank: 11,
permission: "admin.any",
hasPermission: true,
}),
).toMatchObject({ allowed: false, reason: "invalid_rank" }));
it("denies missing permission", () =>
expect(
decideAuthorization({ actor, highestRank: 12, permission: "admin.any", hasPermission: false }),
).toMatchObject({ allowed: false, reason: "permission_denied" }));
});