import assert from "node:assert/strict"; import { test } from "node:test"; import { assertProductionSecret, isPlaceholderSecret } from "../src/runtime-config.js"; test("production rejects missing or short session secrets", () => { assert.throws(() => assertProductionSecret(undefined, "production"), /至少 32 位/); assert.throws(() => assertProductionSecret("short-secret", "production"), /至少 32 位/); }); test("production rejects example placeholder secrets", () => { assert.throws( () => assertProductionSecret("replace-with-at-least-32-random-characters", "production"), /示例占位符/, ); assert.throws( () => assertProductionSecret("change-me-now-1234567890-abcdefghij", "production"), /示例占位符/, ); }); test("production accepts a strong random secret", () => { assert.doesNotThrow(() => assertProductionSecret("s3cure-Random-Value-0123456789-abcdefghij", "production"), ); }); test("development keeps working with the example placeholder", () => { assert.doesNotThrow(() => assertProductionSecret("replace-with-a-long-random-value", "development"), ); }); test("placeholder detection covers documented example values", () => { assert.equal(isPlaceholderSecret("replace-with-a-long-random-value"), true); assert.equal(isPlaceholderSecret(" YOur-secret-value "), true); assert.equal(isPlaceholderSecret("s3cure-Random-Value-0123456789-abcdefghij"), false); });