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
@@ -2,123 +2,14 @@ import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
buildAuditLogWhereFromFilters,
|
||||
createLegacyEntityWebhookLog,
|
||||
createLegacyRowLog,
|
||||
getAdminAuditLogList,
|
||||
getLegacyEntityWebhooksByAction,
|
||||
getTenantAuditLogList,
|
||||
redactLogDetails,
|
||||
serializeAdminAuditLogsCsv,
|
||||
type AdminAuditLogClient,
|
||||
type AdminAuditLogRow,
|
||||
type LegacyEntityWebhookClient,
|
||||
type LegacyLogWriterClient,
|
||||
} from "./logs.server.js";
|
||||
|
||||
describe("legacy row log writes", () => {
|
||||
it("normalizes nullable row log fields before writing", async () => {
|
||||
const client: LegacyLogWriterClient = {
|
||||
log: {
|
||||
create: vi.fn().mockResolvedValue({ id: "log_1" }),
|
||||
},
|
||||
} as unknown as LegacyLogWriterClient;
|
||||
|
||||
await expect(
|
||||
createLegacyRowLog(
|
||||
{
|
||||
tenantId: "tenant_1",
|
||||
apiKeyId: "api_key_1",
|
||||
url: "/api/contacts",
|
||||
rowId: "row_1",
|
||||
action: "created",
|
||||
},
|
||||
client,
|
||||
),
|
||||
).resolves.toEqual({ id: "log_1" });
|
||||
|
||||
expect(client.log.create).toHaveBeenCalledWith({
|
||||
data: {
|
||||
tenantId: "tenant_1",
|
||||
userId: null,
|
||||
apiKeyId: "api_key_1",
|
||||
url: "/api/contacts",
|
||||
rowId: "row_1",
|
||||
action: "created",
|
||||
details: null,
|
||||
commentId: null,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("redacts sensitive row log details before writing", async () => {
|
||||
const client: LegacyLogWriterClient = {
|
||||
log: {
|
||||
create: vi.fn().mockResolvedValue({ id: "log_1" }),
|
||||
},
|
||||
} as unknown as LegacyLogWriterClient;
|
||||
|
||||
await createLegacyRowLog(
|
||||
{
|
||||
tenantId: "tenant_1",
|
||||
url: "/api/contacts",
|
||||
action: "updated",
|
||||
details: JSON.stringify({ token: "secret-token", nested: { authorization: "Bearer secret", kept: "value" } }),
|
||||
},
|
||||
client,
|
||||
);
|
||||
|
||||
const details = vi.mocked(client.log.create).mock.calls[0]?.[0].data.details;
|
||||
expect(details).toBe('{"token":"[REDACTED]","nested":{"authorization":"[REDACTED]","kept":"value"}}');
|
||||
expect(details).not.toContain("secret-token");
|
||||
expect(details).not.toContain("Bearer secret");
|
||||
});
|
||||
});
|
||||
|
||||
describe("legacy entity webhook reads and logs", () => {
|
||||
it("fetches entity webhooks for an action", async () => {
|
||||
const client: LegacyEntityWebhookClient = {
|
||||
entityWebhook: {
|
||||
findMany: vi.fn().mockResolvedValue([{ id: "webhook_1", method: "POST", endpoint: "/hook" }]),
|
||||
},
|
||||
entityWebhookLog: {
|
||||
create: vi.fn(),
|
||||
},
|
||||
} as unknown as LegacyEntityWebhookClient;
|
||||
|
||||
await expect(getLegacyEntityWebhooksByAction("entity_1", "Created", client)).resolves.toEqual([
|
||||
{ id: "webhook_1", method: "POST", endpoint: "/hook" },
|
||||
]);
|
||||
expect(client.entityWebhook.findMany).toHaveBeenCalledWith({
|
||||
where: {
|
||||
entityId: "entity_1",
|
||||
action: "Created",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("records entity webhook delivery status", async () => {
|
||||
const client: LegacyEntityWebhookClient = {
|
||||
entityWebhook: {
|
||||
findMany: vi.fn(),
|
||||
},
|
||||
entityWebhookLog: {
|
||||
create: vi.fn().mockResolvedValue({ id: "webhook_log_1" }),
|
||||
},
|
||||
} as unknown as LegacyEntityWebhookClient;
|
||||
|
||||
await expect(createLegacyEntityWebhookLog({ webhookId: "webhook_1", logId: "log_1", status: 202 }, client)).resolves.toEqual({
|
||||
id: "webhook_log_1",
|
||||
});
|
||||
expect(client.entityWebhookLog.create).toHaveBeenCalledWith({
|
||||
data: {
|
||||
webhookId: "webhook_1",
|
||||
logId: "log_1",
|
||||
status: 202,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("admin audit log list filters", () => {
|
||||
it("builds focused where input from supported filters", () => {
|
||||
const where = buildAuditLogWhereFromFilters({
|
||||
@@ -180,7 +71,6 @@ describe("admin audit log list filters", () => {
|
||||
user: { select: { id: true, email: true, firstName: true, lastName: true } },
|
||||
tenant: { select: { id: true, name: true, slug: true } },
|
||||
apiKey: { select: { id: true, alias: true } },
|
||||
comment: { select: { id: true, value: true } },
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 500,
|
||||
@@ -245,7 +135,6 @@ describe("tenant audit log list filters", () => {
|
||||
user: { select: { id: true, email: true, firstName: true, lastName: true } },
|
||||
tenant: { select: { id: true, name: true, slug: true } },
|
||||
apiKey: { select: { id: true, alias: true } },
|
||||
comment: { select: { id: true, value: true } },
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 25,
|
||||
@@ -272,7 +161,6 @@ describe("tenant audit log list filters", () => {
|
||||
user: { select: { id: true, email: true, firstName: true, lastName: true } },
|
||||
tenant: { select: { id: true, name: true, slug: true } },
|
||||
apiKey: { select: { id: true, alias: true } },
|
||||
comment: { select: { id: true, value: true } },
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 500,
|
||||
@@ -294,7 +182,6 @@ describe("serializeAdminAuditLogsCsv", () => {
|
||||
tenant: null,
|
||||
user: null,
|
||||
apiKey: null,
|
||||
comment: null,
|
||||
details: null,
|
||||
}),
|
||||
]),
|
||||
@@ -341,15 +228,12 @@ function makeAuditRow(overrides: Partial<AdminAuditLogRow> = {}): AdminAuditLogR
|
||||
tenantId: "tenant_1",
|
||||
userId: "user_1",
|
||||
apiKeyId: null,
|
||||
rowId: null,
|
||||
url: "/api/contacts",
|
||||
action: "create",
|
||||
details: "Created contact",
|
||||
commentId: null,
|
||||
tenant: { id: "tenant_1", name: "Tenant One", slug: "tenant-one" },
|
||||
user: { id: "user_1", email: "user@example.com", firstName: "User", lastName: "One" },
|
||||
apiKey: null,
|
||||
comment: null,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user