@@ -1865,6 +1865,56 @@ describe("OpenResponses HTTP API (e2e)", () => {
18651865 }
18661866 }
18671867
1868+ agentCommand . mockClear ( ) ;
1869+ agentCommand . mockResolvedValue ( { payloads : [ { text : "hello" } ] } as never ) ;
1870+ const forwardedHeaders = {
1871+ "x-forwarded-proto" : "https" ,
1872+ authorization : "Bearer forwarded-untrusted" ,
1873+ } ;
1874+ const aliceResponse = await postResponses (
1875+ port ,
1876+ { model : "openclaw" , user : "alice" , input : "private alice history" } ,
1877+ { ...
forwardedHeaders , "x-forwarded-user" :
"[email protected] " } , 1878+ ) ;
1879+ expect ( aliceResponse . status ) . toBe ( 200 ) ;
1880+ const aliceResponseId = ( ( await aliceResponse . json ( ) ) as { id : string } ) . id ;
1881+ const aliceSessionKey = requireSessionKey (
1882+ firstAgentOpts ( ) . sessionKey as string | undefined ,
1883+ "Alice trusted-proxy response" ,
1884+ ) ;
1885+
1886+ const aliceContinuation = await postResponses (
1887+ port ,
1888+ {
1889+ model : "openclaw" ,
1890+ user : "alice" ,
1891+ previous_response_id : aliceResponseId ,
1892+ input : "continue alice history" ,
1893+ } ,
1894+ {
1895+ ...forwardedHeaders ,
1896+ authorization : "Bearer different-forwarded-untrusted" ,
1897+ "x-forwarded-user" :
"[email protected] " , 1898+ } ,
1899+ ) ;
1900+ expect ( aliceContinuation . status ) . toBe ( 200 ) ;
1901+ await ensureResponseConsumed ( aliceContinuation ) ;
1902+
1903+ const bobContinuation = await postResponses (
1904+ port ,
1905+ {
1906+ model : "openclaw" ,
1907+ user : "bob" ,
1908+ previous_response_id : aliceResponseId ,
1909+ input : "attempt alice history" ,
1910+ } ,
1911+ { ...
forwardedHeaders , "x-forwarded-user" :
"[email protected] " } , 1912+ ) ;
1913+ expect ( bobContinuation . status ) . toBe ( 200 ) ;
1914+ await ensureResponseConsumed ( bobContinuation ) ;
1915+ expect ( firstAgentOpts ( 2 ) . sessionKey ) . not . toBe ( aliceSessionKey ) ;
1916+ expect ( firstAgentOpts ( 1 ) . sessionKey ) . toBe ( aliceSessionKey ) ;
1917+
18681918 agentCommand . mockClear ( ) ;
18691919 const unauthorized = await postResponses (
18701920 port ,
0 commit comments