Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -25,6 +25,9 @@ vi.mock("@hivegrid/shared-store", () => ({
vi.mock("~/shared-store.server", () => ({
getSharedStore: () => ({}),
}));
vi.mock("~/services/auth/auth-rate-limit-key.server", () => ({
getPseudonymousAuthBucketKey: ({ scope }: { scope?: string }) => `pseudonymous-${scope ?? "pair"}`,
}));
vi.mock("~/utils/services/.server/urlService", () => ({
getTenantIdFromUrl: (...args: unknown[]) => getTenantIdMock(...args),
@@ -171,7 +174,8 @@ describe("plugins API route", () => {
}),
headers: {
"content-type": "application/json",
"x-forwarded-for": "203.0.113.9, 198.51.100.99",
"cf-connecting-ip": "203.0.113.9",
"x-forwarded-for": "198.51.100.99, 173.245.48.10",
},
}),
params: { tenant: "tenant-attacker" },
@@ -180,8 +184,8 @@ describe("plugins API route", () => {
expect(response.status).toBe(201);
expect(verifyPermissionMock).toHaveBeenCalledWith(expect.any(Request), "app.plugins.manage", "tenant-canonical");
expect(consumeMock).toHaveBeenCalledWith("tenant:tenant-canonical");
expect(consumeMock).toHaveBeenCalledWith("ip:203.0.113.9");
expect(consumeMock).toHaveBeenCalledWith("pseudonymous-identifier");
expect(consumeMock).toHaveBeenCalledWith("pseudonymous-client");
expect(installMock).toHaveBeenCalledWith({
tenantId: "tenant-canonical",
manifestJson: { id: "com.acme.hi" },
@@ -331,7 +335,8 @@ describe("plugins API route", () => {
}),
headers: {
"content-type": "application/json",
"x-forwarded-for": "203.0.113.9",
"cf-connecting-ip": "203.0.113.9",
"x-forwarded-for": "198.51.100.99, 173.245.48.10",
},
}),
params: { tenant: "t-1" },
@@ -782,7 +787,8 @@ describe("plugins API route", () => {
body: JSON.stringify({ pluginId: "com.acme.hello", capabilityNames: ["http.outbound"] }),
headers: {
"content-type": "application/json",
"x-forwarded-for": "203.0.113.9",
"cf-connecting-ip": "203.0.113.9",
"x-forwarded-for": "198.51.100.99, 173.245.48.10",
},
}),
params: { tenant: "t-1" },
@@ -1127,7 +1133,7 @@ describe("plugins API route", () => {
expect(response.headers.get("Retry-After")).toBe("60");
const body = await response.json();
expect(body.error).toBe("rate_limit_exceeded");
expect(consumeMock).toHaveBeenCalledWith("tenant:t-1");
expect(consumeMock).toHaveBeenCalledWith("pseudonymous-identifier");
expect(consumeMock).toHaveBeenCalledTimes(1);
expect(installMock).not.toHaveBeenCalled();
});
@@ -1144,7 +1150,11 @@ describe("plugins API route", () => {
wasmSha256: "a".repeat(64),
signaturePublicKey: "c".repeat(64),
}),
headers: { "content-type": "application/json", "x-forwarded-for": "203.0.113.10, 198.51.100.1" },
headers: {
"content-type": "application/json",
"cf-connecting-ip": "203.0.113.10",
"x-forwarded-for": "198.51.100.1, 173.245.48.10",
},
}),
params: { tenant: "t-1" },
context: {},
@@ -1153,12 +1163,12 @@ describe("plugins API route", () => {
expect(response.status).toBe(429);
expect(response.headers.get("Retry-After")).toBe("60");
await expect(response.json()).resolves.toMatchObject({ error: "rate_limit_exceeded" });
expect(consumeMock).toHaveBeenNthCalledWith(1, "tenant:t-1");
expect(consumeMock).toHaveBeenNthCalledWith(2, "ip:203.0.113.10");
expect(consumeMock).toHaveBeenNthCalledWith(1, "pseudonymous-identifier");
expect(consumeMock).toHaveBeenNthCalledWith(2, "pseudonymous-client");
expect(installMock).not.toHaveBeenCalled();
});
test("fails open and installs when the limiter throws", async () => {
test("fails closed in every environment when the limiter throws", async () => {
consumeMock.mockImplementationOnce(async () => {
throw new Error("Redis connection refused");
});
@@ -1177,8 +1187,10 @@ describe("plugins API route", () => {
params: { tenant: "t-1" },
context: {},
})) as Response;
expect(response.status).toBe(201);
expect(installMock).toHaveBeenCalledOnce();
expect(response.status).toBe(503);
expect(response.headers.get("Retry-After")).toBe("60");
await expect(response.json()).resolves.toMatchObject({ error: "rate_limit_unavailable" });
expect(installMock).not.toHaveBeenCalled();
});
test("fails closed in production when rate-limit storage is unavailable", async () => {
@@ -1270,8 +1282,8 @@ describe("plugins API route", () => {
params: { tenant: "t-1" },
context: {},
});
expect(consumeMock).toHaveBeenCalledWith("tenant:t-1");
expect(consumeMock).toHaveBeenCalledWith("ip:203.0.113.11");
expect(consumeMock).toHaveBeenCalledWith("pseudonymous-identifier");
expect(consumeMock).toHaveBeenCalledWith("pseudonymous-client");
});
});