21 lines
1.0 KiB
TypeScript
21 lines
1.0 KiB
TypeScript
// 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");
|
||
});
|
||
});
|