16 lines
621 B
TypeScript
16 lines
621 B
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { execFileSync } from "node:child_process";
|
|
import { quoteShell, remote } from "../src/ssh.js";
|
|
|
|
test("shell quoting preserves literal input", () => {
|
|
for (const value of ["", "hello", "a'b", "$(echo unsafe);\n*", "こんにちは"]) {
|
|
assert.equal(execFileSync("sh", ["-c", `printf %s ${quoteShell(value)}`], { encoding: "utf8" }), value);
|
|
}
|
|
});
|
|
|
|
test("rejects option-like SSH destinations", () => {
|
|
assert.throws(() => remote("-oProxyCommand=bad", "true"));
|
|
assert.throws(() => remote("home extra", "true"));
|
|
});
|