@@ -167,6 +167,21 @@ async function postThreadGoal(
167167 } ) ;
168168}
169169
170+ async function getThreadGoal (
171+ proxy : RuntimeRotationProxyServer ,
172+ path = "/thread/goal/get" ,
173+ headers : Record < string , string > = { } ,
174+ ) : Promise < Response > {
175+ return fetch ( `${ proxy . baseUrl } ${ path } ` , {
176+ method : "GET" ,
177+ headers : {
178+ authorization : `Bearer ${ DEFAULT_CLIENT_API_KEY } ` ,
179+ "x-api-key" : "caller-key" ,
180+ ...headers ,
181+ } ,
182+ } ) ;
183+ }
184+
170185async function postRawResponses (
171186 proxy : RuntimeRotationProxyServer ,
172187 body : string ,
@@ -617,6 +632,33 @@ describe("runtime rotation proxy", () => {
617632 ] ) ;
618633 } ) ;
619634
635+ it ( "keys blocked GET thread goal fallbacks by query thread id" , async ( ) => {
636+ const now = Date . now ( ) ;
637+ const accountManager = new AccountManager ( undefined , createStorage ( now ) ) ;
638+ const { calls, fetchImpl } = createRecordingFetch (
639+ ( ) =>
640+ new Response ( "<html>blocked</html>" , {
641+ status : HTTP_STATUS . FORBIDDEN ,
642+ headers : { "content-type" : "text/html" } ,
643+ } ) ,
644+ ) ;
645+ const proxy = await startProxy ( { accountManager, fetchImpl } ) ;
646+
647+ await postThreadGoal (
648+ proxy ,
649+ { threadId : "thread-1" , goal : "ship it" } ,
650+ "/thread/goal/set" ,
651+ ) ;
652+ const response = await getThreadGoal ( proxy , "/thread/goal/get?thread_id=thread-1" ) ;
653+
654+ expect ( response . status ) . toBe ( HTTP_STATUS . OK ) ;
655+ expect ( await response . json ( ) ) . toEqual ( { goal : "ship it" } ) ;
656+ expect ( calls . map ( ( call ) => call . url ) ) . toEqual ( [
657+ "https://example.test/backend-api/codex/thread/goal/set" ,
658+ "https://example.test/backend-api/codex/thread/goal/get?thread_id=thread-1" ,
659+ ] ) ;
660+ } ) ;
661+
620662 it ( "rejects unauthenticated model discovery requests" , async ( ) => {
621663 const now = Date . now ( ) ;
622664 const accountManager = new AccountManager ( undefined , createStorage ( now ) ) ;
0 commit comments