fix: harden Docker/GCP onboarding flow (#26253) (thanks @pandego)

This commit is contained in:
Peter Steinberger
2026-02-26 05:45:57 +01:00
parent e8197404d0
commit 35976da7a0
6 changed files with 127 additions and 5 deletions

View File

@@ -168,6 +168,27 @@ describe("docker-setup.sh", () => {
expect(identityDirStat.isDirectory()).toBe(true);
});
it("reuses existing config token when OPENCLAW_GATEWAY_TOKEN is unset", async () => {
const activeSandbox = requireSandbox(sandbox);
const configDir = join(activeSandbox.rootDir, "config-token-reuse");
const workspaceDir = join(activeSandbox.rootDir, "workspace-token-reuse");
await mkdir(configDir, { recursive: true });
await writeFile(
join(configDir, "openclaw.json"),
JSON.stringify({ gateway: { auth: { mode: "token", token: "config-token-123" } } }),
);
const result = runDockerSetup(activeSandbox, {
OPENCLAW_GATEWAY_TOKEN: undefined,
OPENCLAW_CONFIG_DIR: configDir,
OPENCLAW_WORKSPACE_DIR: workspaceDir,
});
expect(result.status).toBe(0);
const envFile = await readFile(join(activeSandbox.rootDir, ".env"), "utf8");
expect(envFile).toContain("OPENCLAW_GATEWAY_TOKEN=config-token-123");
});
it("rejects injected multiline OPENCLAW_EXTRA_MOUNTS values", async () => {
const activeSandbox = requireSandbox(sandbox);

View File

@@ -9,7 +9,7 @@ const dockerfilePath = join(repoRoot, "Dockerfile");
describe("Dockerfile", () => {
it("installs optional browser dependencies after pnpm install", async () => {
const dockerfile = await readFile(dockerfilePath, "utf8");
const installIndex = dockerfile.indexOf("RUN pnpm install --frozen-lockfile");
const installIndex = dockerfile.indexOf("pnpm install --frozen-lockfile");
const browserArgIndex = dockerfile.indexOf("ARG OPENCLAW_INSTALL_BROWSER");
expect(installIndex).toBeGreaterThan(-1);