Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(llm-proxy): require the runtime rate limiter to answer JSON rate_limited
Alfredo Lopez9076805a2589
diff --git a/codex-llm-proxy/test/server.security.test.ts b/codex-llm-proxy/test/server.security.test.tsindex ced2ed0bd..2cb00cfa1 100644--- a/codex-llm-proxy/test/server.security.test.ts+++ b/codex-llm-proxy/test/server.security.test.ts@@ -274,6 +274,13 @@ describe('codex-llm-proxy security surface', () => {// check turns the same request into a 401.const limited = await completion().send(oversized)expect(limited.status).toBe(429)+ // G1-2 (#720): the Host reads the JSON error code; a text body would fall+ // back to provider_unavailable ("Model Overloaded").+ expect(limited.headers['content-type']).toMatch(/^application\/json/)+ expect(limited.body).toEqual({ error: 'rate_limited' })+ // The library's own headers stay: Retry-After and the draft-7 pair.+ expect(limited.headers['retry-after']).toMatch(/^[1-9][0-9]*$/)+ expect(limited.headers['ratelimit-policy']).toBe('60;w=60')})it('rejects a platform JWT whose hostRefs do not bind the ticket hostRef', async () => {diff --git a/grok-llm-proxy/test/server.security.test.ts b/grok-llm-proxy/test/server.security.test.tsindex 5aa603b2a..787dff47f 100644--- a/grok-llm-proxy/test/server.security.test.ts+++ b/grok-llm-proxy/test/server.security.test.ts@@ -177,6 +177,26 @@ describe('grok-llm-proxy security surface', () => {expect(res.status).toBe(413)})+ it('(g1-2) rate limits the completion endpoint with a JSON rate_limited body', async () => {+ const { runtimeApp } = createProxyApps(config())+ const completion = () => request(runtimeApp).post('/internal/runtime/v1/grok/completions')+ // Within the window every request reaches the platform JWT gate: the witness+ // that the 61st rejection comes from the limiter and not from that gate.+ for (let i = 0; i < 60; i += 1) {+ const accepted = await completion().send({})+ expect(accepted.status).toBe(401)+ }+ const limited = await completion().send({})+ expect(limited.status).toBe(429)+ // G1-2 (#720): the Host reads the JSON error code; a text body would fall+ // back to provider_unavailable ("Model Overloaded").+ expect(limited.headers['content-type']).toMatch(/^application\/json/)+ expect(limited.body).toEqual({ error: 'rate_limited' })+ // The library's own headers stay: Retry-After and the draft-7 pair.+ expect(limited.headers['retry-after']).toMatch(/^[1-9][0-9]*$/)+ expect(limited.headers['ratelimit-policy']).toBe('60;w=60')+ })+it('rejects a platform JWT whose hostRefs do not bind the ticket hostRef', async () => {const { runtimeApp } = createProxyApps(config())const foreign = sign(