mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-23 15:11:42 +00:00
perf(secrets): split runtime snapshot coverage
This commit is contained in:
60
src/secrets/runtime-auth-write-refresh.test.ts
Normal file
60
src/secrets/runtime-auth-write-refresh.test.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import os from "node:os";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { withTempHome } from "../config/home-env.test-harness.js";
|
||||
import {
|
||||
beginSecretsRuntimeIsolationForTest,
|
||||
createOpenAIFileRuntimeConfig,
|
||||
createOpenAIFileRuntimeFixture,
|
||||
EMPTY_LOADABLE_PLUGIN_ORIGINS,
|
||||
endSecretsRuntimeIsolationForTest,
|
||||
expectResolvedOpenAIRuntime,
|
||||
type SecretsRuntimeEnvSnapshot,
|
||||
} from "./runtime-auth.integration.test-helpers.js";
|
||||
import { activateSecretsRuntimeSnapshot, prepareSecretsRuntimeSnapshot } from "./runtime.js";
|
||||
|
||||
vi.unmock("../version.js");
|
||||
|
||||
describe("secrets runtime snapshot auth write refresh", () => {
|
||||
let envSnapshot: SecretsRuntimeEnvSnapshot;
|
||||
|
||||
beforeEach(() => {
|
||||
envSnapshot = beginSecretsRuntimeIsolationForTest();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
endSecretsRuntimeIsolationForTest(envSnapshot);
|
||||
});
|
||||
|
||||
it("keeps active secrets runtime snapshots resolved after refreshes", async () => {
|
||||
if (os.platform() === "win32") {
|
||||
return;
|
||||
}
|
||||
await withTempHome("openclaw-secrets-runtime-write-", async (home) => {
|
||||
const { secretFile, agentDir } = await createOpenAIFileRuntimeFixture(home);
|
||||
|
||||
const prepared = await prepareSecretsRuntimeSnapshot({
|
||||
config: createOpenAIFileRuntimeConfig(secretFile),
|
||||
agentDirs: [agentDir],
|
||||
loadablePluginOrigins: EMPTY_LOADABLE_PLUGIN_ORIGINS,
|
||||
});
|
||||
|
||||
activateSecretsRuntimeSnapshot(prepared);
|
||||
|
||||
expectResolvedOpenAIRuntime(agentDir);
|
||||
|
||||
const refreshed = await prepareSecretsRuntimeSnapshot({
|
||||
config: {
|
||||
...createOpenAIFileRuntimeConfig(secretFile),
|
||||
gateway: { auth: { mode: "token" } },
|
||||
},
|
||||
agentDirs: [agentDir],
|
||||
loadablePluginOrigins: EMPTY_LOADABLE_PLUGIN_ORIGINS,
|
||||
});
|
||||
activateSecretsRuntimeSnapshot(refreshed);
|
||||
|
||||
expectResolvedOpenAIRuntime(agentDir);
|
||||
expect(refreshed.config.gateway?.auth).toEqual({ mode: "token" });
|
||||
expect(refreshed.sourceConfig.gateway?.auth).toEqual({ mode: "token" });
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user