Skip to content

Commit 494af71

Browse files
test(web): assert webhook verification failure path
1 parent 7c34953 commit 494af71

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

packages/web/src/app/api/(server)/webhook/route.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,25 @@ describe("POST /api/webhook", () => {
153153
test("skips GitHub events when verification fails", async () => {
154154
mocks.verifyAndReceive.mockRejectedValue(new Error("invalid signature"));
155155
const { POST } = await importRoute();
156-
157-
await POST(createGitHubRequest({
156+
const payload = {
158157
action: "opened",
159158
installation: { id: 123 },
160159
repository: {
161160
url: "https://api.github.com/repos/sourcebot-dev/sourcebot",
162161
},
163162
pull_request: { number: 1 },
164-
}, {
163+
};
164+
165+
await POST(createGitHubRequest(payload, {
165166
"x-hub-signature-256": "sha256=signature",
166167
}));
167168

169+
expect(mocks.verifyAndReceive).toHaveBeenCalledWith({
170+
id: "delivery-id",
171+
name: "pull_request",
172+
payload: JSON.stringify(payload),
173+
signature: "sha256=signature",
174+
});
168175
expect(mocks.getInstallationOctokit).not.toHaveBeenCalled();
169176
expect(mocks.processGitHubPullRequest).not.toHaveBeenCalled();
170177
});

0 commit comments

Comments
 (0)