Skip to content

Commit 7b631ac

Browse files
authored
test(auth): cover project-scoped token parsing
Generated-By: PostHog Code Task-Id: 07b377f9-4583-463c-b256-cc29621375e6
1 parent c55f5f2 commit 7b631ac

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

packages/core/src/auth/auth.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,9 @@ describe("AuthService", () => {
14661466
},
14671467
);
14681468

1469-
it("loads project-scoped OAuth access without calling the organization endpoint", async () => {
1469+
// Regression for #3279: the current-org fallback still strands the picker
1470+
// when the backend rejects team-scoped tokens on organization endpoints.
1471+
it("loads project-scoped OAuth access when organization access is forbidden", async () => {
14701472
let orgCalls = 0;
14711473
let projectCalls = 0;
14721474
vi.stubGlobal(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { describe, expect, it } from "vitest";
2+
import { oAuthTokenResponse } from "./oauth.schemas";
3+
4+
describe("oAuthTokenResponse", () => {
5+
it("preserves project scopes from the token response", () => {
6+
const token = oAuthTokenResponse.parse({
7+
access_token: "access-token",
8+
expires_in: 3600,
9+
token_type: "Bearer",
10+
refresh_token: "refresh-token",
11+
scoped_teams: [42, 84],
12+
scoped_organizations: [],
13+
});
14+
15+
expect(token.scoped_teams).toEqual([42, 84]);
16+
});
17+
});

0 commit comments

Comments
 (0)