CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
team-collaborators.test.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| febd4f0 | 1 | /** |
| 2 | * Team-collaborator routes — auth guard smoke. | |
| 3 | * | |
| 4 | * Mirrors src/__tests__/collaborators.test.ts. Two assertions: | |
| 5 | * 1. unauthenticated GET redirects to /login (requireAuth) | |
| 6 | * 2. an authed non-owner is blocked — either 403 (inline owner check) or | |
| 7 | * redirected away (302 to /login when the stub cookie can't resolve). | |
| 8 | */ | |
| 9 | ||
| 10 | import { describe, it, expect } from "bun:test"; | |
| 11 | import app from "../app"; | |
| 12 | ||
| 13 | describe("team-collaborators — auth guard", () => { | |
| 14 | it("GET /:owner/:repo/settings/collaborators/teams without auth redirects to /login", async () => { | |
| 15 | const res = await app.request( | |
| 16 | "/somebody/some-repo/settings/collaborators/teams" | |
| 17 | ); | |
| 18 | expect(res.status).toBe(302); | |
| 19 | expect(res.headers.get("location") || "").toContain("/login"); | |
| 20 | }); | |
| 21 | ||
| 22 | it("GET as an authed non-owner returns 403 or redirects away", async () => { | |
| 23 | const res = await app.request( | |
| 24 | "/some-owner/some-repo/settings/collaborators/teams", | |
| 25 | { headers: { cookie: "session=not-a-real-token" } } | |
| 26 | ); | |
| 27 | expect([302, 403, 404]).toContain(res.status); | |
| 28 | if (res.status === 302) { | |
| 29 | expect(res.headers.get("location") || "").toContain("/login"); | |
| 30 | } | |
| 31 | }); | |
| 32 | }); |