mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:38:28 +00:00
refactor(test): snapshot gateway auth env in security audit tests
This commit is contained in:
@@ -4,7 +4,7 @@ import path from "node:path";
|
|||||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import type { ChannelPlugin } from "../channels/plugins/types.js";
|
import type { ChannelPlugin } from "../channels/plugins/types.js";
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import { withEnvAsync } from "../test-utils/env.js";
|
import { captureEnv, withEnvAsync } from "../test-utils/env.js";
|
||||||
import { collectPluginsCodeSafetyFindings } from "./audit-extra.js";
|
import { collectPluginsCodeSafetyFindings } from "./audit-extra.js";
|
||||||
import type { SecurityAuditOptions, SecurityAuditReport } from "./audit.js";
|
import type { SecurityAuditOptions, SecurityAuditReport } from "./audit.js";
|
||||||
import { runSecurityAudit } from "./audit.js";
|
import { runSecurityAudit } from "./audit.js";
|
||||||
@@ -2240,25 +2240,16 @@ description: test skill
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("maybeProbeGateway auth selection", () => {
|
describe("maybeProbeGateway auth selection", () => {
|
||||||
const originalEnvToken = process.env.OPENCLAW_GATEWAY_TOKEN;
|
let envSnapshot: ReturnType<typeof captureEnv>;
|
||||||
const originalEnvPassword = process.env.OPENCLAW_GATEWAY_PASSWORD;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
envSnapshot = captureEnv(["OPENCLAW_GATEWAY_TOKEN", "OPENCLAW_GATEWAY_PASSWORD"]);
|
||||||
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||||
delete process.env.OPENCLAW_GATEWAY_PASSWORD;
|
delete process.env.OPENCLAW_GATEWAY_PASSWORD;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
if (originalEnvToken == null) {
|
envSnapshot.restore();
|
||||||
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
|
||||||
} else {
|
|
||||||
process.env.OPENCLAW_GATEWAY_TOKEN = originalEnvToken;
|
|
||||||
}
|
|
||||||
if (originalEnvPassword == null) {
|
|
||||||
delete process.env.OPENCLAW_GATEWAY_PASSWORD;
|
|
||||||
} else {
|
|
||||||
process.env.OPENCLAW_GATEWAY_PASSWORD = originalEnvPassword;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeProbeCapture = () => {
|
const makeProbeCapture = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user