- Accounts: account and admin pages in Cross Events' layout (top bar, sidebar, a page per section, dark footer); quick links to the church's sites (GET /me/apps); nightly pg_dump backups with Admin -> Backups (run, keep, download, audited; heartbeat lastBackupAt); a fuller built-in privacy notice with headings and bullets; a fixed favicon. /backups/ ignored (anchored, so src/backups is kept). - Contracts 1.11.0: people.removeDemo (only @example.com, never an admin). - Events: uploads served from the folder they're saved in (a backend started outside backend/ answered 404 for a logo it had just saved); Branding checks the file loads before saving; logout waits for the sign-out call so Accounts signs out too; set-demo removes the last demo's people from Accounts. Tests: Accounts 62 + e2e 8, Events 782, contracts 225; npm run check passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
2.9 KiB
TypeScript
54 lines
2.9 KiB
TypeScript
import { identityRequestSchema, importPersonSchema, sealedValueSchema } from "../src";
|
|
import { newLinkSecret, openLinkValue, sealLinkValue } from "../src/signing";
|
|
import { sample } from "./helpers";
|
|
|
|
describe("crosscode.identity-request/1", () => {
|
|
test("a sealed value opens with the same link secret, and only that one", () => {
|
|
const secret = newLinkSecret();
|
|
const hash = "$2b$10$abcdefghijklmnopqrstuuJt1Yx0H1iLx3m6nS6m1j0fDqv3p4q5W";
|
|
const sealed = sealLinkValue(secret, hash);
|
|
expect(sealedValueSchema.safeParse(sealed).success).toBe(true);
|
|
expect(sealed).not.toContain("abcdefghij");
|
|
expect(openLinkValue(secret, sealed)).toBe(hash);
|
|
expect(() => openLinkValue(newLinkSecret(), sealed)).toThrow();
|
|
const tampered = sealed.slice(0, -2) + (sealed.endsWith("A") ? "BB" : "AA");
|
|
expect(() => openLinkValue(secret, tampered)).toThrow();
|
|
});
|
|
|
|
test("import.finish lists the subs (uuids)", () => {
|
|
const finish = sample<{ subs: string[] }>("import-finish.json");
|
|
expect(identityRequestSchema.safeParse(finish).success).toBe(true);
|
|
expect(identityRequestSchema.safeParse({ ...finish, subs: ["not-a-uuid"] }).success).toBe(false);
|
|
});
|
|
|
|
test("an unsealed password hash is refused", () => {
|
|
const person = sample<{ people: Record<string, unknown>[] }>("import-batch.json").people[0]!;
|
|
expect(importPersonSchema.safeParse(person).success).toBe(true);
|
|
expect(importPersonSchema.safeParse({ ...person, passwordHash: "$2b$10$plain" }).success).toBe(false);
|
|
});
|
|
|
|
test("a batch is at most 200 people", () => {
|
|
const batch = sample<{ people: unknown[] }>("import-batch.json");
|
|
const many = { ...batch, people: Array.from({ length: 201 }, () => batch.people[0]) };
|
|
expect(identityRequestSchema.safeParse(many).success).toBe(false);
|
|
});
|
|
|
|
test("messaging.set needs the password sealed, or null to keep the saved one", () => {
|
|
const set = sample<{ email: { settings: Record<string, unknown> } }>("messaging-set.json");
|
|
expect(identityRequestSchema.safeParse(set).success).toBe(true);
|
|
expect(identityRequestSchema.safeParse({ ...set, email: { ...set.email, settings: { ...set.email.settings, pass: null } } }).success).toBe(true);
|
|
expect(identityRequestSchema.safeParse({ ...set, email: { ...set.email, settings: { ...set.email.settings, pass: "plain-password" } } }).success).toBe(false);
|
|
});
|
|
|
|
test("people.removeDemo: at most 1000 accounts at a time", () => {
|
|
const r = sample<{ subs: string[] }>("people-remove-demo.json");
|
|
expect(identityRequestSchema.safeParse(r).success).toBe(true);
|
|
expect(identityRequestSchema.safeParse({ ...r, subs: Array.from({ length: 1001 }, () => r.subs[0]) }).success).toBe(false);
|
|
expect(identityRequestSchema.safeParse({ ...r, subs: ["not-an-id"] }).success).toBe(false);
|
|
});
|
|
|
|
test("unknown request types are refused", () => {
|
|
expect(identityRequestSchema.safeParse({ ...sample("people-ensure.json"), type: "people.delete" }).success).toBe(false);
|
|
});
|
|
});
|