Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

2.9 KB
Raw Blame
import { readFileSync } from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { getManagedAppDefinition, isManagedAppId, listManagedAppDefinitions } from "./catalog";
import { MANAGED_APP_ACTIONS } from "./types";

describe("managed app catalog", () => {
  it("uses one shared catalog for Hermes, OpenClaw, 9Router and Orca", () => {
    const definitions = listManagedAppDefinitions();
    expect(definitions.map((item) => item.id)).toEqual(["hermes", "openclaw", "9router", "orca"]);
    expect(new Set(definitions.map((item) => item.id)).size).toBe(4);
  });

  it("rejects arbitrary application ids and commands", () => {
    expect(isManagedAppId("hermes")).toBe(true);
    expect(isManagedAppId("openclaw")).toBe(true);
    expect(isManagedAppId("9router")).toBe(true);
    expect(isManagedAppId("orca")).toBe(true);
    expect(isManagedAppId("hermes;rm -rf /")).toBe(false);
    expect(MANAGED_APP_ACTIONS).toEqual(["start", "stop", "restart", "backup"]);
  });

  it("keeps runtime-specific configuration separate", () => {
    const definitions = listManagedAppDefinitions();
    expect(new Set(definitions.map((item) => item.command)).size).toBe(definitions.length);
    expect(new Set(definitions.map((item) => item.stateDirName)).size).toBe(definitions.length);
    const hermes = getManagedAppDefinition("hermes");
    const openclaw = getManagedAppDefinition("openclaw");
    expect(hermes.serviceNames).not.toEqual(openclaw.serviceNames);
    expect(hermes.healthPath).toBe("/api/health");
  });
  it("keeps 9Router loopback-only unless public exposure is explicitly enabled", () => {
    const source = readFileSync(new URL("../../scripts/managed-app-9router", import.meta.url), "utf8");
    expect(source).toContain('EXPOSE_PUBLIC="${NINE_ROUTER_EXPOSE_PUBLIC:-0}"');
    expect(source).toContain('PROXY_NETWORK="${NINE_ROUTER_PROXY_NETWORK:-dokploy-network}"');
    expect(source).toContain('network_args=(--network "$PROXY_NETWORK")');
    expect(source).toContain('0) BIND=127.0.0.1');
    expect(source).toContain('-p "$BIND:$PORT:$PORT"');
    expect(source).not.toContain('-p "$PORT:$PORT"');
    expect(getManagedAppDefinition("9router").publicPort).toBeUndefined();
  });

  it("wires Orca to the repo-owned adapter and the systemd user backend", () => {
    const orca = getManagedAppDefinition("orca");
    // The reviewed adapter ships in this repo, so its presence must not count as
    // an install; the exact unit + a verified receipt do.
    expect(orca.installBackends).toEqual(["user-systemd"]);
    expect(orca.command).toBe(path.join(process.cwd(), "scripts", "managed-app-orca"));
    expect(orca.commandProvesInstall).toBe(false);
    expect(orca.serviceNames).toEqual(["mso-orca.service"]);
    // The managed root is MSO-owned state, never the operator's personal ~/.orca.
    expect(orca.homeDir).toMatch(/mso[/\\]orca$/);
  });

});