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(