Initial upload to Gitea
This commit is contained in:
1 parent
78193254ad
commit
8478998cae
1485 files changed
+461025
-42348
No files matched your search
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
|
||||
// adpanel:remember-lifetime-pin — REMEMBER_LOGIN_MAX_AGE_MS must stay its own
|
||||
// 365-day literal, decoupled from SESSION_MAX_AGE_MS: the tombstone TTL
|
||||
// (370 days) is sized to outlive the longest session/remember lifetime, and
|
||||
// the two lifetimes may only move together by a conscious decision, never by
|
||||
// one being derived from the other. This pin was orphaned when the opt-in
|
||||
// feature's test file was removed and is re-homed here.
|
||||
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
|
||||
const INDEX_PATH = path.join(__dirname, "..", "index.js");
|
||||
const source = fs.readFileSync(INDEX_PATH, "utf8");
|
||||
|
||||
test("REMEMBER_LOGIN_MAX_AGE_MS is a standalone 365-day literal", () => {
|
||||
const decl = source.match(/const REMEMBER_LOGIN_MAX_AGE_MS = ([^;]+);/);
|
||||
assert.ok(decl, "declaration must exist in index.js");
|
||||
assert.equal(
|
||||
decl[1].trim(),
|
||||
"365 * 24 * 60 * 60 * 1000",
|
||||
"must be the literal 365-day expression, not a reference to SESSION_MAX_AGE_MS"
|
||||
);
|
||||
assert.equal(
|
||||
eval(decl[1].trim()), // eslint-disable-line no-eval -- pinned literal, repo-internal
|
||||
365 * 24 * 60 * 60 * 1000
|
||||
);
|
||||
});
|
||||
|
||||
test("remember lifetime is never derived from the session lifetime", () => {
|
||||
// The pre-campaign coupling was `= SESSION_MAX_AGE_MS`; forbid any
|
||||
// reference to the session constant inside the remember declaration.
|
||||
const decl = source.match(/const REMEMBER_LOGIN_MAX_AGE_MS = ([^;]+);/);
|
||||
assert.ok(decl);
|
||||
assert.ok(!decl[1].includes("SESSION_MAX_AGE_MS"));
|
||||
});
|
||||
|
||||
test("remember lifetime stays within the tombstone invariant bound", () => {
|
||||
// Tombstone TTL is 370 days; the remember credential must never outlive it.
|
||||
const decl = source.match(/const REMEMBER_LOGIN_MAX_AGE_MS = ([^;]+);/);
|
||||
assert.ok(decl);
|
||||
assert.ok(eval(decl[1].trim()) <= 370 * 24 * 60 * 60 * 1000); // eslint-disable-line no-eval
|
||||
});
|
||||
Reference in new issue
Block a user