Skip to content

armgit / rea

Public Imported from GitHub
0

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

fix(adb): share host configuration refusals with apktool (#1954)

Kaoru082239418ea17376
diff --git a/tests/boundary/cli/adbCli.test.ts b/tests/boundary/cli/adbCli.test.ts
index 26d376977..f36166780 100644
--- a/tests/boundary/cli/adbCli.test.ts
+++ b/tests/boundary/cli/adbCli.test.ts
@@ -1,6 +1,9 @@
import { expect, it } from "vitest";
-import { serveCli as serve } from "./cliServeHarness.js";
+import {
+ expectConfigurationRefusal,
+ serveCli as serve,
+} from "./cliServeHarness.js";
it.each([
["inspect-adb-client"],
@@ -35,25 +38,26 @@ it.each([
});
it.each([
- ["inspect-adb-client", "/nonexistent/adb", "not found"],
- ["list-adb-devices", "relative/adb", "absolute path"],
+ [
+ ["inspect-adb-client", "--json"],
+ "/nonexistent/adb",
+ "The selected adb binary was not found: /nonexistent/adb. Set REA_ADB_PATH",
+ ],
+ [
+ ["list-adb-devices", "--json"],
+ "/nonexistent/adb",
+ "The selected adb binary was not found: /nonexistent/adb. Set REA_ADB_PATH",
+ ],
+ [
+ ["list-adb-devices", "--json"],
+ "relative/adb",
+ "REA_ADB_PATH must be an absolute path to the adb binary.",
+ ],
])(
- "%s names the adb configuration requirement",
- async (command, binary, cause) => {
- const result = await serve([command, "--json"], {
- REA_ADB_PATH: binary,
- });
- const output = JSON.parse(result.stdout) as {
- code?: unknown;
- message?: unknown;
- remediation?: { action?: unknown };
- };
- expect(output.code).toBe("capability_unavailable");
- expect(output.message).toEqual(expect.stringContaining(cause));
- expect(output.message).toEqual(expect.stringContaining("REA_ADB_PATH"));
- expect(output.remediation?.action).toEqual(
- expect.stringContaining("REA_ADB_PATH"),
- );
+ "%j with REA_ADB_PATH=%s names the host requirement",
+ async (argv, binary, reason) => {
+ const result = await serve(argv, { REA_ADB_PATH: binary });
+ expectConfigurationRefusal(result, reason);
},
);
diff --git a/tests/boundary/cli/apktoolCli.test.ts b/tests/boundary/cli/apktoolCli.test.ts
index e3415e6f0..f52855b78 100644
--- a/tests/boundary/cli/apktoolCli.test.ts
+++ b/tests/boundary/cli/apktoolCli.test.ts
@@ -1,6 +1,9 @@
import { expect, it } from "vitest";
-import { serveCli as serve } from "./cliServeHarness.js";
+import {
+ expectConfigurationRefusal,
+ serveCli as serve,
+} from "./cliServeHarness.js";
it.each(["inspect-apktool-client", "decode-android-resources"])(
"%s advertises a schema through the public CLI",
@@ -32,15 +35,7 @@ it.each([
"%j with REA_APKTOOL_COMMAND=%s names the host requirement",
async (argv, command, reason) => {
const result = await serve(argv, { REA_APKTOOL_COMMAND: command });
- const output = JSON.parse(result.stdout) as {
- code?: unknown;
- message?: unknown;
- remediation?: { action?: unknown };
- };
- expect(output.code).toBe("capability_unavailable");
- // The target is not the problem; the refusal must say what to configure.
- expect(output.message).toEqual(expect.stringContaining(reason));
- expect(output.remediation?.action).toEqual(expect.stringContaining(reason));
+ expectConfigurationRefusal(result, reason);
},
);
diff --git a/tests/boundary/cli/cliServeHarness.ts b/tests/boundary/cli/cliServeHarness.ts
index 35676e842..827d1c3e3 100644
--- a/tests/boundary/cli/cliServeHarness.ts
+++ b/tests/boundary/cli/cliServeHarness.ts
@@ -1,3 +1,5 @@
+import { expect } from "vitest";
+
import { createCli } from "../../../src/cli.js";
/** Captured CLI invocation for boundary tests. */
@@ -25,3 +27,18 @@ export const serveCli = async (
});
return { stdout, exitCode };
};
+
+/** A host tool configuration refusal names what to configure, not the target. */
+export const expectConfigurationRefusal = (
+ result: ServedCli,
+ reason: string,
+): void => {
+ const output = JSON.parse(result.stdout) as {
+ code?: unknown;
+ message?: unknown;
+ remediation?: { action?: unknown };
+ };
+ expect(output.code).toBe("capability_unavailable");
+ expect(output.message).toEqual(expect.stringContaining(reason));
+ expect(output.remediation?.action).toEqual(expect.stringContaining(reason));
+};