Files
edgeever/apps/api/src/share-password.test.mjs
T
tianma-if dcfd11468d feat(sharing): add optional password protection for public note shares
Allow owners to turn on an auto-generated access password when sharing a note. Visitors must unlock the share page before reading the note or its attachments; existing public links stay open until a password is enabled.
2026-09-17 14:44:43 +08:00

16 lines
693 B
JavaScript

import { describe, expect, test } from "bun:test";
import { generateSharePassword, SHARE_PASSWORD_ALPHABET, SHARE_PASSWORD_LENGTH } from "./share-password.ts";
describe("generateSharePassword", () => {
test("returns an unambiguous password of the expected length", () => {
const password = generateSharePassword();
expect(password).toHaveLength(SHARE_PASSWORD_LENGTH);
expect([...password].every((character) => SHARE_PASSWORD_ALPHABET.includes(character))).toBe(true);
});
test("does not repeat the same password across draws", () => {
const passwords = new Set(Array.from({ length: 20 }, () => generateSharePassword()));
expect(passwords.size).toBe(20);
});
});