Skip to content

Commit 9152c89

Browse files
committed
test(proxy): keep managed proxy cert fixture in temp dir
1 parent f1f7ffc commit 9152c89

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

src/proxy-capture/proxy-server.managed-proxy.test.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
import { rm } from "node:fs/promises";
1+
import { mkdtemp, rm } from "node:fs/promises";
22
import { Socket } from "node:net";
3+
import { tmpdir } from "node:os";
4+
import { join } from "node:path";
35
import { afterEach, beforeEach, describe, expect, it } from "vitest";
46
import { assertDebugProxyDirectConnectAllowed, startDebugProxyServer } from "./proxy-server.js";
57

6-
const testBlobDir = ".tmp-debug-proxy-test-blobs";
7-
const testCertDir = ".tmp-debug-proxy-test-certs";
8+
let testRoot: string | undefined;
89

910
async function cleanupTestDirs(): Promise<void> {
10-
await Promise.all([
11-
rm(testBlobDir, { recursive: true, force: true }),
12-
rm(testCertDir, { recursive: true, force: true }),
13-
]);
11+
if (!testRoot) {
12+
return;
13+
}
14+
const root = testRoot;
15+
testRoot = undefined;
16+
await rm(root, { recursive: true, force: true });
1417
}
1518

16-
function makeSettings() {
19+
async function makeSettings() {
20+
testRoot = await mkdtemp(join(tmpdir(), "openclaw-debug-proxy-managed-proxy-"));
1721
return {
1822
enabled: true,
1923
required: false,
2024
dbPath: ":memory:",
21-
blobDir: testBlobDir,
22-
certDir: testCertDir,
25+
blobDir: join(testRoot, "blobs"),
26+
certDir: join(testRoot, "certs"),
2327
sessionId: "debug-proxy-managed-proxy-test",
2428
sourceProcess: "test",
2529
};
@@ -90,7 +94,7 @@ describe("debug proxy managed-proxy CONNECT policy", () => {
9094

9195
it("rejects CONNECT upstreams before opening direct sockets while managed proxy mode is active", async () => {
9296
process.env["OPENCLAW_PROXY_ACTIVE"] = "1";
93-
const server = await startDebugProxyServer({ settings: makeSettings() });
97+
const server = await startDebugProxyServer({ settings: await makeSettings() });
9498
try {
9599
const response = await connectThroughProxy(server.proxyUrl);
96100

0 commit comments

Comments
 (0)