mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
feat: harden plugin api for separate repos, signed updates and generic external login
This commit is contained in:
1 parent
fb9c168b6b
commit
80944301dd
310 files changed
+6577
-4927
No files matched your search
@@ -20,7 +20,7 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
function fakeHosts(hosts: PluginHostSummary[]): PluginHosts {
|
||||
return {
|
||||
return <PluginHosts>(<unknown>{
|
||||
list: async () => hosts,
|
||||
get: async (hostId) => hosts.find((h) => h.id === hostId) ?? null,
|
||||
checkAccess: async (hostId) => {
|
||||
@@ -37,7 +37,7 @@ function fakeHosts(hosts: PluginHostSummary[]): PluginHosts {
|
||||
share: async (hostId) => ({ hostId, shared: true }),
|
||||
listUsers: async () => [],
|
||||
listRoles: async () => [],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function setup(hosts: PluginHostSummary[]) {
|
||||
|
||||
@@ -19,15 +19,14 @@ describe("fleets.access", () => {
|
||||
const service = server.mock.services.get("fleets.access") as FleetsService;
|
||||
|
||||
await expect(
|
||||
server.mock.ctx.asUser("user-1", () => service.create({ name: "prod" })),
|
||||
server.mock.actAs("user-1", () => service.create({ name: "prod" })),
|
||||
).rejects.toThrow("fleets.manage");
|
||||
});
|
||||
|
||||
it("adds only hosts the caller can see", async () => {
|
||||
server = await startServer();
|
||||
const service = server.mock.services.get("fleets.access") as FleetsService;
|
||||
const run = <T>(fn: () => Promise<T>) =>
|
||||
server!.mock.ctx.asUser("user-1", fn);
|
||||
const run = <T>(fn: () => Promise<T>) => server!.mock.actAs("user-1", fn);
|
||||
|
||||
const fleet = await run(() => service.create({ name: "prod" }));
|
||||
await run(() => service.addMember(fleet.id, 10));
|
||||
|
||||
Reference in new issue
Block a user