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

@@ -11,6 +11,8 @@ import {
__setMcpRateLimitStoreForTests,
} from "./rate-limit.js";
const TEST_BUCKET_SECRET = "mcp-rate-limit-test-secret-32-bytes-long";
beforeEach(() => {
__setMcpRateLimitStoreForTests(createSharedStore({ namespace: "test-mcp-rate-limit" }));
});
@@ -26,26 +28,28 @@ describe("checkMcpRateLimit weighting", () => {
// full batches to exhaust the per-hour budget must be blocked afterwards.
const batches = MCP_KEY_RATE_LIMIT_PER_HOUR / MCP_MAX_BATCH_OPERATIONS;
for (let index = 0; index < batches; index += 1) {
expect((await checkMcpRateLimit({ apiKeyId: "k1", tenantId: "t1", weight: MCP_MAX_BATCH_OPERATIONS })).allowed).toBe(true);
expect((await checkMcpRateLimit({ apiKeyId: "k1", tenantId: "t1", bucketKeySecret: TEST_BUCKET_SECRET, weight: MCP_MAX_BATCH_OPERATIONS })).allowed).toBe(
true
);
}
const overflow = await checkMcpRateLimit({ apiKeyId: "k1", tenantId: "t1", weight: 1 });
const overflow = await checkMcpRateLimit({ apiKeyId: "k1", tenantId: "t1", bucketKeySecret: TEST_BUCKET_SECRET, weight: 1 });
expect(overflow.allowed).toBe(false);
});
it("defaults to a single token when no weight is given", async () => {
for (let index = 0; index < MCP_KEY_RATE_LIMIT_PER_HOUR; index += 1) {
expect((await checkMcpRateLimit({ apiKeyId: "k2", tenantId: "t2" })).allowed).toBe(true);
expect((await checkMcpRateLimit({ apiKeyId: "k2", tenantId: "t2", bucketKeySecret: TEST_BUCKET_SECRET })).allowed).toBe(true);
}
expect((await checkMcpRateLimit({ apiKeyId: "k2", tenantId: "t2" })).allowed).toBe(false);
expect((await checkMcpRateLimit({ apiKeyId: "k2", tenantId: "t2", bucketKeySecret: TEST_BUCKET_SECRET })).allowed).toBe(false);
});
});
describe("checkMcpPreAuthIpRateLimit", () => {
it("sheds an unauthenticated flood from a single IP after the per-minute cap", async () => {
for (let index = 0; index < MCP_PREAUTH_IP_RATE_LIMIT_PER_MINUTE; index += 1) {
expect((await checkMcpPreAuthIpRateLimit("203.0.113.5")).allowed).toBe(true);
expect((await checkMcpPreAuthIpRateLimit("203.0.113.5", TEST_BUCKET_SECRET)).allowed).toBe(true);
}
const blocked = await checkMcpPreAuthIpRateLimit("203.0.113.5");
const blocked = await checkMcpPreAuthIpRateLimit("203.0.113.5", TEST_BUCKET_SECRET);
expect(blocked.allowed).toBe(false);
if (!blocked.allowed) {
expect(blocked.status).toBe(429);
@@ -54,8 +58,12 @@ describe("checkMcpPreAuthIpRateLimit", () => {
it("keys the shield per IP so distinct IPs do not share a bucket", async () => {
for (let index = 0; index < MCP_PREAUTH_IP_RATE_LIMIT_PER_MINUTE; index += 1) {
await checkMcpPreAuthIpRateLimit("203.0.113.5");
await checkMcpPreAuthIpRateLimit("203.0.113.5", TEST_BUCKET_SECRET);
}
expect((await checkMcpPreAuthIpRateLimit("203.0.113.6")).allowed).toBe(true);
expect((await checkMcpPreAuthIpRateLimit("203.0.113.6", TEST_BUCKET_SECRET)).allowed).toBe(true);
});
it("fails closed when the bucket HMAC secret is weak", async () => {
await expect(checkMcpPreAuthIpRateLimit("203.0.113.5", "weak")).rejects.toThrow("bucket secret");
});
});