21 lines
727 B
TypeScript
21 lines
727 B
TypeScript
import assert from "node:assert/strict";
|
|||
|
|
import { describe, it } from "node:test";
|
||
|
|
import { canManageApiKeys } from "./api-key-permissions.ts";
|
||
|
|
|
||
|
|
describe("API key management permissions", () => {
|
||
|
|
it("allows a non-admin with both API Keys and API access", () => {
|
||
|
|
assert.equal(canManageApiKeys(false, true, true), true);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("rejects a non-admin without the API Keys permission", () => {
|
||
|
|
assert.equal(canManageApiKeys(false, false, true), false);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("rejects a non-admin without the company API entitlement", () => {
|
||
|
|
assert.equal(canManageApiKeys(false, true, false), false);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("keeps preexisting company-admin UI access", () => {
|
||
|
|
assert.equal(canManageApiKeys(true, false, false), true);
|
||
|
|
});
|
||
|
|
});
|