auth.test.ts 495 B

123456789
  1. import { expect, test } from "bun:test"
  2. import { ServerAuth } from "@opencode-ai/server/auth"
  3. import { Option, Redacted } from "effect"
  4. test("accepts only the fixed opencode username", () => {
  5. const config = { password: Option.some("secret"), username: "opencode" }
  6. expect(ServerAuth.authorized({ username: "opencode", password: Redacted.make("secret") }, config)).toBe(true)
  7. expect(ServerAuth.authorized({ username: "custom", password: Redacted.make("secret") }, config)).toBe(false)
  8. })