Skip to content

armgit / rea

Public Imported from GitHub
0

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

test(mcp): isolate target-free sessions from host provider discovery

morluto28f57619738e
diff --git a/tests/boundary/mcp/sessionMcp.test.ts b/tests/boundary/mcp/sessionMcp.test.ts
index 2c3627502..0bad24e57 100644
--- a/tests/boundary/mcp/sessionMcp.test.ts
+++ b/tests/boundary/mcp/sessionMcp.test.ts
@@ -217,6 +217,33 @@ describe("public provider availability", () => {
});
});
+describe("target-free MCP fixture host isolation", () => {
+ it("uses fixed unavailable ports instead of probing installed Android tools", async () => {
+ directory = await createTestTempDirectory("rea-mcp-host-isolation-");
+ const { mcp } = await createSessionMcpHarness(
+ directory,
+ provider,
+ resources,
+ );
+
+ const status = structured(
+ await mcp.callTool({ name: "binary_session", arguments: {} }),
+ );
+ const availability = toolAvailabilityInventory.parse(
+ (status.result as { tool_availability: unknown }).tool_availability,
+ );
+ for (const name of [
+ "inspect_android_package",
+ "inspect_adb_client",
+ "inspect_apktool_client",
+ ]) {
+ expect(
+ availability.groups.find((group) => group.names.includes(name)),
+ ).toMatchObject({ available: false, reason: "provider_missing" });
+ }
+ });
+});
+
describe("target-free MCP lifecycle", () => {
it("takes the session snapshot after Android readiness inspection completes", async () => {
directory = await createTestTempDirectory("rea-mcp-status-readiness-");
diff --git a/tests/boundary/mcp/sessionMcpHarness.ts b/tests/boundary/mcp/sessionMcpHarness.ts
index 45f298c76..f1bca7b54 100644
--- a/tests/boundary/mcp/sessionMcpHarness.ts
+++ b/tests/boundary/mcp/sessionMcpHarness.ts
@@ -10,6 +10,10 @@ import { z } from "zod";
import { createTestBinarySession } from "../../fixtures/binarySession.js";
import { createAnalysisProfile } from "../../../src/domain/analysisProfile.js";
import { createEvidence } from "../../../src/domain/evidence.js";
+import type { ProviderAvailability } from "../../../src/application/AnalysisProvider.js";
+import type { AndroidAnalysisPort } from "../../../src/application/android/AndroidAnalysisPort.js";
+import type { AdbDeviceAnalysisPort } from "../../../src/application/adb/AdbDeviceAnalysisPort.js";
+import type { ApktoolResourceAnalysisPort } from "../../../src/application/apktool/ApktoolResourceAnalysisPort.js";
import {
createEvidenceBundle,
evidenceBundleSchema,
@@ -24,6 +28,38 @@ const SNAPSHOT_PROFILE = createAnalysisProfile(
{ fixture: true },
);
+const HOST_TOOLS_NOT_CONFIGURED: ProviderAvailability = {
+ status: "unavailable",
+ code: "not_configured",
+ reason: "The target-free MCP fixture does not probe host tools.",
+ diagnostics: { source: "test_fixture" },
+};
+
+const unusedHostToolExecution = async (): Promise<never> => {
+ throw new Error("Host-tool execution is outside the target-free fixture");
+};
+
+// These fixed ports keep this fake-session harness independent of whichever
+// Android tools happen to be installed on the test host. The dedicated public
+// availability test below continues to exercise status projection separately.
+const androidAnalysis: AndroidAnalysisPort = {
+ inspectAvailability: async () => HOST_TOOLS_NOT_CONFIGURED,
+ close: async () => {},
+ execute: unusedHostToolExecution,
+};
+
+const adbDeviceAnalysis: AdbDeviceAnalysisPort = {
+ inspectAvailability: async () => HOST_TOOLS_NOT_CONFIGURED,
+ close: async () => {},
+ execute: unusedHostToolExecution,
+};
+
+const apktoolAnalysis: ApktoolResourceAnalysisPort = {
+ inspectAvailability: async () => HOST_TOOLS_NOT_CONFIGURED,
+ close: async () => {},
+ execute: unusedHostToolExecution,
+};
+
export interface SessionMcpHarness {
readonly mcp: Client;
readonly first: string;
@@ -47,6 +83,9 @@ export const createSessionMcpHarness = async (
const server = createServer(
{ kind: "session", session },
{
+ androidAnalysis,
+ adbDeviceAnalysis,
+ apktoolAnalysis,
logger: silentLogger,
},
);