mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55:24 +00:00
fix(session-sharing): use the linked server for desktop meetings and links (#1507)
This commit is contained in:
1 parent
9801cc7fc7
commit
ec7c2c2835
15 files changed
+621
-210
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import http from "node:http";
|
||||
import { sqliteTable, integer, text } from "drizzle-orm/sqlite-core";
|
||||
import type { AddressInfo } from "node:net";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import express, { type Router } from "express";
|
||||
@@ -85,7 +86,20 @@ export async function startServer(
|
||||
settings?: Record<string, unknown>;
|
||||
} = {},
|
||||
): Promise<TestServer> {
|
||||
const db = await createTestDb(pluginDir);
|
||||
const db = await createTestDb(pluginDir, {
|
||||
before: (sqlite) => {
|
||||
sqlite.exec("ALTER TABLE ssh_data ADD COLUMN sync_id TEXT");
|
||||
},
|
||||
});
|
||||
const refs = await db.database.refs();
|
||||
db.database.refs = async () =>
|
||||
({
|
||||
...refs,
|
||||
hosts: sqliteTable("ssh_data", {
|
||||
id: integer("id").primaryKey(),
|
||||
syncId: text("sync_id"),
|
||||
}),
|
||||
}) as Awaited<ReturnType<typeof db.database.refs>>;
|
||||
for (const user of options.users ?? ["alice", "bob", "carol"]) {
|
||||
db.sqlite
|
||||
.prepare("INSERT INTO users (id, username, is_admin) VALUES (?, ?, ?)")
|
||||
|
||||
@@ -28,6 +28,28 @@ async function present(s: TestServer, roomId: string, user = "alice") {
|
||||
}
|
||||
|
||||
describe("collab rooms", () => {
|
||||
it("resolves a synced host to the server ID only with connect access", async () => {
|
||||
server = await startServer({ hostIds: [41, 42], accessibleHostIds: [42] });
|
||||
server.db.sqlite.exec("UPDATE ssh_data SET sync_id = 'shared-host'");
|
||||
expect(await server.request("GET", "/meeting-host/shared-host")).toEqual({
|
||||
status: 200,
|
||||
body: { id: 42 },
|
||||
});
|
||||
server.db.sqlite.exec(
|
||||
"UPDATE ssh_data SET sync_id = 'private-host' WHERE id = 41",
|
||||
);
|
||||
expect(
|
||||
(await server.request("GET", "/meeting-host/private-host")).status,
|
||||
).toBe(404);
|
||||
expect(
|
||||
(await server.request("GET", "/meeting-host/missing-host")).status,
|
||||
).toBe(404);
|
||||
expect(
|
||||
(await server.request("GET", "/meeting-host/shared-host", { user: null }))
|
||||
.status,
|
||||
).toBe(401);
|
||||
});
|
||||
|
||||
it("creates a room with the creator as host and hides the guest token", async () => {
|
||||
server = await startServer();
|
||||
const res = await server.request("POST", "/rooms", {
|
||||
|
||||
Reference in new issue
Block a user