Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

1.3 KB
Raw Blame
import { createTenantAuthority } from "./authority";
import type { TenantAddress, TenantBinding, TenantStoredValue, TenantStoragePort } from "./types";

export function tenantFixture() {
  let now = 1000;
  const bindings: Record<string, TenantBinding> = {
    alice: { tenantId: "tenant-a", principalId: "principal-a", mappingRevision: 1, enabled: true, tenantEnabled: true },
    bob: { tenantId: "tenant-b", principalId: "principal-b", mappingRevision: 1, enabled: true, tenantEnabled: true },
  };
  const reads: TenantAddress[] = [];
  let override: ((address: Readonly<TenantAddress>) => TenantStoredValue | null) | undefined;
  const storage: TenantStoragePort = {
    read: async (address) => {
      reads.push({ ...address });
      return override ? override(address) : { ...address, value: address.tenantId + ":" + address.key };
    },
  };
  const authority = createTenantAuthority({
    resolve: async (identity) => identity.issuer === "mso-local" && bindings[identity.subject]
      ? { ...bindings[identity.subject] } : null,
  }, storage, () => now);
  return { authority, bindings, reads, storage,
    identity: (subject = "alice") => ({ issuer: "mso-local", subject, expiresAt: 5000 }),
    setNow: (value: number) => { now = value; },
    overrideRead: (value: typeof override) => { override = value; },
  };
}