Initial commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
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"));
|
||||
});
|
||||
Reference in New Issue
Block a user