mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 23:11:37 +00:00
test: stabilize remaining e2e gateway suites
This commit is contained in:
@@ -5,6 +5,10 @@ import path from "node:path";
|
|||||||
import { pathToFileURL } from "node:url";
|
import { pathToFileURL } from "node:url";
|
||||||
import { afterEach, describe, expect, it } from "vitest";
|
import { afterEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
const nodeMajor = Number.parseInt(process.versions.node.split(".")[0] ?? "0", 10);
|
||||||
|
// tsx currently crashes with "__name is not a function" on Node 25 in child bootstrap mode.
|
||||||
|
const runSigtermTest = nodeMajor >= 25 ? it.skip : it;
|
||||||
|
|
||||||
const waitForReady = async (
|
const waitForReady = async (
|
||||||
proc: ReturnType<typeof spawn>,
|
proc: ReturnType<typeof spawn>,
|
||||||
chunksOut: string[],
|
chunksOut: string[],
|
||||||
@@ -78,7 +82,7 @@ describe("gateway SIGTERM", () => {
|
|||||||
child = null;
|
child = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("exits 0 on SIGTERM", { timeout: 180_000 }, async () => {
|
runSigtermTest("exits 0 on SIGTERM", { timeout: 180_000 }, async () => {
|
||||||
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-gateway-test-"));
|
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-gateway-test-"));
|
||||||
const out: string[] = [];
|
const out: string[] = [];
|
||||||
const err: string[] = [];
|
const err: string[] = [];
|
||||||
|
|||||||
@@ -27,6 +27,20 @@ beforeAll(async () => {
|
|||||||
testState.gatewayAuth = { mode: "token", token: gatewayToken };
|
testState.gatewayAuth = { mode: "token", token: gatewayToken };
|
||||||
process.env.OPENCLAW_GATEWAY_PORT = String(gatewayPort);
|
process.env.OPENCLAW_GATEWAY_PORT = String(gatewayPort);
|
||||||
process.env.OPENCLAW_GATEWAY_TOKEN = gatewayToken;
|
process.env.OPENCLAW_GATEWAY_TOKEN = gatewayToken;
|
||||||
|
const { approveDevicePairing, requestDevicePairing } = await import("../infra/device-pairing.js");
|
||||||
|
const { loadOrCreateDeviceIdentity, publicKeyRawBase64UrlFromPem } =
|
||||||
|
await import("../infra/device-identity.js");
|
||||||
|
const identity = loadOrCreateDeviceIdentity();
|
||||||
|
const pending = await requestDevicePairing({
|
||||||
|
deviceId: identity.deviceId,
|
||||||
|
publicKey: publicKeyRawBase64UrlFromPem(identity.publicKeyPem),
|
||||||
|
clientId: "openclaw-cli",
|
||||||
|
clientMode: "cli",
|
||||||
|
role: "operator",
|
||||||
|
scopes: ["operator.admin", "operator.read", "operator.write", "operator.approvals"],
|
||||||
|
silent: false,
|
||||||
|
});
|
||||||
|
await approveDevicePairing(pending.request.requestId);
|
||||||
server = await startGatewayServer(gatewayPort);
|
server = await startGatewayServer(gatewayPort);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user