Skip to content

Commit 7e98cd3

Browse files
committed
test(webapp): pin the run-commit org opt-in against a default flip
1 parent c68a33c commit 7e98cd3

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

apps/webapp/test/userActorOrgWideRunCommit.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ vi.mock("~/v3/runStore.server", () => ({
3333
}));
3434

3535
const { loader } = await import("~/routes/api.v1.projects.$projectRef.$env.runs.$runId.commit");
36+
const { authenticatedEnvironmentForAuthentication } = await import("~/services/apiAuth.server");
3637

3738
function suffix() {
3839
return Math.random().toString(36).slice(2, 10);
@@ -255,5 +256,25 @@ postgresTest(
255256
});
256257
expect(scopedSibling.status).toBe(403);
257258
expect(scopedSibling.body.code).toBe("forbidden_environment");
259+
260+
// The control: without the opt-in, the same org-claim token is refused a sibling
261+
// environment, so the flag stays the only way in.
262+
const authenticationResult = {
263+
type: "personalAccessToken" as const,
264+
result: { userId: orgA.member.id },
265+
userActor: { ...minted, client: "dashboard-agent" },
266+
};
267+
268+
try {
269+
await authenticatedEnvironmentForAuthentication(
270+
authenticationResult,
271+
orgA.sibling.project.externalRef,
272+
"prod"
273+
);
274+
expect.unreachable("a sibling environment must be refused without the opt-in");
275+
} catch (thrown) {
276+
expect(thrown).toBeInstanceOf(Response);
277+
expect((thrown as Response).status).toBe(403);
278+
}
258279
}
259280
);

0 commit comments

Comments
 (0)