From 4d4eb7de28a355c4a8ac688c0b5d7a29b7f8bea9 Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Wed, 24 Jun 2026 16:58:30 -0500 Subject: [PATCH] test(mcp): avoid fixed oauth callback ports --- packages/opencode/test/mcp/oauth-callback.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/opencode/test/mcp/oauth-callback.test.ts b/packages/opencode/test/mcp/oauth-callback.test.ts index 584b651df0..46531bda18 100644 --- a/packages/opencode/test/mcp/oauth-callback.test.ts +++ b/packages/opencode/test/mcp/oauth-callback.test.ts @@ -82,12 +82,13 @@ describe("McpOAuthCallback.ensureRunning", () => { }) test("starts server with custom redirectUri port and path", async () => { - await McpOAuthCallback.ensureRunning("http://127.0.0.1:18000/custom/callback") + const port = await getFreeLoopbackPort() + await McpOAuthCallback.ensureRunning(`http://127.0.0.1:${port}/custom/callback`) expect(McpOAuthCallback.isRunning()).toBe(true) }) test("stops after the callback completes", async () => { - const redirectUri = "http://127.0.0.1:18003/custom/callback" + const redirectUri = `http://127.0.0.1:${await getFreeLoopbackPort()}/custom/callback` await McpOAuthCallback.ensureRunning(redirectUri) const callback = McpOAuthCallback.waitForCallback("success") @@ -99,7 +100,7 @@ describe("McpOAuthCallback.ensureRunning", () => { }) test("escapes provider error markup in callback HTML", async () => { - const redirectUri = "http://127.0.0.1:18001/custom/callback" + const redirectUri = `http://127.0.0.1:${await getFreeLoopbackPort()}/custom/callback` await McpOAuthCallback.ensureRunning(redirectUri) const error = `` @@ -114,7 +115,7 @@ describe("McpOAuthCallback.ensureRunning", () => { }) test("keeps normal provider errors readable", async () => { - const redirectUri = "http://127.0.0.1:18002/custom/callback" + const redirectUri = `http://127.0.0.1:${await getFreeLoopbackPort()}/custom/callback` await McpOAuthCallback.ensureRunning(redirectUri) const response = await fetch(