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.

test(cli): lock offline update dispatch

Rahman71d592e0b9d8
diff --git a/bin/mso-update-offline.test.ts b/bin/mso-update-offline.test.ts
new file mode 100644
index 00000000..939dece8
--- /dev/null
+++ b/bin/mso-update-offline.test.ts
@@ -0,0 +1,92 @@
+import { execFileSync } from "node:child_process";
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterEach, describe, expect, it } from "vitest";
+
+const ROOT = path.resolve(__dirname, "..");
+const roots: string[] = [];
+
+function copy(root: string, rel: string) {
+ const dst = path.join(root, rel);
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
+ fs.copyFileSync(path.join(ROOT, rel), dst);
+ fs.chmodSync(dst, fs.statSync(path.join(ROOT, rel)).mode & 0o777);
+}
+
+function git(cwd: string, ...args: string[]) {
+ return execFileSync("git", args, { cwd, encoding: "utf8" }).trim();
+}
+
+function fixture() {
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "mso-cli-update-"));
+ roots.push(dir);
+ const repo = path.join(dir, "repo");
+ const remote = path.join(dir, "remote.git");
+ const fakebin = path.join(dir, "fakebin");
+ const curlMarker = path.join(dir, "curl-called");
+ fs.mkdirSync(repo, { recursive: true });
+ fs.mkdirSync(fakebin, { mode: 0o700 });
+ for (const rel of [
+ "bin/mso",
+ "scripts/mso-update",
+ "scripts/lib/private-state.sh",
+ "scripts/lib/update-state.sh",
+ "scripts/lib/runtime-exclusion.sh",
+ ]) copy(repo, rel);
+ fs.writeFileSync(
+ path.join(fakebin, "curl"),
+ `#!/bin/sh\nprintf touched > ${JSON.stringify(curlMarker)}\nexit 91\n`,
+ { mode: 0o700 },
+ );
+ fs.writeFileSync(
+ path.join(fakebin, "systemctl"),
+ `#!/bin/sh\nif [ "$1" = is-active ]; then exit 3; fi\nexit 1\n`,
+ { mode: 0o700 },
+ );
+ git(repo, "init", "-q", "-b", "main");
+ git(repo, "config", "user.email", "[email protected]");
+ git(repo, "config", "user.name", "MSO Test");
+ git(repo, "add", ".");
+ git(repo, "commit", "-qm", "fixture");
+ execFileSync("git", ["init", "-q", "--bare", remote]);
+ git(repo, "remote", "add", "origin", remote);
+ git(repo, "push", "-q", "-u", "origin", "main");
+ return {
+ repo,
+ curlMarker,
+ env: {
+ ...process.env,
+ HOME: dir,
+ PATH: `${fakebin}:${process.env.PATH ?? ""}`,
+ MSO_ENV: "/dev/null",
+ MSO_UPDATE_NOTICE_DIR: path.join(dir, "notice"),
+ MSO_UPDATE_STATE_DIR: path.join(dir, "update-state"),
+ MSO_RUNTIME_EXCLUSION_DIR: path.join(dir, "runtime-exclusion"),
+ },
+ };
+}
+
+afterEach(() => {
+ for (const dir of roots.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
+});
+
+describe("mso offline update dispatch", () => {
+ it("runs update status without contacting the MSO HTTP API", () => {
+ const f = fixture();
+ const out = execFileSync(path.join(f.repo, "bin/mso"), ["update", "status"], {
+ encoding: "utf8",
+ env: f.env,
+ });
+ expect(out).toMatch(/up to date|offline deployment verification\/restart is pending/);
+ expect(fs.existsSync(f.curlMarker)).toBe(false);
+ });
+
+ it("keeps `mso update run` as a local compatibility alias", () => {
+ const cli = fs.readFileSync(path.join(ROOT, "bin/mso"), "utf8");
+ const updater = fs.readFileSync(path.join(ROOT, "scripts/mso-update"), "utf8");
+ expect(cli).toMatch(/update\).*scripts\/mso-update/);
+ expect(updater).toMatch(/case "\$\{1:-run\}" in/);
+ expect(updater).toMatch(/run\) case/);
+ });
+});
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index da460bc5..92ace847 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -36,6 +36,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Tests**
+- `cli` lock offline update dispatch
- `gateway` harden hosted security fixtures
**Docs**