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

@@ -71,7 +71,7 @@ describe("createHiveGridClient — idempotency edge cases", () => {
});
describe("createHiveGridClient — URL building", () => {
it("uses an absolute path verbatim instead of prefixing the base url", async () => {
it("allows an absolute path only when it stays on the configured origin", async () => {
const captured: { url: string | null } = { url: null };
const stub: typeof fetch = (async (url: string) => {
captured.url = url;
@@ -79,8 +79,47 @@ describe("createHiveGridClient — URL building", () => {
}) as unknown as typeof fetch;
const client = createHiveGridClient({ baseUrl: "https://api.example.com", fetch: stub });
await client.request({ method: "GET", path: "https://other.example.test/v2/thing" });
expect(captured.url).toBe("https://other.example.test/v2/thing");
await client.request({ method: "GET", path: "https://api.example.com/v2/thing" });
expect(captured.url).toBe("https://api.example.com/v2/thing");
});
it.each(["https://other.example.test/v2/thing", "//other.example.test/v2/thing"])(
"fails closed for a cross-origin request path: %s",
async (path) => {
let calls = 0;
const stub: typeof fetch = (async () => {
calls += 1;
return jsonResponse(200, {});
}) as unknown as typeof fetch;
const client = createHiveGridClient({
baseUrl: "https://api.example.com",
auth: { apiKey: "must-not-leak" },
tenantId: "tenant-must-not-leak",
fetch: stub,
});
await expect(client.request({ method: "GET", path })).rejects.toThrow(/cross-origin/);
expect(calls).toBe(0);
},
);
it("disables automatic redirects so custom credentials cannot cross origins", async () => {
const captured: { redirect: RequestRedirect | undefined; calls: number } = { redirect: undefined, calls: 0 };
const stub: typeof fetch = (async (_url: unknown, init: RequestInit) => {
captured.calls += 1;
captured.redirect = init.redirect;
return new Response(null, { status: 302, headers: { location: "https://other.example.test/collect" } });
}) as unknown as typeof fetch;
const client = createHiveGridClient({
baseUrl: "https://api.example.com",
auth: { apiKey: "must-not-leak" },
retry: { maxAttempts: 1 },
fetch: stub,
});
await expect(client.request({ method: "GET", path: "/v1/redirect" })).rejects.toMatchObject({ status: 302 });
expect(captured.redirect).toBe("manual");
expect(captured.calls).toBe(1);
});
it("skips undefined query values while serializing the rest", async () => {