feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
|
|
@ -232,3 +232,42 @@ Deno.test('auth rejection response is returned as-is and non-POST is 405', async
|
|||
assertEquals(preflight.status, 200, 'preflight status')
|
||||
await preflight.body?.cancel()
|
||||
})
|
||||
|
||||
Deno.test('malformed or oversized JSON returns 400/413 and OpenAI provider attaches AbortSignal', async () => {
|
||||
const h = harness()
|
||||
const badJson = await h.handler(new Request('http://localhost/realtime-token', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: '{broken',
|
||||
}))
|
||||
assertEquals(badJson.status, 400, 'malformed json status')
|
||||
assertEquals(await badJson.json(), { error: 'invalid_json' }, 'malformed json body')
|
||||
|
||||
const oversized = await h.handler(new Request('http://localhost/realtime-token', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ instructions: 'x'.repeat(20_000) }),
|
||||
}))
|
||||
assertEquals(oversized.status, 413, 'oversized json status')
|
||||
assertEquals(await oversized.json(), { error: 'request_too_large' }, 'oversized json body')
|
||||
|
||||
const emptyPost = await h.handler(new Request('http://localhost/realtime-token', { method: 'POST' }))
|
||||
assertEquals(emptyPost.status, 200, 'empty POST defaults to {}')
|
||||
await emptyPost.body?.cancel()
|
||||
|
||||
let capturedSignal: unknown
|
||||
const provider = createOpenAiRealtimeProvider({
|
||||
readApiKey: () => 'sk-test',
|
||||
fetchImpl: (_url, init) => {
|
||||
capturedSignal = init && 'signal' in init ? init.signal : undefined
|
||||
return Promise.resolve(new Response(JSON.stringify({ value: 'ek_ok' }), { status: 200 }))
|
||||
},
|
||||
})
|
||||
const minted = await provider.mintClientSecret('user-1', {
|
||||
type: 'realtime',
|
||||
model: 'gpt-realtime-2.1-mini',
|
||||
instructions: '',
|
||||
audio: { output: { voice: 'alloy' } },
|
||||
})
|
||||
assert(minted.ok && capturedSignal instanceof AbortSignal, 'provider request must carry AbortSignal')
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue