Skip to content

Commit 1462375

Browse files
committed
fix: replace realistic-looking test tokens with obviously fake values
GitGuardian flagged token patterns like `ghu_...`, `ghp_...`, `sk-ant-...` in test files. Replace all with generic `test-*` strings that won't trigger secret scanners.
1 parent 6ef943d commit 1462375

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

packages/opencode/test/provider/codespace-e2e.test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe("Codespace provider detection", () => {
5858

5959
test("github-models is excluded in Codespace with only GITHUB_TOKEN", async () => {
6060
await withEnv(
61-
{ CODESPACES: "true", CODESPACE_NAME: "test-codespace", GITHUB_TOKEN: "ghu_test123" },
61+
{ CODESPACES: "true", CODESPACE_NAME: "test-codespace", GITHUB_TOKEN: "test-codespace-token" },
6262
async () => {
6363
const providers = await Provider.list()
6464
expect(providers["github-models"]).toBeUndefined()
@@ -68,7 +68,7 @@ describe("Codespace provider detection", () => {
6868

6969
test("github-copilot is excluded in Codespace with only GITHUB_TOKEN", async () => {
7070
await withEnv(
71-
{ CODESPACES: "true", CODESPACE_NAME: "test-codespace", GITHUB_TOKEN: "ghu_test123" },
71+
{ CODESPACES: "true", CODESPACE_NAME: "test-codespace", GITHUB_TOKEN: "test-codespace-token" },
7272
async () => {
7373
const providers = await Provider.list()
7474
expect(providers["github-copilot"]).toBeUndefined()
@@ -80,7 +80,7 @@ describe("Codespace provider detection", () => {
8080

8181
test("github-models is excluded when only GH_TOKEN is set in Codespace", async () => {
8282
await withEnv(
83-
{ CODESPACES: "true", GH_TOKEN: "ghu_test456" },
83+
{ CODESPACES: "true", GH_TOKEN: "test-gh-token" },
8484
async () => {
8585
const providers = await Provider.list()
8686
expect(providers["github-models"]).toBeUndefined()
@@ -92,7 +92,7 @@ describe("Codespace provider detection", () => {
9292

9393
test("github-models excluded when both GITHUB_TOKEN and GH_TOKEN are machine-scoped", async () => {
9494
await withEnv(
95-
{ CODESPACES: "true", GITHUB_TOKEN: "ghu_test", GH_TOKEN: "ghu_test" },
95+
{ CODESPACES: "true", GITHUB_TOKEN: "test-machine-token", GH_TOKEN: "test-machine-token" },
9696
async () => {
9797
const providers = await Provider.list()
9898
expect(providers["github-models"]).toBeUndefined()
@@ -104,7 +104,7 @@ describe("Codespace provider detection", () => {
104104

105105
test("github-models is available outside Codespace with GITHUB_TOKEN", async () => {
106106
await withEnv(
107-
{ GITHUB_TOKEN: "ghp_personal_token_123" },
107+
{ GITHUB_TOKEN: "test-personal-token" },
108108
async () => {
109109
const providers = await Provider.list()
110110
expect(providers["github-models"]).toBeDefined()
@@ -114,7 +114,7 @@ describe("Codespace provider detection", () => {
114114

115115
test("github-copilot is available outside Codespace with GITHUB_TOKEN", async () => {
116116
await withEnv(
117-
{ GITHUB_TOKEN: "ghp_personal_token_123" },
117+
{ GITHUB_TOKEN: "test-personal-token" },
118118
async () => {
119119
const providers = await Provider.list()
120120
// github-copilot may be filtered by custom loader (needs OAuth auth),
@@ -133,7 +133,7 @@ describe("Codespace provider detection", () => {
133133
describe("GitHub Actions provider detection", () => {
134134
test("github-models is excluded in GitHub Actions with GITHUB_TOKEN", async () => {
135135
await withEnv(
136-
{ GITHUB_ACTIONS: "true", CI: "true", GITHUB_TOKEN: "ghs_workflow_token" },
136+
{ GITHUB_ACTIONS: "true", CI: "true", GITHUB_TOKEN: "test-actions-token" },
137137
async () => {
138138
const providers = await Provider.list()
139139
expect(providers["github-models"]).toBeUndefined()
@@ -143,7 +143,7 @@ describe("GitHub Actions provider detection", () => {
143143

144144
test("github-copilot is excluded in GitHub Actions with GITHUB_TOKEN", async () => {
145145
await withEnv(
146-
{ GITHUB_ACTIONS: "true", CI: "true", GITHUB_TOKEN: "ghs_workflow_token" },
146+
{ GITHUB_ACTIONS: "true", CI: "true", GITHUB_TOKEN: "test-actions-token" },
147147
async () => {
148148
const providers = await Provider.list()
149149
expect(providers["github-copilot"]).toBeUndefined()
@@ -154,7 +154,7 @@ describe("GitHub Actions provider detection", () => {
154154
// CI=true alone (generic CI) should NOT block — only GITHUB_ACTIONS matters
155155
test("github-models is available in generic CI (CI=true without GITHUB_ACTIONS)", async () => {
156156
await withEnv(
157-
{ CI: "true", GITHUB_TOKEN: "ghp_personal_token" },
157+
{ CI: "true", GITHUB_TOKEN: "test-personal-token" },
158158
async () => {
159159
const providers = await Provider.list()
160160
expect(providers["github-models"]).toBeDefined()
@@ -173,7 +173,7 @@ describe("Adversarial: Codespace edge cases", () => {
173173
test("CODESPACES=false does NOT trigger Codespace detection", async () => {
174174
// Some users might set CODESPACES=false in local dev
175175
await withEnv(
176-
{ CODESPACES: "false", GITHUB_TOKEN: "ghp_personal" },
176+
{ CODESPACES: "false", GITHUB_TOKEN: "test-personal-token" },
177177
async () => {
178178
const providers = await Provider.list()
179179
// "false" is truthy in Boolean() — this tests our detection
@@ -186,7 +186,7 @@ describe("Adversarial: Codespace edge cases", () => {
186186

187187
test("CODESPACES='' (empty) does NOT trigger Codespace detection", async () => {
188188
await withEnv(
189-
{ CODESPACES: "", GITHUB_TOKEN: "ghp_personal" },
189+
{ CODESPACES: "", GITHUB_TOKEN: "test-personal-token" },
190190
async () => {
191191
const providers = await Provider.list()
192192
expect(providers["github-models"]).toBeDefined()
@@ -200,7 +200,7 @@ describe("Adversarial: Codespace edge cases", () => {
200200
// We don't check prefixes — the env var NAME is what matters
201201

202202
test("works regardless of token prefix (ghu_, ghs_, ghp_, github_pat_)", async () => {
203-
const prefixes = ["ghu_test", "ghs_test", "ghp_test", "github_pat_test"]
203+
const prefixes = ["test-token-a", "test-token-b", "test-token-c", "test-token-d"]
204204
for (const token of prefixes) {
205205
await withEnv(
206206
{ CODESPACES: "true", GITHUB_TOKEN: token },
@@ -229,7 +229,7 @@ describe("Adversarial: Codespace edge cases", () => {
229229
await Instance.provide({
230230
directory: tmp.path,
231231
init: async () => {
232-
Env.set("GITHUB_TOKEN", "ghp_real_personal_token")
232+
Env.set("GITHUB_TOKEN", "test-real-personal-token")
233233
},
234234
fn: async () => {
235235
const providers = await Provider.list()
@@ -250,7 +250,7 @@ describe("Adversarial: Codespace edge cases", () => {
250250
provider: {
251251
"github-models": {
252252
options: {
253-
apiKey: "ghp_explicitly_configured_token",
253+
apiKey: "test-explicit-config-token",
254254
},
255255
},
256256
},
@@ -262,7 +262,7 @@ describe("Adversarial: Codespace edge cases", () => {
262262
directory: tmp.path,
263263
init: async () => {
264264
Env.set("CODESPACES", "true")
265-
Env.set("GITHUB_TOKEN", "ghu_machine_token")
265+
Env.set("GITHUB_TOKEN", "test-machine-token")
266266
},
267267
fn: async () => {
268268
const providers = await Provider.list()
@@ -286,7 +286,7 @@ describe("Adversarial: Codespace edge cases", () => {
286286

287287
test("both CODESPACES and GITHUB_ACTIONS set blocks providers", async () => {
288288
await withEnv(
289-
{ CODESPACES: "true", GITHUB_ACTIONS: "true", GITHUB_TOKEN: "ghu_test" },
289+
{ CODESPACES: "true", GITHUB_ACTIONS: "true", GITHUB_TOKEN: "test-machine-token" },
290290
async () => {
291291
const providers = await Provider.list()
292292
expect(providers["github-models"]).toBeUndefined()
@@ -298,7 +298,7 @@ describe("Adversarial: Codespace edge cases", () => {
298298

299299
test("anthropic provider is NOT blocked in Codespace", async () => {
300300
await withEnv(
301-
{ CODESPACES: "true", GITHUB_TOKEN: "ghu_test", ANTHROPIC_API_KEY: "sk-ant-test" },
301+
{ CODESPACES: "true", GITHUB_TOKEN: "test-machine-token", ANTHROPIC_API_KEY: "test-anthropic-key" },
302302
async () => {
303303
const providers = await Provider.list()
304304
expect(providers["anthropic"]).toBeDefined()
@@ -308,7 +308,7 @@ describe("Adversarial: Codespace edge cases", () => {
308308

309309
test("openai provider is NOT blocked in Codespace", async () => {
310310
await withEnv(
311-
{ CODESPACES: "true", GITHUB_TOKEN: "ghu_test", OPENAI_API_KEY: "sk-test" },
311+
{ CODESPACES: "true", GITHUB_TOKEN: "test-machine-token", OPENAI_API_KEY: "test-openai-key" },
312312
async () => {
313313
const providers = await Provider.list()
314314
expect(providers["openai"]).toBeDefined()
@@ -425,7 +425,7 @@ describe("Full Codespace environment simulation", () => {
425425
const FULL_CODESPACE_ENV = {
426426
CODESPACES: "true",
427427
CODESPACE_NAME: "user-literate-space-parakeet-abc123",
428-
GITHUB_TOKEN: "ghu_abcdef1234567890abcdef1234567890abcd",
428+
GITHUB_TOKEN: "test-full-codespace-token",
429429
GITHUB_USER: "testuser",
430430
GITHUB_REPOSITORY: "testorg/test-repo",
431431
GITHUB_API_URL: "https://api.github.com",
@@ -460,7 +460,7 @@ describe("Full Codespace environment simulation", () => {
460460

461461
test("full Codespace env + explicit Anthropic key: both work", async () => {
462462
await withEnv(
463-
{ ...FULL_CODESPACE_ENV, ANTHROPIC_API_KEY: "sk-ant-api03-test" },
463+
{ ...FULL_CODESPACE_ENV, ANTHROPIC_API_KEY: "test-anthropic-key" },
464464
async () => {
465465
const providers = await Provider.list()
466466
expect(providers["github-models"]).toBeUndefined()

packages/opencode/test/provider/provider.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,7 +2298,7 @@ test("github-models is excluded when CODESPACES=true and only GITHUB_TOKEN is se
22982298
await Instance.provide({
22992299
directory: tmp.path,
23002300
init: async () => {
2301-
Env.set("GITHUB_TOKEN", "ghu_fake_codespace_token")
2301+
Env.set("GITHUB_TOKEN", "test-codespace-token")
23022302
Env.set("CODESPACES", "true")
23032303
},
23042304
fn: async () => {
@@ -2322,7 +2322,7 @@ test("github-models is available when GITHUB_TOKEN set without CODESPACES", asyn
23222322
await Instance.provide({
23232323
directory: tmp.path,
23242324
init: async () => {
2325-
Env.set("GITHUB_TOKEN", "ghp_real_personal_token")
2325+
Env.set("GITHUB_TOKEN", "test-personal-token")
23262326
},
23272327
fn: async () => {
23282328
const providers = await Provider.list()
@@ -2345,7 +2345,7 @@ test("github-copilot is excluded when CODESPACES=true and only GITHUB_TOKEN is s
23452345
await Instance.provide({
23462346
directory: tmp.path,
23472347
init: async () => {
2348-
Env.set("GITHUB_TOKEN", "ghu_fake_codespace_token")
2348+
Env.set("GITHUB_TOKEN", "test-codespace-token")
23492349
Env.set("CODESPACES", "true")
23502350
},
23512351
fn: async () => {

0 commit comments

Comments
 (0)