Public: anyone can read this; the crew can change it.

An outsider's offered pull answers with a receipt number and the same words by API and MCP #13468

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/13445-an-outsider-s-offered-pull-answers-with → main 2 commits fork

  • Merged. mason/13445-an-outsider-s-offered-pull-answers-with was merged into main as 97c7af0.

Review

Sign in to review this change.
2 files changed +33 −1
src/actions/offer.ts +1 −1
@@ -59,7 +59,7 @@ export const OFFER_BODY_MAX = 8_000;
5959
6060 /** The answer to an offer that was stored and now waits for a person. */
6161 export const OFFER_RECEIVED =
62 "Received as a pull. A person who maintains this repository reads it; nothing runs with the repository's secrets and nothing lands before they approve it.";
62 "Received as a pull: a person who maintains this repository reads it next, and nothing runs with the repository's secrets or lands before they approve it.";
6363
6464 /** What a refused offer is told: the shape that would have been taken. */
6565 export const OFFER_HINT =
test/offer-mcp.test.ts +32
@@ -66,6 +66,38 @@ describe("offer over MCP", () => {
6666 expect(got.url).toContain("/alice/game/pulls/");
6767 });
6868
69 test("both doors answer a receipt number and the same one sentence", async () => {
70 const http = await fetch(`${servers.url}/api/v1/repos/alice/game/offers`, {
71 method: "POST",
72 headers: { "content-type": "application/json", "x-forwarded-for": `10.3.0.${n++}` },
73 body: JSON.stringify({ title: "Via HTTP", patch: PATCH }),
74 });
75 expect(http.status).toBe(202);
76 const viaHttp: any = await http.json();
77 const viaMcp = JSON.parse(said(await call("offer", { repo: "alice/game", title: "Via MCP", patch: PATCH })));
78 for (const got of [viaHttp, viaMcp]) {
79 expect(typeof got.number).toBe("number");
80 expect(got.receipt).toBeTruthy();
81 expect(got.message).toBe(OFFER_RECEIVED);
82 }
83 expect(viaHttp.message).toBe(viaMcp.message);
84 expect(OFFER_RECEIVED.match(/\. /g)).toBeNull();
85 });
86
87 test("an invalid offer names the first thing wrong, as a 422 and as the same words by MCP", async () => {
88 const http = await fetch(`${servers.url}/api/v1/repos/alice/game/offers`, {
89 method: "POST",
90 headers: { "content-type": "application/json", "x-forwarded-for": `10.4.0.${n++}` },
91 body: JSON.stringify({ title: " ", patch: PATCH }),
92 });
93 expect(http.status).toBe(422);
94 const refused: any = await http.json();
95 expect(refused.error).toBe("empty_title");
96 const r = await call("offer", { repo: "alice/game", title: " ", patch: PATCH });
97 expect(said(r)).toContain(`empty_title: ${OFFER_WORDS.empty_title}`);
98 expect(refused.message).toContain(OFFER_WORDS.empty_title);
99 });
100
69101 test("a patch that does not apply is refused with the REST door's reason", async () => {
70102 const r = await call("offer", { repo: "alice/game", title: "Stale", patch: STALE });
71103 expect(r.body.result.isError).toBe(true);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs