diff options
| author | Kit Langton <[email protected]> | 2026-05-03 17:13:42 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-05-03 21:13:42 +0000 |
| commit | ca6150d6f092cc8761d6072b0b07b6a7de8748cf (patch) | |
| tree | 2e62b173530b8bb8f1d0d9583764217d3b7a888b /packages/app/src/context/server.test.ts | |
| parent | 825ab2e38d1f41074bb536b6ba5771f30594b197 (diff) | |
| download | opencode-ca6150d6f092cc8761d6072b0b07b6a7de8748cf.tar.gz opencode-ca6150d6f092cc8761d6072b0b07b6a7de8748cf.zip | |
fix(app): preserve auth token credentials (#25636)
Diffstat (limited to 'packages/app/src/context/server.test.ts')
| -rw-r--r-- | packages/app/src/context/server.test.ts | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/packages/app/src/context/server.test.ts b/packages/app/src/context/server.test.ts new file mode 100644 index 000000000..1fa35247c --- /dev/null +++ b/packages/app/src/context/server.test.ts @@ -0,0 +1,53 @@ +import { describe, expect, test } from "bun:test" +import { resolveServerList, ServerConnection } from "./server" + +describe("resolveServerList", () => { + test("lets startup auth_token credentials override a persisted same-url server", () => { + const list = resolveServerList({ + stored: [{ url: "https://server.example.test" }], + props: [ + { + type: "http", + authToken: true, + http: { + url: "https://server.example.test", + username: "opencode", + password: "secret", + }, + }, + ], + }) + + expect(list).toHaveLength(1) + expect(list[0]?.type).toBe("http") + expect(list[0]?.http).toEqual({ + url: "https://server.example.test", + username: "opencode", + password: "secret", + }) + expect(list[0]?.type === "http" ? list[0].authToken : false).toBe(true) + expect(ServerConnection.key(list[0]!) as string).toBe("https://server.example.test") + }) + + test("keeps persisted credentials when startup has no auth_token", () => { + const list = resolveServerList({ + stored: [ + { + url: "https://server.example.test", + username: "opencode", + password: "saved", + }, + ], + props: [{ type: "http", http: { url: "https://server.example.test" } }], + }) + + expect(list).toHaveLength(1) + expect(list[0]?.type).toBe("http") + expect(list[0]?.http).toEqual({ + url: "https://server.example.test", + username: "opencode", + password: "saved", + }) + expect(list[0]?.type === "http" ? list[0].authToken : true).toBeUndefined() + }) +}) |
