mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-16 23:52:40 -06:00
e72f601925
Remove the unrelated npm openshell dependency and keep the OpenShell sandbox backend pointed at the NVIDIA CLI command contract.
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { afterEach, describe, expect, it } from "vitest";
|
|
import { buildOpenShellSandboxName, buildOpenShellSshExecEnv } from "./backend.js";
|
|
|
|
describe("openshell backend env", () => {
|
|
const originalEnv = { ...process.env };
|
|
|
|
afterEach(() => {
|
|
for (const key of Object.keys(process.env)) {
|
|
if (!(key in originalEnv)) {
|
|
delete process.env[key];
|
|
}
|
|
}
|
|
Object.assign(process.env, originalEnv);
|
|
});
|
|
|
|
it("filters blocked secrets from ssh exec env", () => {
|
|
process.env.OPENAI_API_KEY = "sk-test-secret";
|
|
process.env.ANTHROPIC_API_KEY = "sk-ant-test-secret";
|
|
process.env.LANG = "en_US.UTF-8";
|
|
process.env.NODE_ENV = "test";
|
|
|
|
const env = buildOpenShellSshExecEnv();
|
|
|
|
expect(env.OPENAI_API_KEY).toBeUndefined();
|
|
expect(env.ANTHROPIC_API_KEY).toBeUndefined();
|
|
expect(env.LANG).toBe("en_US.UTF-8");
|
|
expect(env.NODE_ENV).toBe("test");
|
|
});
|
|
});
|
|
|
|
describe("openshell sandbox names", () => {
|
|
it("generates Kubernetes-safe names from OpenClaw session scope keys", () => {
|
|
const name = buildOpenShellSandboxName("agent:somalley_alice:dashboard-8");
|
|
|
|
expect(name).toMatch(/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/);
|
|
expect(name).toContain("somalley-alice");
|
|
expect(name).not.toContain("_");
|
|
expect(name.length).toBeLessThanOrEqual(63);
|
|
});
|
|
});
|