test(secrets): trust source plugin contracts in coverage

This commit is contained in:
Vincent Koc
2026-05-05 15:29:51 -07:00
parent add9a49c40
commit 1ff07517b0
2 changed files with 49 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import { beforeAll, describe, expect, it, vi } from "vitest";
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import type { AuthProfileStore } from "../agents/auth-profiles.js";
import type { OpenClawConfig } from "../config/config.js";
import type { PluginOrigin } from "../plugins/types.js";
@@ -70,6 +70,24 @@ let collectConfigAssignments: typeof import("./runtime-config-collectors.js").co
let createResolverContext: typeof import("./runtime-shared.js").createResolverContext;
let resolveSecretRefValues: typeof import("./resolve.js").resolveSecretRefValues;
let resolveRuntimeWebTools: typeof import("./runtime-web-tools.js").resolveRuntimeWebTools;
const previousBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
const previousTrustBundledPluginsDir = process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR;
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR ??= "extensions";
process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR ??= "1";
afterAll(() => {
if (previousBundledPluginsDir === undefined) {
delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
} else {
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = previousBundledPluginsDir;
}
if (previousTrustBundledPluginsDir === undefined) {
delete process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR;
} else {
process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR = previousTrustBundledPluginsDir;
}
});
async function ensureConfigCoverageRuntimeLoaded(): Promise<void> {
if (!collectConfigAssignments) {
@@ -317,6 +335,16 @@ function applyConfigForOpenClawTarget(
"https://example.com/hook",
);
}
if (entry.id === "channels.qqbot.clientSecret") {
setPathCreateStrict(config, ["channels", "qqbot", "appId"], "sample-app-id");
}
if (entry.id === "channels.qqbot.accounts.*.clientSecret") {
setPathCreateStrict(
config,
["channels", "qqbot", "accounts", wildcardToken, "appId"],
"sample-app-id",
);
}
if (entry.id === "channels.feishu.verificationToken") {
setPathCreateStrict(config, ["channels", "feishu", "connectionMode"], "webhook");
}

View File

@@ -1,6 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { afterAll, describe, expect, it } from "vitest";
import {
buildSecretRefCredentialMatrix,
type SecretRefCredentialMatrixDocument,
@@ -10,6 +10,25 @@ function buildSecretRefCredentialMatrixJson(): string {
return `${JSON.stringify(buildSecretRefCredentialMatrix(), null, 2)}\n`;
}
const previousBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
const previousTrustBundledPluginsDir = process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR;
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR ??= "extensions";
process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR ??= "1";
afterAll(() => {
if (previousBundledPluginsDir === undefined) {
delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
} else {
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = previousBundledPluginsDir;
}
if (previousTrustBundledPluginsDir === undefined) {
delete process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR;
} else {
process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR = previousTrustBundledPluginsDir;
}
});
describe("secret target registry docs", () => {
it("stays in sync with docs/reference/secretref-user-supplied-credentials-matrix.json", () => {
const pathname = path.join(