mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-21 18:26:09 +00:00
14 lines
670 B
TypeScript
14 lines
670 B
TypeScript
import { expect, test } from "bun:test"
|
|
import { ServerAuth } from "@opencode-ai/server/auth"
|
|
import { Option, Redacted } from "effect"
|
|
|
|
test("accepts only the fixed opencode username", () => {
|
|
const config = { password: Option.some("secret"), username: "opencode" }
|
|
expect(ServerAuth.authorized({ username: "opencode", password: Redacted.make("secret") }, config)).toBe(true)
|
|
expect(ServerAuth.authorized({ username: "custom", password: Redacted.make("secret") }, config)).toBe(false)
|
|
})
|
|
|
|
test("encodes the fixed opencode username", () => {
|
|
expect(ServerAuth.header({ password: "secret" })).toBe(`Basic ${Buffer.from("opencode:secret").toString("base64")}`)
|
|
})
|