test: drop duplicate timeout-fallback e2e and trim onboarding auth overlap

This commit is contained in:
Peter Steinberger
2026-02-22 13:33:40 +00:00
parent 7a2b05314a
commit 648d2daf67
2 changed files with 4 additions and 194 deletions

View File

@@ -1,7 +1,6 @@
import fs from "node:fs/promises";
import path from "node:path";
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import type { GatewayAuthConfig } from "../config/config.js";
import { makeTempWorkspace } from "../test-helpers/workspace.js";
import { captureEnv } from "../test-utils/env.js";
import {
@@ -60,19 +59,6 @@ function getPseudoPort(base: number): number {
const runtime = createThrowingRuntime();
async function expectGatewayTokenAuth(params: {
authConfig: GatewayAuthConfig | null | undefined;
token: string;
env: NodeJS.ProcessEnv;
}) {
const { authorizeGatewayConnect, resolveGatewayAuth } = await import("../gateway/auth.js");
const auth = resolveGatewayAuth({ authConfig: params.authConfig, env: params.env });
const resNoToken = await authorizeGatewayConnect({ auth, connectAuth: { token: undefined } });
expect(resNoToken.ok).toBe(false);
const resToken = await authorizeGatewayConnect({ auth, connectAuth: { token: params.token } });
expect(resToken.ok).toBe(true);
}
describe("onboard (non-interactive): gateway and remote auth", () => {
let envSnapshot: ReturnType<typeof captureEnv>;
let tempHome: string | undefined;
@@ -129,7 +115,7 @@ describe("onboard (non-interactive): gateway and remote auth", () => {
envSnapshot.restore();
});
it("writes gateway token auth into config and gateway enforces it", async () => {
it("writes gateway token auth into config", async () => {
await withStateDir("state-noninteractive-", async (stateDir) => {
const token = "tok_test_123";
const workspace = path.join(stateDir, "openclaw");
@@ -153,19 +139,13 @@ describe("onboard (non-interactive): gateway and remote auth", () => {
const { resolveConfigPath } = await import("../config/paths.js");
const configPath = resolveConfigPath(process.env, stateDir);
const cfg = await readJsonFile<{
gateway?: { auth?: GatewayAuthConfig };
gateway?: { auth?: { mode?: string; token?: string } };
agents?: { defaults?: { workspace?: string } };
}>(configPath);
expect(cfg?.agents?.defaults?.workspace).toBe(workspace);
expect(cfg?.gateway?.auth?.mode).toBe("token");
expect(cfg?.gateway?.auth?.token).toBe(token);
await expectGatewayTokenAuth({
authConfig: cfg.gateway?.auth,
token,
env: process.env,
});
});
}, 60_000);
@@ -237,21 +217,14 @@ describe("onboard (non-interactive): gateway and remote auth", () => {
gateway?: {
bind?: string;
port?: number;
auth?: GatewayAuthConfig;
auth?: { mode?: string; token?: string };
};
}>(configPath);
expect(cfg.gateway?.bind).toBe("lan");
expect(cfg.gateway?.port).toBe(port);
expect(cfg.gateway?.auth?.mode).toBe("token");
const token = cfg.gateway?.auth?.token ?? "";
expect(token.length).toBeGreaterThan(8);
await expectGatewayTokenAuth({
authConfig: cfg.gateway?.auth,
token,
env: process.env,
});
expect((cfg.gateway?.auth?.token ?? "").length).toBeGreaterThan(8);
});
}, 60_000);
});