Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+73
@@ -0,0 +1,73 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildVaultDetailVM,
|
||||
buildVaultListVM,
|
||||
buildAdminVaultListVM,
|
||||
PASSWORD_SAFE_COPY_AUTO_CLEAR_MS,
|
||||
type EntryRow,
|
||||
} from "./hr-password-safe.vm.js";
|
||||
|
||||
// AK-P17a — the password-safe VMs carry the security-critical "never list a
|
||||
// secret value" contract. These pure-function tests lock that contract in.
|
||||
|
||||
const entry = (overrides: Partial<EntryRow> = {}): EntryRow => ({
|
||||
id: "e1",
|
||||
title: "Router admin",
|
||||
tags: ["network"],
|
||||
url: "https://router.local",
|
||||
hasUsername: true,
|
||||
hasPassword: true,
|
||||
hasNotes: false,
|
||||
revealHref: "/acme/hr/password-safe/v1/reveal",
|
||||
...overrides,
|
||||
});
|
||||
|
||||
describe("buildVaultDetailVM", () => {
|
||||
it("never exposes a secret value field on an entry row", () => {
|
||||
const vm = buildVaultDetailVM({ vaultId: "v1", vaultName: "Ops", accessLevel: "read", rows: [entry()], exportHref: "/x" });
|
||||
expect(vm.status).toBe("ready");
|
||||
const row = vm.data!.rows[0]! as unknown as Record<string, unknown>;
|
||||
// Only presence flags are allowed — never the plaintext.
|
||||
expect(row).not.toHaveProperty("username");
|
||||
expect(row).not.toHaveProperty("password");
|
||||
expect(row).not.toHaveProperty("notes");
|
||||
expect(row.hasUsername).toBe(true);
|
||||
expect(row.hasPassword).toBe(true);
|
||||
});
|
||||
|
||||
it("derives canWrite/canManageAccess from the access level", () => {
|
||||
expect(buildVaultDetailVM({ vaultId: "v1", vaultName: "Ops", accessLevel: "read", rows: [], exportHref: "/x" }).data?.canWrite).toBe(false);
|
||||
expect(buildVaultDetailVM({ vaultId: "v1", vaultName: "Ops", accessLevel: "write", rows: [], exportHref: "/x" }).data?.canWrite).toBe(true);
|
||||
expect(buildVaultDetailVM({ vaultId: "v1", vaultName: "Ops", accessLevel: "read", rows: [], exportHref: "/x" }).data?.canManageAccess).toBe(false);
|
||||
expect(buildVaultDetailVM({ vaultId: "v1", vaultName: "Ops", accessLevel: "admin", rows: [], exportHref: "/x" }).data?.canManageAccess).toBe(true);
|
||||
});
|
||||
|
||||
it("enforces the 30s clipboard auto-clear window", () => {
|
||||
const vm = buildVaultDetailVM({ vaultId: "v1", vaultName: "Ops", accessLevel: "read", rows: [], exportHref: "/x" });
|
||||
expect(vm.data?.copyAutoClearMs).toBe(30_000);
|
||||
expect(PASSWORD_SAFE_COPY_AUTO_CLEAR_MS).toBe(30_000);
|
||||
});
|
||||
|
||||
it("keeps an empty vault in a ready state with a plain-text empty state", () => {
|
||||
const vm = buildVaultDetailVM({ vaultId: "v1", vaultName: "Ops", accessLevel: "read", rows: [], exportHref: "/x" });
|
||||
expect(vm.status).toBe("ready");
|
||||
expect(vm.data?.rows).toHaveLength(0);
|
||||
expect(vm.data?.emptyHeadlineKey).toBe("hr.passwordSafe.entries.empty.headline");
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildVaultListVM / buildAdminVaultListVM", () => {
|
||||
it("the admin vault row carries only metadata + counts, never entry contents", () => {
|
||||
const vm = buildAdminVaultListVM({ rows: [{ id: "v1", name: "Ops", entryCount: 3, accessCount: 2, archived: false, detailHref: "/x" }] });
|
||||
const row = vm.data!.rows[0]! as unknown as Record<string, unknown>;
|
||||
expect(row).not.toHaveProperty("entries");
|
||||
expect(row.entryCount).toBe(3);
|
||||
expect(row.accessCount).toBe(2);
|
||||
});
|
||||
|
||||
it("an empty vault list stays ready with the empty-state keys", () => {
|
||||
const vm = buildVaultListVM({ rows: [], canCreate: true, createHref: "/x" });
|
||||
expect(vm.status).toBe("ready");
|
||||
expect(vm.data?.emptyHeadlineKey).toBe("hr.passwordSafe.empty.headline");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user