Files
openclaw-zero-token/bootstrap/node-extra-ca-certs.test.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

89 lines
2.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
isNodeVersionManagerRuntime,
LINUX_CA_BUNDLE_PATHS,
resolveAutoNodeExtraCaCerts,
resolveLinuxSystemCaBundle,
} from "./node-extra-ca-certs.js";
function allowOnly(path: string) {
return (candidate: string) => {
if (candidate !== path) {
throw new Error("ENOENT");
}
};
}
describe("resolveLinuxSystemCaBundle", () => {
it("returns undefined on non-linux platforms", () => {
expect(
resolveLinuxSystemCaBundle({
platform: "darwin",
accessSync: allowOnly(LINUX_CA_BUNDLE_PATHS[0]),
}),
).toBeUndefined();
});
it("returns the first readable Linux CA bundle", () => {
expect(
resolveLinuxSystemCaBundle({
platform: "linux",
accessSync: allowOnly(LINUX_CA_BUNDLE_PATHS[1]),
}),
).toBe(LINUX_CA_BUNDLE_PATHS[1]);
});
});
describe("isNodeVersionManagerRuntime", () => {
it("detects nvm via NVM_DIR", () => {
expect(isNodeVersionManagerRuntime({ NVM_DIR: "/home/test/.nvm" }, "/usr/bin/node")).toBe(true);
});
it("detects nvm via execPath", () => {
expect(isNodeVersionManagerRuntime({}, "/home/test/.nvm/versions/node/v22/bin/node")).toBe(
true,
);
});
it("returns false for non-nvm node paths", () => {
expect(isNodeVersionManagerRuntime({}, "/usr/bin/node")).toBe(false);
});
});
describe("resolveAutoNodeExtraCaCerts", () => {
it("returns undefined when NODE_EXTRA_CA_CERTS is already set", () => {
expect(
resolveAutoNodeExtraCaCerts({
env: {
NVM_DIR: "/home/test/.nvm",
NODE_EXTRA_CA_CERTS: "/custom/ca.pem",
},
platform: "linux",
accessSync: allowOnly(LINUX_CA_BUNDLE_PATHS[0]),
}),
).toBeUndefined();
});
it("returns undefined when node is not nvm-managed", () => {
expect(
resolveAutoNodeExtraCaCerts({
env: {},
platform: "linux",
execPath: "/usr/bin/node",
accessSync: allowOnly(LINUX_CA_BUNDLE_PATHS[0]),
}),
).toBeUndefined();
});
it("returns the readable Linux CA bundle for nvm-managed node", () => {
expect(
resolveAutoNodeExtraCaCerts({
env: { NVM_DIR: "/home/test/.nvm" },
platform: "linux",
execPath: "/usr/bin/node",
accessSync: allowOnly(LINUX_CA_BUNDLE_PATHS[2]),
}),
).toBe(LINUX_CA_BUNDLE_PATHS[2]);
});
});