mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55:24 +00:00
chore: lock the plugin boundary and remove 2.9.0 leftovers
This commit is contained in:
1 parent
6489b62ece
commit
2961297989
399 files changed
+3964
-5627
No files matched your search
@@ -128,7 +128,7 @@ function startBackend(
|
||||
let body = "";
|
||||
req.on("data", (d) => (body += d));
|
||||
req.on("end", () => {
|
||||
if (!opts.failAll && req.url?.endsWith("/ssh/downloadFileStream")) {
|
||||
if (!opts.failAll && req.url?.endsWith("/downloadFileStream")) {
|
||||
// Headers go out immediately so the client opens its temp file;
|
||||
// the body may be delayed to keep the transfer in flight.
|
||||
res.writeHead(200, { "Content-Length": payload.length });
|
||||
@@ -150,7 +150,7 @@ function startBackend(
|
||||
server.listen(0, "127.0.0.1", () => {
|
||||
const address = server.address() as { port: number };
|
||||
resolve({
|
||||
url: `http://127.0.0.1:${address.port}/ssh/file_manager`,
|
||||
url: `http://127.0.0.1:${address.port}/plugin-api/file-manager`,
|
||||
seen,
|
||||
close: () => new Promise((r) => server.close(() => r())),
|
||||
});
|
||||
@@ -160,25 +160,25 @@ function startBackend(
|
||||
|
||||
describe("local-files transfer target resolution", () => {
|
||||
const resolve = localFiles.createTargetResolver({
|
||||
localBaseUrl: "http://127.0.0.1:30004/ssh/file_manager",
|
||||
localBaseUrl: "http://127.0.0.1:30001/plugin-api/file-manager",
|
||||
getRemoteSyncConfig: () => ({ serverUrl: "https://termix.example.com/" }),
|
||||
getRemoteSyncJwt: () => "remote-jwt",
|
||||
});
|
||||
|
||||
it("only reaches the two file-manager streaming routes on the local backend", () => {
|
||||
expect(resolve({ origin: "local", route: "uploadFileStream" })).toEqual({
|
||||
url: "http://127.0.0.1:30004/ssh/file_manager/ssh/uploadFileStream",
|
||||
url: "http://127.0.0.1:30001/plugin-api/file-manager/uploadFileStream",
|
||||
headers: { "X-Electron-App": "true" },
|
||||
});
|
||||
expect(resolve({ origin: "local", route: "downloadFileStream" }).url).toBe(
|
||||
"http://127.0.0.1:30004/ssh/file_manager/ssh/downloadFileStream",
|
||||
"http://127.0.0.1:30001/plugin-api/file-manager/downloadFileStream",
|
||||
);
|
||||
});
|
||||
|
||||
it("derives the remote target from the configured sync server and attaches its JWT itself", () => {
|
||||
const target = resolve({ origin: "remote", route: "downloadFileStream" });
|
||||
expect(target.url).toBe(
|
||||
"https://termix.example.com/ssh/file_manager/ssh/downloadFileStream",
|
||||
"https://termix.example.com/plugin-api/file-manager/downloadFileStream",
|
||||
);
|
||||
expect(target.headers.Authorization).toBe("Bearer remote-jwt");
|
||||
});
|
||||
@@ -242,7 +242,7 @@ describe("local-files transfer target resolution", () => {
|
||||
});
|
||||
expect(target.headers.Authorization).toBe(`Bearer ${jwt}`);
|
||||
expect(target.url).toBe(
|
||||
"http://127.0.0.1:30004/ssh/file_manager/ssh/uploadFileStream",
|
||||
"http://127.0.0.1:30001/plugin-api/file-manager/uploadFileStream",
|
||||
);
|
||||
// Absent or empty: no header at all (the session cookie is the fallback).
|
||||
for (const authToken of [undefined, null, ""]) {
|
||||
@@ -355,7 +355,7 @@ describe("local-files download boundary", () => {
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
const last = backend.seen[backend.seen.length - 1];
|
||||
expect(last.url).toBe("/ssh/file_manager/ssh/downloadFileStream");
|
||||
expect(last.url).toBe("/plugin-api/file-manager/downloadFileStream");
|
||||
expect(last.headers.authorization).toBeUndefined();
|
||||
expect(last.headers.cookie).toBeUndefined();
|
||||
expect(last.headers["x-electron-app"]).toBe("true");
|
||||
@@ -952,7 +952,7 @@ describe("local-files upload boundary", () => {
|
||||
const handlers = localFiles.createLocalFileHandlers({
|
||||
net: fakeNet,
|
||||
shell: {},
|
||||
localBaseUrl: `http://127.0.0.1:${port}/ssh/file_manager`,
|
||||
localBaseUrl: `http://127.0.0.1:${port}/plugin-api/file-manager`,
|
||||
});
|
||||
const result = await handlers[localFiles.IPC.UPLOAD](fakeEvent, {
|
||||
transferId: "up-1",
|
||||
@@ -964,7 +964,7 @@ describe("local-files upload boundary", () => {
|
||||
headers: { Authorization: "Bearer leaked" },
|
||||
});
|
||||
expect(result.success).toBe(true);
|
||||
expect(received.url).toBe("/ssh/file_manager/ssh/uploadFileStream");
|
||||
expect(received.url).toBe("/plugin-api/file-manager/uploadFileStream");
|
||||
expect(received.headers?.authorization).toBeUndefined();
|
||||
expect(received.fields).toEqual({
|
||||
sessionId: "42",
|
||||
@@ -1006,7 +1006,7 @@ describe("local-files upload boundary", () => {
|
||||
const handlers = localFiles.createLocalFileHandlers({
|
||||
net: fakeNet,
|
||||
shell: {},
|
||||
localBaseUrl: `http://127.0.0.1:${port}/ssh/file_manager`,
|
||||
localBaseUrl: `http://127.0.0.1:${port}/plugin-api/file-manager`,
|
||||
});
|
||||
const withoutToken = await handlers[localFiles.IPC.UPLOAD](fakeEvent, {
|
||||
transferId: "up-auth-0",
|
||||
@@ -1105,7 +1105,7 @@ describe("local-files upload boundary", () => {
|
||||
const handlers = localFiles.createLocalFileHandlers({
|
||||
net: fakeNet,
|
||||
shell: {},
|
||||
localBaseUrl: `http://127.0.0.1:${port}/ssh/file_manager`,
|
||||
localBaseUrl: `http://127.0.0.1:${port}/plugin-api/file-manager`,
|
||||
});
|
||||
const results = await Promise.all(
|
||||
files.map((f) =>
|
||||
@@ -1131,7 +1131,7 @@ describe("local-files upload boundary", () => {
|
||||
const handlers = localFiles.createLocalFileHandlers({
|
||||
net: fakeNet,
|
||||
shell: {},
|
||||
localBaseUrl: "http://127.0.0.1:1/ssh/file_manager",
|
||||
localBaseUrl: "http://127.0.0.1:1/plugin-api/file-manager",
|
||||
});
|
||||
const result = await handlers[localFiles.IPC.UPLOAD](fakeEvent, {
|
||||
transferId: "up-2",
|
||||
|
||||
Reference in new issue
Block a user