Public: anyone can read this; the crew can change it.
MCP `backups_test`: check that the snapshot destination is reachable, as the Backups page's Test button does, for a forge admin #5437
scout/forge:scout/5428-mcp-backups-test-check-that-the-snapshot → main 1 commit fork
4 files
changed +163
−29
docs/MCP.md +1
| @@ -41,6 +41,7 @@ for a tunnel and a forge that sleeps. | ||
| 41 | 41 | | `pulls` | `{ repo, state?, limit? }`: a repository's pulls, newest first, one brief line each: `number`, `title`, `author`, `head`, `check` (state), `approvals`, `changesRequested`, `mergeable` (null once closed); `state` open (default) or closed, `limit` 1-50 (default 20); no bodies, no diffs | no | |
| 42 | 42 | | `read_file` | a file (utf-8, or base64 for binary) or a directory listing at a ref, as GET …/contents | no | |
| 43 | 43 | | `seal` | `{ repo, number, sealed }`: seal a security report (and the pull that fixes it) so only writers and the crew see it, or unseal it for every reader; a writer's, recorded | yes | |
| 44 | | `backups_test` | `{ endpoint?, bucket?, region?, accessKey?, secretKey? }` (forge admin): list the snapshot bucket and answer `{ reached, says }`, the sentence the Backups page's Test button shows; all four of endpoint, bucket, accessKey and secretKey test what is typed, none tests the destination in effect; no key is echoed | yes | | |
| 44 | 45 | | `secrets` | `{ scope, ref?, action, name?, value? }` (forge admin): `list` the names and timestamps of the forge's sealed secrets, `set` or `remove` one; `scope` is forge, org or repo, `ref` the org or `owner/name`; a value is never read back | yes | |
| 45 | 46 | | `org_teams` | `{ org, action, team, user?, permission? }` (admin-scope token, an org owner): `create` a team (`permission` read, write or admin; read by default), `add_member` a `user`, or `remove` the team; the same as POST/DELETE `/api/v1/orgs/:org/teams` | yes | |
| 46 | 47 | | `now` | what the crew is doing right now: who, on what, since when, at what cost; a planner that declined the direction and waits for you comes first (`run: null`, its words in `says`) | | |
src/http/mcp.ts +58 −29
| @@ -38,6 +38,7 @@ import { getOrg, listTeams, type Permission } from "../core/orgs.ts"; | ||
| 38 | 38 | import { changeTeam, planTeam, readTeams, TEAM_SAYS } from "../actions/teams.ts"; |
| 39 | 39 | import { readScorecards } from "../actions/scorecard.ts"; |
| 40 | 40 | import { createAgent, deleteAgent, updateAgent } from "../actions/crew.ts"; |
| 41 | import { testDestination } from "../actions/destination.ts"; | |
| 41 | 42 | import { listSecrets, putSecret, removeSecret } from "../actions/secrets.ts"; |
| 42 | 43 | import { addAccount, allowWrite, auditAccount, removeAccount, renameAccount, reverify, rotateAccount } from "../actions/cloud.ts"; |
| 43 | 44 | import { usesByVendor, type VendorUse } from "../cloud/declared.ts"; |
| @@ -513,7 +514,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 513 | 514 | { |
| 514 | 515 | name: "new_app", |
| 515 | 516 | description: |
| 516 | "Make an app from a sentence: a repository, production started, and with `description` a first issue.", | |
| 517 | "Make an app from a sentence: a repository, production started, and a first issue (`description`).", | |
| 517 | 518 | inputSchema: { |
| 518 | 519 | type: "object", |
| 519 | 520 | properties: { |
| @@ -634,7 +635,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 634 | 635 | { |
| 635 | 636 | name: "here", |
| 636 | 637 | description: |
| 637 | "What you can do on a forge page, as who you are: each open action with its HTTP route and MCP tool.", | |
| 638 | "What you can do on a forge page, as who you are: each action with its HTTP route and MCP tool.", | |
| 638 | 639 | inputSchema: { |
| 639 | 640 | type: "object", |
| 640 | 641 | properties: { url: { type: "string", maxLength: 2000 } }, |
| @@ -661,7 +662,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 661 | 662 | { |
| 662 | 663 | name: "tell", |
| 663 | 664 | description: |
| 664 | "Tell an app's crew what should change (first line is the title). No `repo`: kept, answers a thought id.", | |
| 665 | "Tell an app's crew what should change (first line is the title). No `repo`: kept; answers a thought id.", | |
| 665 | 666 | inputSchema: { |
| 666 | 667 | type: "object", |
| 667 | 668 | properties: { |
| @@ -740,7 +741,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 740 | 741 | { |
| 741 | 742 | name: "share", |
| 742 | 743 | description: |
| 743 | "Share a feed item: no `to` tells the app's crew and owners, else its followers; daily budget each.", | |
| 744 | "Share a feed item: no `to` tells the app's crew and owners, else its followers.", | |
| 744 | 745 | inputSchema: { |
| 745 | 746 | type: "object", |
| 746 | 747 | properties: { |
| @@ -799,7 +800,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 799 | 800 | { |
| 800 | 801 | name: "issue", |
| 801 | 802 | description: |
| 802 | "One issue with comments, `blockedBy`, `blocks`; a crew agent sees `untrusted: true` on text by non-writers.", | |
| 803 | "One issue with comments, `blockedBy`, `blocks`; text by non-writers has `untrusted: true`.", | |
| 803 | 804 | inputSchema: { |
| 804 | 805 | type: "object", |
| 805 | 806 | properties: { |
| @@ -868,7 +869,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 868 | 869 | { |
| 869 | 870 | name: "pull", |
| 870 | 871 | description: |
| 871 | "Read a pull: title, state, head, base; open: `mergeable`, `conflicts`, `proposal`, `checkStale`, `check`.", | |
| 872 | "A pull: title, state, head, base; open: `mergeable`, `conflicts`, `proposal`, `checkStale`, `check`.", | |
| 872 | 873 | inputSchema: { |
| 873 | 874 | type: "object", |
| 874 | 875 | properties: { |
| @@ -955,7 +956,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 955 | 956 | { |
| 956 | 957 | name: "variant", |
| 957 | 958 | description: |
| 958 | "Like or dislike one pull among its variants; a later vote replaces it; a dislike closes it (`reason`).", | |
| 959 | "Like or dislike one pull among its variants; a later vote replaces it; a dislike closes it.", | |
| 959 | 960 | inputSchema: { |
| 960 | 961 | type: "object", |
| 961 | 962 | properties: { |
| @@ -1140,7 +1141,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 1140 | 1141 | { |
| 1141 | 1142 | name: "asks", |
| 1142 | 1143 | description: |
| 1143 | "What waits on you, most consequential first: decision, options, cost of inaction; your saved filter applies.", | |
| 1144 | "What waits on you, most consequential first: decision, options, cost of inaction.", | |
| 1144 | 1145 | inputSchema: { type: "object", properties: { ...CHIP_ARGS } }, |
| 1145 | 1146 | writes: false, |
| 1146 | 1147 | run(ctx, user, args) { |
| @@ -1152,7 +1153,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 1152 | 1153 | { |
| 1153 | 1154 | name: "asks_act", |
| 1154 | 1155 | description: |
| 1155 | "Decide asks (`items`: `asks` ids, `issue:<id>`): dismiss, decline, ship (never undone), close (`reason`), mute, replan.", | |
| 1156 | "Decide asks (`items`: `asks` ids, `issue:<id>`): dismiss, decline, ship (final), close (`reason`), mute, replan.", | |
| 1156 | 1157 | inputSchema: { |
| 1157 | 1158 | type: "object", |
| 1158 | 1159 | properties: { |
| @@ -1176,7 +1177,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 1176 | 1177 | { |
| 1177 | 1178 | name: "asks_decide", |
| 1178 | 1179 | description: |
| 1179 | "Let the decider answer a hand-over (`item`: `parked:<id>`); only a sure set_aside (70%+) clears it.", | |
| 1180 | "Let the decider answer a hand-over (`item`: `parked:<id>`); only a sure set_aside clears it.", | |
| 1180 | 1181 | inputSchema: { |
| 1181 | 1182 | type: "object", |
| 1182 | 1183 | properties: { item: { type: "string", maxLength: 80 } }, |
| @@ -1248,7 +1249,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 1248 | 1249 | { |
| 1249 | 1250 | name: "asks_undecide", |
| 1250 | 1251 | description: |
| 1251 | "Put a card the decider set aside back on your board, within a day. `id` is from `asks_decide`.", | |
| 1252 | "Put a card the decider set aside back on your board, within a day (`id`, from `asks_decide`).", | |
| 1252 | 1253 | inputSchema: { |
| 1253 | 1254 | type: "object", |
| 1254 | 1255 | properties: { id: { type: "string", maxLength: 80 } }, |
| @@ -1340,7 +1341,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 1340 | 1341 | { |
| 1341 | 1342 | name: "issue_teams", |
| 1342 | 1343 | description: |
| 1343 | "Name up to two crew teams (design, data-science, security, platform) to review an issue's pull.", | |
| 1344 | "Name up to two crew teams to review an issue's pull (design, data-science, security, platform).", | |
| 1344 | 1345 | inputSchema: { |
| 1345 | 1346 | type: "object", |
| 1346 | 1347 | properties: { |
| @@ -1413,7 +1414,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 1413 | 1414 | { |
| 1414 | 1415 | name: "now", |
| 1415 | 1416 | description: |
| 1416 | "What the crew is doing across your apps: who, on what, since when, cost; what waits on your review.", | |
| 1417 | "What the crew is doing across your apps: who, on what, since when, cost; what awaits review.", | |
| 1417 | 1418 | inputSchema: { type: "object", properties: {} }, |
| 1418 | 1419 | writes: false, |
| 1419 | 1420 | run(ctx, user) { |
| @@ -1536,7 +1537,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 1536 | 1537 | { |
| 1537 | 1538 | name: "audit", |
| 1538 | 1539 | description: |
| 1539 | "Who can do what in every app you can see, from each contract.json: resource × verb, yes, own or no.", | |
| 1540 | "Who can do what in every app you can see, per contract.json: resource × verb.", | |
| 1540 | 1541 | inputSchema: { |
| 1541 | 1542 | type: "object", |
| 1542 | 1543 | properties: { |
| @@ -1758,7 +1759,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 1758 | 1759 | { |
| 1759 | 1760 | name: "model_ceiling", |
| 1760 | 1761 | description: |
| 1761 | "Set an account's daily and per-run model spend ceilings in dollars; a run past one does not start.", | |
| 1762 | "Set an account's daily and per-run model spend ceilings in dollars.", | |
| 1762 | 1763 | inputSchema: { |
| 1763 | 1764 | type: "object", |
| 1764 | 1765 | properties: { |
| @@ -2287,7 +2288,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 2287 | 2288 | { |
| 2288 | 2289 | name: "probe", |
| 2289 | 2290 | description: |
| 2290 | "Try every door of a running app as nobody, a user and an admin against its contract.json; read-only.", | |
| 2291 | "Try every door of a running app as nobody, a user and an admin against contract.json.", | |
| 2291 | 2292 | inputSchema: { |
| 2292 | 2293 | type: "object", |
| 2293 | 2294 | properties: { repo: REPO_ARG }, |
| @@ -2587,7 +2588,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 2587 | 2588 | { |
| 2588 | 2589 | name: "sever", |
| 2589 | 2590 | description: |
| 2590 | "Cut a spawned forge's link to its parent (its `forge` repository's owner only). Deletes nothing.", | |
| 2591 | "Cut a spawned forge's link to its parent (its `forge` repo's owner). Deletes nothing.", | |
| 2591 | 2592 | inputSchema: { |
| 2592 | 2593 | type: "object", |
| 2593 | 2594 | properties: { repo: REPO_ARG }, |
| @@ -2672,7 +2673,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 2672 | 2673 | { |
| 2673 | 2674 | name: "propose_to_parent_forge", |
| 2674 | 2675 | description: |
| 2675 | "Offer this forge's landed change to its parent as a pull on `child/<name>/…`; the same tip answers that pull.", | |
| 2676 | "Offer this forge's landed change to its parent as a pull on `child/<name>/…`.", | |
| 2676 | 2677 | inputSchema: { |
| 2677 | 2678 | type: "object", |
| 2678 | 2679 | properties: { repo: REPO_ARG }, |
| @@ -2913,7 +2914,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 2913 | 2914 | { |
| 2914 | 2915 | name: "search", |
| 2915 | 2916 | description: |
| 2916 | "Find issues, pulls, repositories and code you can read; `kind` narrows, `repo` keeps to one.", | |
| 2917 | "Find issues, pulls, repos and code you can read; `kind` narrows, `repo` keeps to one.", | |
| 2917 | 2918 | inputSchema: { |
| 2918 | 2919 | type: "object", |
| 2919 | 2920 | properties: { |
| @@ -3020,7 +3021,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 3020 | 3021 | { |
| 3021 | 3022 | name: "make_it_yours", |
| 3022 | 3023 | description: |
| 3023 | "Fork an app you can see: its code and history, following the original; nothing else is copied.", | |
| 3024 | "Fork an app you can see: its code and history, following the original.", | |
| 3024 | 3025 | inputSchema: { |
| 3025 | 3026 | type: "object", |
| 3026 | 3027 | properties: { |
| @@ -3362,7 +3363,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 3362 | 3363 | { |
| 3363 | 3364 | name: "limb", |
| 3364 | 3365 | description: |
| 3365 | "Act on a plan limb: `defer`, `resume`, `close` (`reason`), `raise`, `lower`, `replan`, `takeback`, `undo`.", | |
| 3366 | "Act on a plan limb: `defer`, `resume`, `close` (`reason`), `raise`, `lower`, `replan`, `takeback`, `undo`", | |
| 3366 | 3367 | inputSchema: { |
| 3367 | 3368 | type: "object", |
| 3368 | 3369 | properties: { |
| @@ -3587,7 +3588,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 3587 | 3588 | { |
| 3588 | 3589 | name: "spend", |
| 3589 | 3590 | description: |
| 3590 | "Report what your session spent on work the forge did not run: who, model, tokens or dollars, issue.", | |
| 3591 | "Report what your session spent on work the forge did not run: model, tokens or dollars, issue.", | |
| 3591 | 3592 | inputSchema: { |
| 3592 | 3593 | type: "object", |
| 3593 | 3594 | properties: { |
| @@ -3886,7 +3887,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 3886 | 3887 | { |
| 3887 | 3888 | name: "hold", |
| 3888 | 3889 | description: |
| 3889 | "Hold a pull (`why`) or let it go (`release: true`): while held nothing reviews or lands it. Writers.", | |
| 3890 | "Hold a pull (`why`) or let it go (`release: true`): held, nothing reviews or lands it.", | |
| 3890 | 3891 | inputSchema: { |
| 3891 | 3892 | type: "object", |
| 3892 | 3893 | properties: { |
| @@ -4038,7 +4039,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 4038 | 4039 | { |
| 4039 | 4040 | name: "prompts", |
| 4040 | 4041 | description: |
| 4041 | "An app's prompt sources (Instagram): list, add (`kind`, `token`, `at`), run or remove (`id`). Repository admin token.", | |
| 4042 | "An app's prompt sources (Instagram): list, add (`kind`, `token`, `at`), run, remove (`id`). Admin token.", | |
| 4042 | 4043 | inputSchema: { |
| 4043 | 4044 | type: "object", |
| 4044 | 4045 | properties: { |
| @@ -4088,7 +4089,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 4088 | 4089 | { |
| 4089 | 4090 | name: "access", |
| 4090 | 4091 | description: |
| 4091 | "What outside agents tried: redacted log of non-browser requests to public paths, newest first, max 500. Forge admin.", | |
| 4092 | "What outside agents tried: redacted non-browser requests to public paths, newest first. Forge admin.", | |
| 4092 | 4093 | inputSchema: { |
| 4093 | 4094 | type: "object", |
| 4094 | 4095 | properties: { |
| @@ -4167,7 +4168,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 4167 | 4168 | { |
| 4168 | 4169 | name: "flow", |
| 4169 | 4170 | description: |
| 4170 | "The pipeline (forge admin): per-stage counts, `oldestWaiting`, `capacity`, bottleneck, `queue`, `reviewing` by reviewer.", | |
| 4171 | "The pipeline (forge admin): stage counts, `oldestWaiting`, `capacity`, bottleneck, `queue`, `reviewing`.", | |
| 4171 | 4172 | inputSchema: { type: "object", properties: {} }, |
| 4172 | 4173 | writes: false, |
| 4173 | 4174 | run(ctx, user) { |
| @@ -4334,7 +4335,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 4334 | 4335 | { |
| 4335 | 4336 | name: "cloud_accounts", |
| 4336 | 4337 | description: |
| 4337 | "Cloud accounts (forge admin): each provider token's use, verification, write permission, calls today.", | |
| 4338 | "Cloud accounts (forge admin): each provider token's use, verification, write permission, calls.", | |
| 4338 | 4339 | inputSchema: { type: "object", properties: {} }, |
| 4339 | 4340 | // A read, but marked a write so a `ro` token never lists the accounts; it |
| 4340 | 4341 | // is a forge admin's and the audit rows name every vendor call. |
| @@ -4350,7 +4351,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 4350 | 4351 | { |
| 4351 | 4352 | name: "cloud_account", |
| 4352 | 4353 | description: |
| 4353 | "Change a cloud account (admin token): `verb` attach, verify, rotate, rename, remove, allow_writes, audit.", | |
| 4354 | "Change a cloud account (admin token): `verb` attach, verify, rotate, rename, remove, allow_writes, audit", | |
| 4354 | 4355 | inputSchema: { |
| 4355 | 4356 | type: "object", |
| 4356 | 4357 | properties: { |
| @@ -4405,7 +4406,7 @@ const TOOLS: readonly Tool[] = [ | ||
| 4405 | 4406 | { |
| 4406 | 4407 | name: "quotas", |
| 4407 | 4408 | description: |
| 4408 | "Per-account repository and app quotas (number or null; not enforced yet). With `key`, `value` (\"\" clears), plans.", | |
| 4409 | "Per-account repo and app quotas (number or null; not enforced yet). With `key`, `value`, plans.", | |
| 4409 | 4410 | inputSchema: { |
| 4410 | 4411 | type: "object", |
| 4411 | 4412 | properties: { |
| @@ -4602,6 +4603,34 @@ const TOOLS: readonly Tool[] = [ | ||
| 4602 | 4603 | return done.ok ? good({ deleted: str(args["slug"]) }) : boardFailed(done.error); |
| 4603 | 4604 | }, |
| 4604 | 4605 | }, |
| 4606 | { | |
| 4607 | name: "backups_test", | |
| 4608 | description: "Test the snapshot S3 bucket (admin); no fields tests the one in effect.", | |
| 4609 | inputSchema: { | |
| 4610 | type: "object", | |
| 4611 | properties: { | |
| 4612 | endpoint: { type: "string" }, | |
| 4613 | bucket: { type: "string" }, | |
| 4614 | region: { type: "string" }, | |
| 4615 | accessKey: { type: "string" }, | |
| 4616 | secretKey: { type: "string" }, | |
| 4617 | }, | |
| 4618 | }, | |
| 4619 | writes: true, | |
| 4620 | async run(ctx, user, args) { | |
| 4621 | // As the page's form: each field trimmed, blank when absent. | |
| 4622 | const f = (k: string): string => (typeof args[k] === "string" ? (args[k] as string).trim() : ""); | |
| 4623 | const said = await testDestination(ctx.app, user, { | |
| 4624 | endpoint: f("endpoint"), | |
| 4625 | bucket: f("bucket"), | |
| 4626 | region: f("region"), | |
| 4627 | accessKey: f("accessKey"), | |
| 4628 | secretKey: f("secretKey"), | |
| 4629 | }); | |
| 4630 | if (!said.ok) return bad("not_found", "Not found."); | |
| 4631 | return good({ reached: said.value.startsWith("Reached"), says: said.value }); | |
| 4632 | }, | |
| 4633 | }, | |
| 4605 | 4634 | ]; |
| 4606 | 4635 | |
| 4607 | 4636 | /** |
test/mcp-backups-test.test.ts added +103
| @@ -0,0 +1,103 @@ | ||
| 1 | /** `backups_test` is the Backups page's Test button over MCP: the same action, so the same sentence and gate. */ | |
| 2 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 3 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { createApp, type App } from "../src/app.ts"; | |
| 7 | import { createToken } from "../src/core/tokens.ts"; | |
| 8 | import { createUser } from "../src/core/users.ts"; | |
| 9 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 10 | import { quietLogs } from "./helpers/globals.ts"; | |
| 11 | ||
| 12 | quietLogs(); | |
| 13 | ||
| 14 | describe("MCP backups_test", () => { | |
| 15 | let dataDir: string; | |
| 16 | let app: App; | |
| 17 | let servers: Servers; | |
| 18 | let admin: string; | |
| 19 | let bob: string; | |
| 20 | let local: ReturnType<typeof Bun.serve>; | |
| 21 | let n = 1; | |
| 22 | ||
| 23 | const call = async (token: string, args: unknown) => { | |
| 24 | const res = await fetch(`${servers.url}/mcp`, { | |
| 25 | method: "POST", | |
| 26 | headers: { | |
| 27 | "content-type": "application/json", | |
| 28 | accept: "application/json, text/event-stream", | |
| 29 | authorization: `Bearer ${token}`, | |
| 30 | }, | |
| 31 | body: JSON.stringify({ | |
| 32 | jsonrpc: "2.0", | |
| 33 | id: n++, | |
| 34 | method: "tools/call", | |
| 35 | params: { name: "backups_test", arguments: args }, | |
| 36 | }), | |
| 37 | }); | |
| 38 | const body: any = await res.json(); | |
| 39 | const text: string = body.result.content[0].text; | |
| 40 | return body.result.isError === true ? { error: text } : { value: JSON.parse(text), text }; | |
| 41 | }; | |
| 42 | const secrets = { accessKey: "AKIASECRETACCESS", secretKey: "sekrit-key-value-123" }; | |
| 43 | ||
| 44 | beforeAll(async () => { | |
| 45 | dataDir = await mkdtemp(join(tmpdir(), "forge-mcp-backups-test-")); | |
| 46 | app = createApp({ dataDir, port: 0 }); | |
| 47 | servers = await serve(app); | |
| 48 | const mk = async (username: string, first = false) => { | |
| 49 | const u = await createUser(app.db, { | |
| 50 | origin: "seed", trusted: true, username, | |
| 51 | email: `${username}@forge.local`, password: "a-good-passphrase", adminIfFirst: first, | |
| 52 | }); | |
| 53 | if (!u.ok) throw new Error(u.error); | |
| 54 | return u.value; | |
| 55 | }; | |
| 56 | const alice = await mk("alice", true); | |
| 57 | const b = await mk("bob"); | |
| 58 | admin = createToken(app.db, alice.id, "a", "admin").token; | |
| 59 | bob = createToken(app.db, b.id, "b", "admin").token; | |
| 60 | // A bucket on this machine: it answers an empty listing. | |
| 61 | local = Bun.serve({ | |
| 62 | port: 0, | |
| 63 | hostname: "127.0.0.1", | |
| 64 | fetch: () => | |
| 65 | new Response( | |
| 66 | '<?xml version="1.0"?><ListBucketResult><Name>b</Name><IsTruncated>false</IsTruncated></ListBucketResult>', | |
| 67 | { headers: { "content-type": "application/xml" } }, | |
| 68 | ), | |
| 69 | }); | |
| 70 | }, 30_000); | |
| 71 | ||
| 72 | afterAll(async () => { | |
| 73 | local.stop(true); | |
| 74 | servers.stop(); | |
| 75 | app.close(); | |
| 76 | await rm(dataDir, { recursive: true, force: true }); | |
| 77 | }); | |
| 78 | ||
| 79 | test("a local destination is reached", async () => { | |
| 80 | const r = await call(admin, { | |
| 81 | endpoint: `http://127.0.0.1:${local.port}`, | |
| 82 | bucket: "my-bucket", | |
| 83 | ...secrets, | |
| 84 | }); | |
| 85 | expect(r.value.reached).toBe(true); | |
| 86 | expect(r.value.says).toStartWith("Reached 127.0.0.1:"); | |
| 87 | expect(r.text).not.toContain(secrets.secretKey); | |
| 88 | expect(r.text).not.toContain(secrets.accessKey); | |
| 89 | }, 30_000); | |
| 90 | ||
| 91 | test("an unreachable one says why, without a key", async () => { | |
| 92 | const r = await call(admin, { endpoint: "http://127.0.0.1:1", bucket: "my-bucket", ...secrets }); | |
| 93 | expect(r.value.reached).toBe(false); | |
| 94 | expect(r.value.says).toStartWith("Could not list 127.0.0.1:1/my-bucket: "); | |
| 95 | expect(r.text).not.toContain(secrets.secretKey); | |
| 96 | expect(r.text).not.toContain(secrets.accessKey); | |
| 97 | }, 30_000); | |
| 98 | ||
| 99 | test("a non-admin is refused as the page refuses", async () => { | |
| 100 | const r = await call(bob, { endpoint: "http://127.0.0.1:1", bucket: "my-bucket", ...secrets }); | |
| 101 | expect(r.error).toBe("not_found: Not found."); | |
| 102 | }); | |
| 103 | }); |
test/mcp.test.ts +1
| @@ -277,6 +277,7 @@ describe("the forge over MCP", () => { | ||
| 277 | 277 | "board_write", |
| 278 | 278 | "board_pins", |
| 279 | 279 | "board_delete", |
| 280 | "backups_test", | |
| 280 | 281 | "report", |
| 281 | 282 | ]); |
| 282 | 283 | const byName = new Map<string, any>( |
new above
offline