mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 15:15:24 +00:00
fix: proxmox guest sync, startup snippet sync, drop dead cloudflare ssh transport
This commit is contained in:
1 parent
44062e30d1
commit
ffa872ebd3
19 files changed
+270
-292
No files matched your search
@@ -0,0 +1,61 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
getProxmoxSource,
|
||||
indexImportedGuests,
|
||||
proxmoxSourceKey,
|
||||
} from "../../src/backend/guest-sync.js";
|
||||
|
||||
const source = {
|
||||
source: "proxmox",
|
||||
sourceHostId: 1,
|
||||
node: "pve",
|
||||
vmid: 101,
|
||||
type: "qemu",
|
||||
};
|
||||
|
||||
describe("getProxmoxSource", () => {
|
||||
it("reads the source from an object or a JSON string", () => {
|
||||
expect(getProxmoxSource({ source })).toEqual(source);
|
||||
expect(getProxmoxSource(JSON.stringify({ source }))).toEqual(source);
|
||||
});
|
||||
|
||||
it("refuses a malformed source", () => {
|
||||
expect(getProxmoxSource(null)).toBeNull();
|
||||
expect(getProxmoxSource({ source: { ...source, vmid: "101" } })).toBeNull();
|
||||
expect(getProxmoxSource({ source: { ...source, type: "vm" } })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("indexImportedGuests", () => {
|
||||
// The host row carries no proxmoxConfig since 2.9.0; the source only
|
||||
// exists in the plugin's host settings.
|
||||
const hosts = [
|
||||
{ id: 10, name: "guest-a" },
|
||||
{ id: 11, name: "guest-b" },
|
||||
{ id: 12, name: "manual" },
|
||||
];
|
||||
|
||||
it("matches hosts to guests through their settings", () => {
|
||||
const index = indexImportedGuests(
|
||||
hosts,
|
||||
[
|
||||
{ hostId: 10, value: { source, lastSyncAt: "x" } },
|
||||
{ hostId: 11, value: { source: { ...source, sourceHostId: 2 } } },
|
||||
],
|
||||
1,
|
||||
);
|
||||
expect([...index.keys()]).toEqual([proxmoxSourceKey(source as never)]);
|
||||
const entry = index.get("1:pve:qemu:101")!;
|
||||
expect(entry.host.id).toBe(10);
|
||||
expect(entry.config.lastSyncAt).toBe("x");
|
||||
});
|
||||
|
||||
it("ignores settings for hosts the user does not own", () => {
|
||||
const index = indexImportedGuests(
|
||||
hosts,
|
||||
[{ hostId: 99, value: { source } }],
|
||||
1,
|
||||
);
|
||||
expect(index.size).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user