chore: Consistent policy checks in integration callbacks (#14221)

This commit is contained in:
Tom Moor authored and GitHub committed 2026-10-22 07:27:12 -04:00
1 parent 45bf9e290c
commit cf578accf9
8 files changed
+79 -4

No files matched your search

+18 -1
View File
@@ -1,4 +1,4 @@
import { buildUser } from "@server/test/factories";
import { buildUser, buildViewer } from "@server/test/factories";
import { getTestServer } from "@server/test/support";
import { SetupAction } from "./schema";
@@ -74,4 +74,21 @@ describe("#github.callback", () => {
);
expect(res.status).toEqual(400);
});
it.each([
["member", buildUser],
["viewer", buildViewer],
])("should not allow a %s to create an integration", async (_, build) => {
const user = await build();
const state = JSON.stringify({ teamId: user.teamId, nonce: "nonce" });
const res = await server.get(
`/api/github.callback?state=${encodeURIComponent(state)}&code=123&setup_action=${SetupAction.install}&installation_id=1`,
user,
{
redirect: "manual",
headers: { Cookie: "githubOAuthNonce=nonce" },
}
);
expect(res.status).toEqual(403);
});
});