GitHub(nextgroup2706/ken_nogi)は今後使わず自社Gitea運用に切替え。 NodeSrvは旧リポジトリの履歴を破棄しファイルのみ統合(Dokploy用サービスアカウントは 別途mygit-admin/NodeSrv.gitに履歴あり)。notepmエクスポート(12GB)とPleasanter インストーラzip(208MB)はサイズが大きいため.gitignoreで除外。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
26 lines
1.4 KiB
JavaScript
26 lines
1.4 KiB
JavaScript
const { test } = require("node:test");
|
|
const assert = require("node:assert");
|
|
const { createState, verifyState } = require("../src/lib/oauthState");
|
|
|
|
const SECRET = "test-secret";
|
|
|
|
test("createState then verifyState round-trips key and account", () => {
|
|
const now = () => new Date("2026-08-24T00:00:00.000Z").getTime();
|
|
const state = createState({ key: "lineworks-form-sync", account: "svc@example.co.jp", secret: SECRET, now });
|
|
const data = verifyState({ state, secret: SECRET, now });
|
|
assert.deepStrictEqual(data, { key: "lineworks-form-sync", account: "svc@example.co.jp" });
|
|
});
|
|
|
|
test("verifyState returns null when the signature does not match (tampered state)", () => {
|
|
const state = createState({ key: "lineworks-form-sync", account: "svc@example.co.jp", secret: SECRET });
|
|
const tampered = state.slice(0, -1) + (state.at(-1) === "0" ? "1" : "0");
|
|
assert.strictEqual(verifyState({ state: tampered, secret: SECRET }), null);
|
|
});
|
|
|
|
test("verifyState returns null when the state is older than maxAgeMs", () => {
|
|
const issuedAt = () => new Date("2026-08-24T00:00:00.000Z").getTime();
|
|
const state = createState({ key: "lineworks-form-sync", account: "svc@example.co.jp", secret: SECRET, now: issuedAt });
|
|
const later = () => issuedAt() + 11 * 60 * 1000;
|
|
assert.strictEqual(verifyState({ state, secret: SECRET, maxAgeMs: 10 * 60 * 1000, now: later }), null);
|
|
});
|