feat: release 2.5.1

This commit is contained in:
2026-09-27 10:40:50 +00:00 Unverified
parent 46d97138dc
commit 5f7509a9c5
53 changed files with 2871 additions and 370 deletions
+47
View File
@@ -23,6 +23,53 @@ describe("authorization", () => {
});
describe("memory auth store", () => {
test("maintains the API-key hash index across key mutations", async () => {
const store = new MemoryAuthStore();
await store.putUser({
username: "alice",
passwordHash: "hash",
roles: ["viewer"],
});
const activeHash = hashToken("active-api-key");
const expiredHash = hashToken("expired-api-key");
const activeKey = {
id: "active-key-id-1234",
tokenHash: activeHash,
username: "alice",
capabilities: ["kubernetes:read" as (typeof CAPABILITIES)[number]],
expiresAt: new Date(Date.now() + 60_000).toISOString(),
};
await store.createApiKey(activeKey);
expect(store.apiKeysByTokenHash.get(activeHash)).toBe(
store.apiKeys.get(activeKey.id),
);
expect(await store.getApiKey(activeHash)).toEqual(
store.apiKeys.get(activeKey.id),
);
expect(await store.revokeApiKey("alice", activeKey.id)).toBe(true);
expect(store.apiKeysByTokenHash.has(activeHash)).toBe(false);
expect(await store.getApiKey(activeHash)).toBeUndefined();
const expiredKey = {
...activeKey,
id: "expired-key-id-1234",
tokenHash: expiredHash,
expiresAt: "2020-01-01T00:00:00.000Z",
};
await store.createApiKey(expiredKey);
expect(store.apiKeysByTokenHash.get(expiredHash)).toBe(
store.apiKeys.get(expiredKey.id),
);
expect(await store.deleteExpiredApiKeys()).toBe(1);
expect(store.apiKeysByTokenHash.has(expiredHash)).toBe(false);
await store.createApiKey(activeKey);
expect(await store.deleteUser("alice")).toBe(true);
expect(store.apiKeysByTokenHash.has(activeHash)).toBe(false);
expect(await store.getApiKey(activeHash)).toBeUndefined();
});
test("creates, lists, updates, and deletes users", async () => {
const store = new MemoryAuthStore();
const bob = await store.createUser({