History

Allow endpoint overrides for the first-party GitHub app in tests/dev

Rhys Sullivan committed 2 months ago

Commit 67ee8a01 parent 8d46cc53 files · +19 −2Browse files

Unified · Split

3 files
  1. apps/cloud/src/engine/execution-stack.ts +9 −2
  2. apps/cloud/src/env-augment.d.ts +5 −0
  3. e2e/setup/cloud.boot.ts +5 −0
apps/cloud/src/engine/execution-stack.ts+9−2
@@ -92,13 +92,20 @@ export const CLOUD_MOUNT_PREFIX = "/api" as const; · 91 unmodified lines
9292 // (id + secret). Each provider-side registration must list
9393 // `${VITE_PUBLIC_SITE_URL}/api/oauth/callback` as its callback; the org slug
9494 // travels inside OAuth `state`, so the single static callback serves every org.
95+//
96+// The endpoint URLs default to the real provider; the `_AUTHORIZE_URL` /
97+// `_TOKEN_URL` overrides exist so tests and dev instances can point the app at
98+// an emulated provider (`@executor-js/emulate`) and run the complete flow.
99+// Production leaves them unset.
95100 const cloudFirstPartyOAuthClients = (): readonly FirstPartyOAuthClientConfig[] => [
96101 ...(env.FIRST_PARTY_GITHUB_CLIENT_ID && env.FIRST_PARTY_GITHUB_CLIENT_SECRET
97102 ? [
98103 {
99104 name: "github",
100− authorizationUrl: "https://github.com/login/oauth/authorize",
101− tokenUrl: "https://github.com/login/oauth/access_token",
105+ authorizationUrl:
106+ env.FIRST_PARTY_GITHUB_AUTHORIZE_URL ?? "https://github.com/login/oauth/authorize",
107+ tokenUrl:
108+ env.FIRST_PARTY_GITHUB_TOKEN_URL ?? "https://github.com/login/oauth/access_token",
102109 clientId: env.FIRST_PARTY_GITHUB_CLIENT_ID,
103110 clientSecret: env.FIRST_PARTY_GITHUB_CLIENT_SECRET,
104111 },
apps/cloud/src/env-augment.d.ts+5−0
@@ -60,6 +60,11 @@ declare global { · 59 unmodified lines
6060 // `${VITE_PUBLIC_SITE_URL}/api/oauth/callback`.
6161 FIRST_PARTY_GITHUB_CLIENT_ID?: string;
6262 FIRST_PARTY_GITHUB_CLIENT_SECRET?: string;
63+ // Endpoint overrides for the GitHub first-party app, so tests/dev can
64+ // point it at an emulated provider and complete the whole flow. Unset in
65+ // production (the real github.com endpoints are the defaults).
66+ FIRST_PARTY_GITHUB_AUTHORIZE_URL?: string;
67+ FIRST_PARTY_GITHUB_TOKEN_URL?: string;
6368 FIRST_PARTY_GOOGLE_CLIENT_ID?: string;
6469 FIRST_PARTY_GOOGLE_CLIENT_SECRET?: string;
6570
e2e/setup/cloud.boot.ts+5−0
@@ -99,6 +99,11 @@ export const bootCloud = async (options: CloudBootOptions): Promise<CloudBooted> · 98 unmodified lines
9999 // authorize REDIRECT only (client id + callback), never visits github.com.
100100 FIRST_PARTY_GITHUB_CLIENT_ID: "e2e-first-party-github",
101101 FIRST_PARTY_GITHUB_CLIENT_SECRET: "e2e-first-party-github-secret",
102+ // Optional endpoint overrides pass through so a dev instance (`cli up
103+ // cloud`) can point the first-party app at an emulated GitHub and run the
104+ // complete authorize → token dance instead of stopping at github.com.
105+ FIRST_PARTY_GITHUB_AUTHORIZE_URL: process.env.FIRST_PARTY_GITHUB_AUTHORIZE_URL,
106+ FIRST_PARTY_GITHUB_TOKEN_URL: process.env.FIRST_PARTY_GITHUB_TOKEN_URL,
102107 // Shrink the per-org hourly execution cap (prod default 1000) to a number
103108 // the rate-limit-backstop scenario can actually exhaust with real
104109 // executions — but see execution-limits.ts: it must stay above every other