refactor: dedupe pending pairing request flow and add reuse tests

This commit is contained in:
Peter Steinberger
2026-02-19 13:54:35 +00:00
parent d900d5efbd
commit 7a89049d1d
5 changed files with 117 additions and 51 deletions

View File

@@ -28,6 +28,28 @@ async function setupPairedNode(baseDir: string): Promise<string> {
}
describe("node pairing tokens", () => {
test("reuses existing pending requests for the same node", async () => {
const baseDir = await mkdtemp(join(tmpdir(), "openclaw-node-pairing-"));
const first = await requestNodePairing(
{
nodeId: "node-1",
platform: "darwin",
},
baseDir,
);
const second = await requestNodePairing(
{
nodeId: "node-1",
platform: "darwin",
},
baseDir,
);
expect(first.created).toBe(true);
expect(second.created).toBe(false);
expect(second.request.requestId).toBe(first.request.requestId);
});
test("generates base64url node tokens with 256-bit entropy output length", async () => {
const baseDir = await mkdtemp(join(tmpdir(), "openclaw-node-pairing-"));
const token = await setupPairedNode(baseDir);