mirror of
https://github.com/NeuralNomadsAI/CodeNomad.git
synced 2026-07-10 00:14:27 +00:00
Fixes #315 ## Summary - stop overwriting configured `OPENCODE_SERVER_USERNAME` and `OPENCODE_SERVER_PASSWORD` when CodeNomad launches managed OpenCode servers - reuse user-provided OpenCode auth from workspace environment or process env before falling back to generated credentials - add focused tests for configured, inherited, and generated auth paths ## Testing - `npx tsx --test "packages/server/src/workspaces/opencode-auth.test.ts"` - `npx tsc --noEmit --target ES2020 --module ESNext --moduleResolution Node --strict --esModuleInterop --types node "packages/server/src/workspaces/opencode-auth.ts" "packages/server/src/workspaces/opencode-auth.test.ts"` - `git diff --check` ## Notes - full server workspace typecheck still has unrelated baseline failures in this branch (`commander` typings and missing `fuzzysort` types)
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import assert from "node:assert/strict"
|
|
import { describe, it } from "node:test"
|
|
|
|
import { resolveOpencodeServerAuth } from "./opencode-auth"
|
|
|
|
describe("resolveOpencodeServerAuth", () => {
|
|
it("uses configured OpenCode auth from workspace environment", () => {
|
|
const auth = resolveOpencodeServerAuth({
|
|
userEnvironment: {
|
|
OPENCODE_SERVER_USERNAME: "alice",
|
|
OPENCODE_SERVER_PASSWORD: "secret",
|
|
},
|
|
processEnv: {},
|
|
generatePassword: () => "generated",
|
|
})
|
|
|
|
assert.deepEqual(auth, { username: "alice", password: "secret" })
|
|
})
|
|
|
|
it("uses process environment when workspace environment does not provide credentials", () => {
|
|
const auth = resolveOpencodeServerAuth({
|
|
userEnvironment: {},
|
|
processEnv: {
|
|
OPENCODE_SERVER_PASSWORD: "process-secret",
|
|
},
|
|
generatePassword: () => "generated",
|
|
})
|
|
|
|
assert.deepEqual(auth, { username: "codenomad", password: "process-secret" })
|
|
})
|
|
|
|
it("falls back to generated credentials", () => {
|
|
const auth = resolveOpencodeServerAuth({
|
|
userEnvironment: {},
|
|
processEnv: {},
|
|
generatePassword: () => "generated",
|
|
})
|
|
|
|
assert.deepEqual(auth, { username: "codenomad", password: "generated" })
|
|
})
|
|
})
|