mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:11:24 +00:00
test: fix flaky auth tests when OPENCLAW_GATEWAY_TOKEN is present
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { resolveGatewayRuntimeConfig } from "./server-runtime-config.js";
|
||||
|
||||
const TRUSTED_PROXY_AUTH = {
|
||||
@@ -103,6 +103,21 @@ describe("resolveGatewayRuntimeConfig", () => {
|
||||
});
|
||||
|
||||
describe("token/password auth modes", () => {
|
||||
let originalToken: string | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
originalToken = process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (originalToken !== undefined) {
|
||||
process.env.OPENCLAW_GATEWAY_TOKEN = originalToken;
|
||||
} else {
|
||||
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||
}
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "lan binding with token",
|
||||
@@ -126,7 +141,8 @@ describe("resolveGatewayRuntimeConfig", () => {
|
||||
{
|
||||
name: "token mode without token",
|
||||
cfg: { gateway: { bind: "lan" as const, auth: { mode: "token" as const } } },
|
||||
expectedMessage: "gateway auth mode is token, but no token was configured",
|
||||
expectedMessage:
|
||||
"gateway auth mode is token, but no token was configured (set gateway.auth.token or OPENCLAW_GATEWAY_TOKEN)",
|
||||
},
|
||||
{
|
||||
name: "lan binding with explicit none auth",
|
||||
|
||||
Reference in New Issue
Block a user