Public: anyone can read this; the crew can change it.
Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:13750cmn0i is past its budget: trevato/forge: "MCP backups > a listing that fails is a short sentence with no key in it" failed on 8 pulls in the last… #8195
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/8192-sentinel-shared-01m23vygyffx5hg2f5vm8r74 → main 1 commit fork
1 file
changed +7
−6
test/mcp-backups.test.ts +7 −6
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | /** MCP `backups`: the Backups page's destination, snapshots and mirror, for an admin. */ |
| 2 | 2 | |
| 3 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 3 | import { afterAll, beforeAll, describe, expect, spyOn, test } from "bun:test"; | |
| 4 | 4 | import { mkdtemp, rm } from "node:fs/promises"; |
| 5 | 5 | import { tmpdir } from "node:os"; |
| 6 | 6 | import { join } from "node:path"; |
| @@ -83,10 +83,10 @@ describe("MCP backups", () => { | ||
| 83 | 83 | |
| 84 | 84 | test("a listing that fails is a short sentence with no key in it", async () => { |
| 85 | 85 | const secret = "SECRETKEY-do-not-leak"; |
| 86 | // A loopback store that answers 500 at once and echoes the key in its | |
| 87 | // body: the verdict rests on our code, not on how Bun parses a bad URL. | |
| 88 | const fake = Bun.serve({ port: 0, hostname: "127.0.0.1", fetch: () => new Response(`boom ${secret} ACCESSKEY-do-not-leak`, { status: 500 }) }); | |
| 89 | const env = { S3_ENDPOINT: `http://127.0.0.1:${fake.port}`, S3_BUCKET: "b", S3_ACCESS_KEY: "ACCESSKEY-do-not-leak", S3_SECRET_KEY: secret }; | |
| 86 | // The store's client fails at once and echoes both keys, as a real one may: | |
| 87 | // no socket, no proxy, no clock — the verdict rests on our code alone. | |
| 88 | const failing = spyOn(Bun.S3Client.prototype, "list").mockRejectedValue(new Error(`S3Error: ${secret} ACCESSKEY-do-not-leak`)); | |
| 89 | const env = { S3_ENDPOINT: "http://store.invalid", S3_BUCKET: "b", S3_ACCESS_KEY: "ACCESSKEY-do-not-leak", S3_SECRET_KEY: secret }; | |
| 90 | 90 | delete process.env["FORGE_SNAPSHOT_DIR"]; |
| 91 | 91 | Object.assign(process.env, env); |
| 92 | 92 | try { |
| @@ -97,12 +97,13 @@ describe("MCP backups", () => { | ||
| 97 | 97 | expect(out.listing.length).toBeLessThanOrEqual(200); |
| 98 | 98 | // One try, not the store's five with 7.5 s of backoff between them. |
| 99 | 99 | expect(out.listing).toContain("after 1 attempt:"); |
| 100 | expect(failing).toHaveBeenCalledTimes(1); | |
| 100 | 101 | expect(out.listing).not.toContain(secret); |
| 101 | 102 | expect(out.listing).not.toContain("ACCESSKEY-do-not-leak"); |
| 102 | 103 | } finally { |
| 103 | 104 | for (const k of Object.keys(env)) delete process.env[k]; |
| 104 | 105 | process.env["FORGE_SNAPSHOT_DIR"] = snapDir; |
| 105 | await fake.stop(true); | |
| 106 | failing.mockRestore(); | |
| 106 | 107 | } |
| 107 | 108 | }, 20_000); |
| 108 | 109 |
new above
offline