peppa/packages/testkit/test/logout-all.test.ts
Асель feeeb908e5 PEP-95: peppa web logout-all — every web session issued before the cut-off ends
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:00:05 +05:00

21 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// PEP-95: «выкинуть всех» — web sessions issued before the cut-off stop working.
import assert from "node:assert/strict";
import { after, describe, test } from "node:test";
import { core, db, teardown } from "./helpers.ts";
after(teardown);
describe("PEP-95: logout of every user", () => {
test("no cut-off by default; after logout-all, older sessions are invalid and new ones work", async () => {
assert.equal(await core.sessionsValidAfter(db), null);
const at = await core.logoutAllUsers(db, new Date("2026-11-15T10:00:00Z"));
const after = (await core.sessionsValidAfter(db))!;
assert.equal(after, at.getTime());
// The web's rule (apps/web/lib/auth.ts): issuedAt = exp − 30 days must not be before the cut-off.
const DAYS = 30 * 86400_000;
const valid = (issuedAt: number) => !(issuedAt + DAYS - DAYS < after);
assert.equal(valid(at.getTime() - 60_000), false, "a session from before is out");
assert.equal(valid(at.getTime() + 60_000), true, "signing in again works");
});
});