From c9c19a1106699bb633b74dd67b89cb771cf4069e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 13 Jun 2026 02:58:02 -0700 Subject: [PATCH] test(models): stabilize plugin auth marker fixtures (#92652) Stabilizes model auth marker tests against the current manifest-metadata discovery seam and isolated Vitest environment. Runtime behavior is unchanged; provider-owned non-secret markers remain declared in plugin manifests. --- src/agents/model-auth-markers.test.ts | 10 ++++++++-- src/agents/model-auth.test.ts | 13 +++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/agents/model-auth-markers.test.ts b/src/agents/model-auth-markers.test.ts index 05a7aec8290..0ec79caefa5 100644 --- a/src/agents/model-auth-markers.test.ts +++ b/src/agents/model-auth-markers.test.ts @@ -2,9 +2,11 @@ * Regression coverage for non-secret model-auth marker helpers. * Verifies core, plugin, env-var, OAuth, AWS, and secret-ref marker handling. */ +import { fileURLToPath } from "node:url"; import { beforeAll, describe, expect, it, vi } from "vitest"; import { withEnv, withEnvAsync } from "../test-utils/env.js"; +const BUNDLED_PLUGINS_DIR = fileURLToPath(new URL("../../extensions/", import.meta.url)); const PLUGIN_MANIFEST_ENV_KEYS = [ "OPENCLAW_BUNDLED_PLUGINS_DIR", "OPENCLAW_DISABLE_BUNDLED_PLUGINS", @@ -14,9 +16,12 @@ const PLUGIN_MANIFEST_ENV_KEYS = [ "OPENCLAW_TEST_MINIMAL_GATEWAY", ] as const; -function cleanPluginManifestEnv(): Record<(typeof PLUGIN_MANIFEST_ENV_KEYS)[number], undefined> { +function cleanPluginManifestEnv(): Record< + (typeof PLUGIN_MANIFEST_ENV_KEYS)[number], + string | undefined +> { return { - OPENCLAW_BUNDLED_PLUGINS_DIR: undefined, + OPENCLAW_BUNDLED_PLUGINS_DIR: BUNDLED_PLUGINS_DIR, OPENCLAW_DISABLE_BUNDLED_PLUGINS: undefined, OPENCLAW_SKIP_PROVIDERS: undefined, OPENCLAW_SKIP_CHANNELS: undefined, @@ -35,6 +40,7 @@ let listKnownNonSecretApiKeyMarkers: typeof import("./model-auth-markers.js").li let resolveOAuthApiKeyMarker: typeof import("./model-auth-markers.js").resolveOAuthApiKeyMarker; async function loadMarkerModules() { + vi.doUnmock("../plugins/manifest-metadata-scan.js"); vi.doUnmock("../plugins/manifest-registry.js"); vi.doUnmock("../secrets/provider-env-vars.js"); vi.resetModules(); diff --git a/src/agents/model-auth.test.ts b/src/agents/model-auth.test.ts index b8631542134..3b47c1ee8ad 100644 --- a/src/agents/model-auth.test.ts +++ b/src/agents/model-auth.test.ts @@ -29,6 +29,19 @@ vi.mock("../plugins/plugin-registry.js", () => ({ }), })); +vi.mock("../plugins/manifest-metadata-scan.js", () => ({ + listOpenClawPluginManifestMetadata: () => [ + { + pluginDir: "/bundled/anthropic-vertex", + origin: "bundled", + manifest: { + id: "anthropic-vertex", + nonSecretAuthMarkers: ["gcp-vertex-credentials"], + }, + }, + ], +})); + vi.mock("../plugins/providers.js", () => ({ resolveOwningPluginIdsForProvider: () => [], resolveOwningPluginIdsForProviderRef: () => [],