This commit is contained in:
parent
d99c2d9894
commit
3173641827
3 changed files with 8 additions and 23 deletions
|
|
@ -10,9 +10,6 @@ POST /patchbay/jojo
|
||||||
POST /patchbay/github
|
POST /patchbay/github
|
||||||
```
|
```
|
||||||
|
|
||||||
Existing `/git-webhooks/jojo` and `/git-webhooks/github` routes remain
|
|
||||||
compatibility aliases for existing webhook registrations.
|
|
||||||
|
|
||||||
## Environment
|
## Environment
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,10 @@ export function createHandler(config: ServerConfig): (request: Request) => Promi
|
||||||
if (url.pathname === "/healthz") {
|
if (url.pathname === "/healthz") {
|
||||||
return textResponse("ok\n");
|
return textResponse("ok\n");
|
||||||
}
|
}
|
||||||
if (url.pathname === "/patchbay/github" || url.pathname === "/git-webhooks/github") {
|
if (url.pathname === "/patchbay/github") {
|
||||||
return handleGithub(request, config, store);
|
return handleGithub(request, config, store);
|
||||||
}
|
}
|
||||||
if (url.pathname === "/patchbay/jojo" || url.pathname === "/git-webhooks/jojo") {
|
if (url.pathname === "/patchbay/jojo") {
|
||||||
return handleJojo(request, config, store);
|
return handleJojo(request, config, store);
|
||||||
}
|
}
|
||||||
return jsonResponse({ error: "not_found" }, { status: 404 });
|
return jsonResponse({ error: "not_found" }, { status: 404 });
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,12 @@ describe("server", () => {
|
||||||
expect(response.status).toBe(401);
|
expect(response.status).toBe(401);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("does not serve legacy git-webhooks routes", async () => {
|
||||||
|
const handler = createHandler({ githubSecret: "gh", jojoSecret: "jojo", dataDir: await mkdtemp(join(tmpdir(), "patchbay-")) });
|
||||||
|
const response = await handler(new Request("http://localhost/git-webhooks/jojo", { method: "POST", body: "{}" }));
|
||||||
|
expect(response.status).toBe(404);
|
||||||
|
});
|
||||||
|
|
||||||
test("accepts jojo main pushes and queues a job", async () => {
|
test("accepts jojo main pushes and queues a job", async () => {
|
||||||
const dataDir = await mkdtemp(join(tmpdir(), "patchbay-"));
|
const dataDir = await mkdtemp(join(tmpdir(), "patchbay-"));
|
||||||
const handler = createHandler({ githubSecret: "gh", jojoSecret: "jojo", dataDir });
|
const handler = createHandler({ githubSecret: "gh", jojoSecret: "jojo", dataDir });
|
||||||
|
|
@ -58,24 +64,6 @@ describe("server", () => {
|
||||||
expect(await readFile(join(dataDir, "jobs.jsonl"), "utf8")).toContain("\"kind\":\"main_push\"");
|
expect(await readFile(join(dataDir, "jobs.jsonl"), "utf8")).toContain("\"kind\":\"main_push\"");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("keeps legacy git-webhooks routes as aliases", async () => {
|
|
||||||
const dataDir = await mkdtemp(join(tmpdir(), "patchbay-"));
|
|
||||||
const handler = createHandler({ githubSecret: "gh", jojoSecret: "jojo", dataDir });
|
|
||||||
const request = await signedRequest("/git-webhooks/jojo", "jojo", "jojo", {
|
|
||||||
ref: "refs/heads/main",
|
|
||||||
after: "abc123",
|
|
||||||
repository: {
|
|
||||||
name: "patchbay",
|
|
||||||
full_name: "peezy-tech/patchbay",
|
|
||||||
owner: { username: "peezy-tech" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await handler(request);
|
|
||||||
expect(response.status).toBe(202);
|
|
||||||
expect(await readFile(join(dataDir, "events.jsonl"), "utf8")).toContain("\"provider\":\"jojo\"");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("continues accepting webhooks when Discord returns an error", async () => {
|
test("continues accepting webhooks when Discord returns an error", async () => {
|
||||||
const originalFetch = globalThis.fetch;
|
const originalFetch = globalThis.fetch;
|
||||||
globalThis.fetch = (async () => new Response("bad", { status: 500 })) as unknown as typeof fetch;
|
globalThis.fetch = (async () => new Response("bad", { status: 500 })) as unknown as typeof fetch;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue