mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-31 07:35:24 +00:00
* feat: shell controller, TabStage, layout and theme plugins with repair view * feat: move the classic layout into its own bundled plugin * feat: move color themes into a bundled themes plugin * fix: plugin tests and type checks work with a linked sdk * fix: home tab, layout switch and missing layout fallbacks for looks * chore: add classic layout and themes to the readme * chore: drop example plugin links from the plugin guide * feat: plugin filters by type, paged browse, hide plugins needing newer termix * feat: move desktop, status, import, audit and branding features into plugins * feat: host lock api so a plugin can load hosts from a config file (#1581) * chore: add hosts config to the plugin table * feat: login policy hook for plugins and optional https redirect (#1584) * chore: add login security to the plugin table * feat: api key socket tickets so a master can open remote sessions (#1654) * feat: sync moves to a plugin, desktop gets multiple accounts (#1580, #1654) * chore: add sync to the plugin table * feat: move the sync screens and wizard out of core into the plugin (#1580) * fix: add a neutral linked desktop hook for plugins (#1580) * fix: show the linked account's name and admin flag in the app (#1580) * feat: ssh transport providers, core ssh relay and plugin folders api * feat: support FIDO2 security keys through ssh agent * feat: add companion panels beside host tabs * feat: mTLS client certificates for desktop server links * feat: native web view for plugins in the desktop app * fix: detect the desktop link window by Electron's default user agent Fixes #1675 * fix: changelog for desktop link fix * fix: keep text primary keys in the plugin data export * fix: ship sharp binaries for Windows arm64 builds * feat: client cert on the sync link types (sdk 1.0.18) * chore: update translations * feat: themed title bar for the desktop app (#1690) * chore: changelog for the themed title bar * fix: draw the title bar in the sidebar color * feat: per host layout for the terminal panel bar * chore: sdk 1.0.19 for the panel bar layout * chore: bundle all 43 plugins for 26.10.3 * chore: update translations --------- Co-authored-by: SirHephaistos <60616553+SirHephaistos@users.noreply.github.com> Co-authored-by: Giovanny Aranda <garanda21@gmail.com>
110 lines
2.8 KiB
TypeScript
110 lines
2.8 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import express, {
|
|
type NextFunction,
|
|
type Request,
|
|
type RequestHandler,
|
|
type Response,
|
|
} from "express";
|
|
|
|
const state = vi.hoisted(() => ({
|
|
settings: {} as Record<string, string>,
|
|
}));
|
|
|
|
vi.mock("../../../utils/logger.js", () => ({
|
|
authLogger: { warn: vi.fn(), error: vi.fn(), info: vi.fn() },
|
|
databaseLogger: { warn: vi.fn(), error: vi.fn(), info: vi.fn() },
|
|
}));
|
|
|
|
vi.mock("../../../database/repositories/factory.js", () => ({
|
|
createCurrentSettingsRepository: () => ({
|
|
get: async (key: string) => state.settings[key] ?? null,
|
|
}),
|
|
}));
|
|
|
|
const { registerBrandingRoutes } =
|
|
await import("../../../database/routes/branding-routes.js");
|
|
|
|
interface RouteLayer {
|
|
route?: {
|
|
path: string;
|
|
methods: Record<string, boolean>;
|
|
stack: Array<{ handle: RequestHandler }>;
|
|
};
|
|
}
|
|
|
|
function routesOf(router: express.Router) {
|
|
return (router as unknown as { stack: RouteLayer[] }).stack
|
|
.filter((layer) => layer.route)
|
|
.map((layer) => ({
|
|
path: layer.route!.path,
|
|
methods: Object.keys(layer.route!.methods),
|
|
handlers: layer.route!.stack.map((entry) => entry.handle),
|
|
}));
|
|
}
|
|
|
|
async function call(handler: RequestHandler) {
|
|
const result = { statusCode: 200, body: null as unknown };
|
|
const res = {
|
|
status(code: number) {
|
|
result.statusCode = code;
|
|
return this;
|
|
},
|
|
json(payload: unknown) {
|
|
result.body = payload;
|
|
return this;
|
|
},
|
|
} as unknown as Response;
|
|
await handler(
|
|
{ body: {}, headers: {} } as Request,
|
|
res,
|
|
(() => {}) as NextFunction,
|
|
);
|
|
return result;
|
|
}
|
|
|
|
beforeEach(() => {
|
|
state.settings = {};
|
|
});
|
|
|
|
describe("GET /users/branding", () => {
|
|
it("is the only branding route and has no auth handler", () => {
|
|
const router = express.Router();
|
|
registerBrandingRoutes(router);
|
|
const routes = routesOf(router);
|
|
|
|
expect(routes).toHaveLength(1);
|
|
expect(routes[0].path).toBe("/branding");
|
|
expect(routes[0].methods).toEqual(["get"]);
|
|
expect(routes[0].handlers).toHaveLength(1);
|
|
});
|
|
|
|
it("answers defaults when nothing is set", async () => {
|
|
const router = express.Router();
|
|
registerBrandingRoutes(router);
|
|
const response = await call(routesOf(router)[0].handlers[0]);
|
|
|
|
expect(response.statusCode).toBe(200);
|
|
expect(response.body).toEqual({
|
|
appName: "Termix",
|
|
tagline: "",
|
|
logo: null,
|
|
});
|
|
});
|
|
|
|
it("keeps serving the stored branding of an older install", async () => {
|
|
state.settings = {
|
|
branding_app_name: "Acme",
|
|
branding_tagline: "Ops",
|
|
};
|
|
const router = express.Router();
|
|
registerBrandingRoutes(router);
|
|
const response = await call(routesOf(router)[0].handlers[0]);
|
|
|
|
expect(response.body).toEqual({
|
|
appName: "Acme",
|
|
tagline: "Ops",
|
|
logo: null,
|
|
});
|
|
});
|
|
});
|