@@ -3,6 +3,7 @@ import os from "node:os";
|
3 | 3 | import path from "node:path"; |
4 | 4 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
5 | 5 | import { writeStateDirDotEnv } from "../config/test-helpers.js"; |
| 6 | +import { collectPreservedExistingServiceEnvVars } from "./daemon-install-helpers.js"; |
6 | 7 | |
7 | 8 | const mocks = vi.hoisted(() => ({ |
8 | 9 | hasAnyAuthProfileStoreSource: vi.fn(() => true), |
@@ -1488,3 +1489,46 @@ describe("gatewayInstallErrorHint", () => {
|
1488 | 1489 | ); |
1489 | 1490 | }); |
1490 | 1491 | }); |
| 1492 | + |
| 1493 | +describe("collectPreservedExistingServiceEnvVars — operator opt-in allowlist", () => { |
| 1494 | +const managedKeys = new Set<string>(); |
| 1495 | + |
| 1496 | +it("continues to drop stale OPENCLAW_ALLOW_ROOT", () => { |
| 1497 | +const result = collectPreservedExistingServiceEnvVars( |
| 1498 | +{ OPENCLAW_ALLOW_ROOT: "1" }, |
| 1499 | +managedKeys, |
| 1500 | +); |
| 1501 | +expect(result.OPENCLAW_ALLOW_ROOT).toBeUndefined(); |
| 1502 | +}); |
| 1503 | + |
| 1504 | +it("preserves OPENCLAW_CLI_CONTAINER_BYPASS and OPENCLAW_CONTAINER_HINT", () => { |
| 1505 | +const result = collectPreservedExistingServiceEnvVars( |
| 1506 | +{ |
| 1507 | +OPENCLAW_CLI_CONTAINER_BYPASS: "1", |
| 1508 | +OPENCLAW_CONTAINER_HINT: "ci", |
| 1509 | +}, |
| 1510 | +managedKeys, |
| 1511 | +); |
| 1512 | +expect(result.OPENCLAW_CLI_CONTAINER_BYPASS).toBe("1"); |
| 1513 | +expect(result.OPENCLAW_CONTAINER_HINT).toBe("ci"); |
| 1514 | +}); |
| 1515 | + |
| 1516 | +it("still drops arbitrary OPENCLAW_FOO", () => { |
| 1517 | +const result = collectPreservedExistingServiceEnvVars({ OPENCLAW_FOO: "bar" }, managedKeys); |
| 1518 | +expect(result.OPENCLAW_FOO).toBeUndefined(); |
| 1519 | +}); |
| 1520 | + |
| 1521 | +it("preserves container opt-ins while dropping unrelated OPENCLAW_* keys", () => { |
| 1522 | +const result = collectPreservedExistingServiceEnvVars( |
| 1523 | +{ |
| 1524 | +OPENCLAW_CLI_CONTAINER_BYPASS: "1", |
| 1525 | +OPENCLAW_CONTAINER_HINT: "ci", |
| 1526 | +OPENCLAW_BAZ: "qux", |
| 1527 | +}, |
| 1528 | +managedKeys, |
| 1529 | +); |
| 1530 | +expect(result.OPENCLAW_CLI_CONTAINER_BYPASS).toBe("1"); |
| 1531 | +expect(result.OPENCLAW_CONTAINER_HINT).toBe("ci"); |
| 1532 | +expect(result.OPENCLAW_BAZ).toBeUndefined(); |
| 1533 | +}); |
| 1534 | +}); |