@@ -123,6 +123,19 @@ describe("Codex account pool strategy management API", () => {
123123 expect ( config . accountPoolStrategy ) . toBe ( "quota" ) ;
124124 expect ( config . accountPoolStickyLimit ) . toBe ( 1 ) ;
125125 } ) ;
126+
127+ test ( "PUT /api/codex-auth/pool-strategy rejects non-object JSON bodies with 400" , async ( ) => {
128+ for ( const raw of [ "null" , "[]" , "\"round-robin\"" , "1" ] ) {
129+ const req = new Request ( "http://localhost/api/codex-auth/pool-strategy" , {
130+ method : "PUT" ,
131+ headers : { "Content-Type" : "application/json" } ,
132+ body : raw ,
133+ } ) ;
134+ const resp = await handleCodexAuthAPI ( req , new URL ( req . url ) , makeCodexConfig ( ) ) ;
135+ expect ( resp ! . status ) . toBe ( 400 ) ;
136+ expect ( await resp ! . json ( ) ) . toMatchObject ( { error : "body must be an object" } ) ;
137+ }
138+ } ) ;
126139} ) ;
127140describe ( "Anthropic account pool strategy management API" , ( ) => {
128141 let testDir = "" ;
@@ -196,6 +209,23 @@ describe("Anthropic account pool strategy management API", () => {
196209 }
197210 } ) ;
198211
212+ test ( "PUT /api/oauth/accounts/pool rejects non-object JSON bodies with 400" , async ( ) => {
213+ const server = startServer ( 0 ) ;
214+ try {
215+ for ( const raw of [ "null" , "[]" , "\"round-robin\"" ] ) {
216+ const res = await fetch ( new URL ( "/api/oauth/accounts/pool" , server . url ) , {
217+ method : "PUT" ,
218+ headers : { "Content-Type" : "application/json" } ,
219+ body : raw ,
220+ } ) ;
221+ expect ( res . status ) . toBe ( 400 ) ;
222+ expect ( await res . json ( ) ) . toMatchObject ( { error : "body must be an object" } ) ;
223+ }
224+ } finally {
225+ await server . stop ( true ) ;
226+ }
227+ } ) ;
228+
199229 test ( "PUT /api/oauth/accounts/pool rejects invalid stickyLimit" , async ( ) => {
200230 const server = startServer ( 0 ) ;
201231 try {
0 commit comments