refactor: isolate legacy flags
This commit is contained in:
parent
407ac2d8aa
commit
43c08387f1
65 changed files with 282 additions and 147 deletions
13
packages/server/test/auth.test.ts
Normal file
13
packages/server/test/auth.test.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
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") }
|
||||
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")}`)
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue