Address Greptile review on board CLI auth

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta 2026-03-23 08:45:56 -05:00
parent 01b6b7e66a
commit 7f9a76411a
9 changed files with 207 additions and 54 deletions

View file

@ -198,4 +198,34 @@ describe("applyPendingMigrations", () => {
},
20_000,
);
it(
"enforces a unique board_api_keys.key_hash after migration 0044",
async () => {
const connectionString = await createTempDatabase();
await applyPendingMigrations(connectionString);
const sql = postgres(connectionString, { max: 1, onnotice: () => {} });
try {
await sql.unsafe(`
INSERT INTO "user" ("id", "name", "email", "email_verified", "created_at", "updated_at")
VALUES ('user-1', 'User One', 'user@example.com', true, now(), now())
`);
await sql.unsafe(`
INSERT INTO "board_api_keys" ("id", "user_id", "name", "key_hash", "created_at")
VALUES ('00000000-0000-0000-0000-000000000001', 'user-1', 'Key One', 'dup-hash', now())
`);
await expect(
sql.unsafe(`
INSERT INTO "board_api_keys" ("id", "user_id", "name", "key_hash", "created_at")
VALUES ('00000000-0000-0000-0000-000000000002', 'user-1', 'Key Two', 'dup-hash', now())
`),
).rejects.toThrow();
} finally {
await sql.end();
}
},
20_000,
);
});