[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
58
electron/bridges/sftpBridge/fileOps.extract.test.cjs
Normal file
58
electron/bridges/sftpBridge/fileOps.extract.test.cjs
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("node:assert/strict");
|
||||
const test = require("node:test");
|
||||
|
||||
const { createFileOpsApi } = require("./fileOps.cjs");
|
||||
|
||||
function createExtractApi({ execImpl, clients } = {}) {
|
||||
const commands = [];
|
||||
const optionsLog = [];
|
||||
const api = createFileOpsApi({
|
||||
sftpClients: clients || new Map([
|
||||
["sftp-1", { client: { exec() {} } }],
|
||||
]),
|
||||
resolveEncodingForRequest: () => "utf-8",
|
||||
throwIfAborted: () => {},
|
||||
encodePath: (value) => value,
|
||||
requireSftpChannel: async () => ({}),
|
||||
lstatAsync: async () => ({ size: 1024 }),
|
||||
isScpModeClient: () => false,
|
||||
execRemoteShellCommand: async (_ssh, command, options) => {
|
||||
commands.push(command);
|
||||
optionsLog.push(options);
|
||||
if (typeof execImpl === "function") return execImpl(command);
|
||||
return { stdout: "", stderr: "", code: 0 };
|
||||
},
|
||||
});
|
||||
return { api, commands, optionsLog };
|
||||
}
|
||||
|
||||
test("extractSftpArchive runs a quoted remote tar command", async () => {
|
||||
const { api, commands, optionsLog } = createExtractApi();
|
||||
const result = await api.extractSftpArchive(null, {
|
||||
sftpId: "sftp-1",
|
||||
path: "/home/app/backup.tar.gz",
|
||||
});
|
||||
assert.deepEqual(result, { success: true });
|
||||
assert.equal(commands.length, 1);
|
||||
assert.match(commands[0], /tar -xzf '\/home\/app\/backup\.tar\.gz' -C '\/home\/app'/);
|
||||
assert.equal(optionsLog[0].discardStdout, true);
|
||||
});
|
||||
|
||||
test("extractSftpArchive rejects unsupported files", async () => {
|
||||
const { api, commands } = createExtractApi();
|
||||
await assert.rejects(
|
||||
() => api.extractSftpArchive(null, { sftpId: "sftp-1", path: "/home/app/notes.txt" }),
|
||||
/Unsupported archive type/,
|
||||
);
|
||||
assert.equal(commands.length, 0);
|
||||
});
|
||||
|
||||
test("extractSftpArchive requires an open SFTP session", async () => {
|
||||
const { api } = createExtractApi({ clients: new Map() });
|
||||
await assert.rejects(
|
||||
() => api.extractSftpArchive(null, { sftpId: "missing", path: "/tmp/a.zip" }),
|
||||
/SFTP session not found/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user