

























@@ -4,6 +4,7 @@ import path from "node:path";
44import { PassThrough } from "node:stream";
55import { beforeEach, describe, expect, it, vi } from "vitest";
66import { installScheduledTask, readScheduledTaskCommand } from "./schtasks.js";
7+import { auditGatewayServiceConfig, SERVICE_AUDIT_CODES } from "./service-audit.js";
7889const schtasksCalls: string[][] = [];
910const schtasksResponses: { code: number; stdout: string; stderr: string }[] = [];
@@ -243,4 +244,35 @@ describe("installScheduledTask", () => {
243244expect(script).toContain('set "OPENCLAW_GATEWAY_PORT=18789"');
244245});
245246});
247+248+it("exposes Windows task script env values as inline for managed-env drift audit", async () => {
249+await withUserProfileDir(async (_tmpDir, env) => {
250+const { scriptPath } = await installScheduledTask({
251+ env,
252+stdout: new PassThrough(),
253+programArguments: ["node", "gateway.js"],
254+environment: {
255+OPENCLAW_SERVICE_MANAGED_ENV_KEYS: "TAVILY_API_KEY",
256+TAVILY_API_KEY: "old-inline-value",
257+},
258+});
259+260+const command = await readScheduledTaskCommand(env);
261+expect(command?.environmentValueSources).toMatchObject({
262+OPENCLAW_SERVICE_MANAGED_ENV_KEYS: "inline",
263+TAVILY_API_KEY: "inline",
264+});
265+expect(command?.sourcePath).toBe(scriptPath);
266+267+const audit = await auditGatewayServiceConfig({
268+ env,
269+platform: "win32",
270+ command,
271+expectedManagedServiceEnvKeys: ["TAVILY_API_KEY"],
272+});
273+expect(
274+audit.issues.some((issue) => issue.code === SERVICE_AUDIT_CODES.gatewayManagedEnvEmbedded),
275+).toBe(true);
276+});
277+});
246278});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。