Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

test(cli): accept opaque Kuna doctor run tokens (#5677)

morluto044f180222d9
diff --git a/tests/boundary/cli/doctorCancellation.test.ts b/tests/boundary/cli/doctorCancellation.test.ts
index 530427dcc..7ebcfeae8 100644
--- a/tests/boundary/cli/doctorCancellation.test.ts
+++ b/tests/boundary/cli/doctorCancellation.test.ts
@@ -40,13 +40,11 @@ cliTest.skipIf(!["darwin", "linux"].includes(process.platform)).for(
const executable =
provider === "kuna" ? join(root, "kuna") : join(jdk, "bin", "java");
const probeArgument = provider === "kuna" ? "--version" : "--list-modules";
- const runIdField =
- provider === "jadx" ? ",runId:process.env.REA_PROCESS_RUN_ID" : "";
await writeFile(
executable,
`#!${process.execPath}
if (!process.argv.slice(2).includes(${JSON.stringify(probeArgument)})) process.exit(7);
-require("node:fs").writeFileSync(${JSON.stringify(ready)}, JSON.stringify({pid: process.pid${runIdField}}));
+require("node:fs").writeFileSync(${JSON.stringify(ready)}, JSON.stringify({pid: process.pid, runId: process.env.REA_PROCESS_RUN_ID}));
process.on("SIGTERM", () => {});
setInterval(() => { if (require("node:fs").existsSync(${JSON.stringify(release)})) process.exit(0); }, 25).unref();
setTimeout(() => process.exit(99), 20000);
@@ -97,7 +95,10 @@ setTimeout(() => process.exit(99), 20000);
)
.toBe(true);
const readyRecord: unknown = JSON.parse(await readFile(ready, "utf8"));
- const observed: { readonly pid: number; readonly runId?: string } =
+ // JADX publishes a UUID. Kuna publishes an opaque
+ // `rea-kuna-version-<uuid>` token. Both are required: JSON.stringify
+ // drops an undefined REA_PROCESS_RUN_ID, and that omission must fail.
+ const observed =
provider === "jadx"
? z
.strictObject({
@@ -106,11 +107,12 @@ setTimeout(() => process.exit(99), 20000);
})
.parse(readyRecord)
: z
- .strictObject({ pid: z.number().int().positive() })
+ .strictObject({
+ pid: z.number().int().positive(),
+ runId: z.string().min(1),
+ })
.parse(readyRecord);
if (provider === "jadx") {
- if (observed.runId === undefined)
- throw new Error("Missing JADX run token");
ownership = {
leaderPid: observed.pid,
processGroupId: observed.pid,
@@ -131,8 +133,7 @@ setTimeout(() => process.exit(99), 20000);
state: "empty",
});
} else {
- // Kuna's version probe uses a joined direct execFile child, without a
- // detached run-token group. Do not invent a group owner from its PID.
+ // Do not invent a group owner from the probe PID.
expect(() => process.kill(observed.pid, 0)).toThrowError(
expect.objectContaining({ code: "ESRCH" }),
);