dev/2026-04-08 #1
@@ -1,4 +1,4 @@
|
||||
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
||||
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
hasClientSecret,
|
||||
loadYonexusClientState,
|
||||
saveYonexusClientState,
|
||||
YonexusClientStateCorruptionError,
|
||||
type YonexusClientState
|
||||
} from "../plugin/core/state.js";
|
||||
import { signMessage, verifySignature } from "../plugin/crypto/keypair.js";
|
||||
@@ -81,6 +82,23 @@ describe("Yonexus.Client state store", () => {
|
||||
expect(second.state.privateKey).toBe(first.state.privateKey);
|
||||
expect(second.state.publicKey).toBe(first.state.publicKey);
|
||||
});
|
||||
|
||||
it("SR-06: raises a corruption error for malformed client state files", async () => {
|
||||
const filePath = await createTempStatePath();
|
||||
await saveYonexusClientState(filePath, {
|
||||
...createInitialClientState("client-a"),
|
||||
updatedAt: 1_710_000_000
|
||||
});
|
||||
|
||||
await writeFile(filePath, '{"version":1,"identifier":"client-a","updatedAt":"bad"}\n', "utf8");
|
||||
|
||||
await expect(loadYonexusClientState(filePath, "client-a")).rejects.toBeInstanceOf(
|
||||
YonexusClientStateCorruptionError
|
||||
);
|
||||
await expect(loadYonexusClientState(filePath, "client-a")).rejects.toThrow(
|
||||
"invalid updatedAt"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Yonexus.Client rule registry", () => {
|
||||
|
||||
Reference in New Issue
Block a user