fix(a2a): continuations emit the resumed task, guarded clients bypass proxies
A continued task (input-required -> new message) produced only status updates, so the SDK answered 'Agent handler did not produce any response events'. The handler now enqueues the resumed task (caller message and question in history, working) as the first event. The guarded SocketsHttpHandler sets UseProxy = false: a proxy would make the connection and skip the ConnectCallback address check.
This commit is contained in:
@@ -63,6 +63,36 @@ public class PushUrlGuardAddressTests
|
||||
public void GuardedHandler_DoesNotFollowRedirects() =>
|
||||
Assert.False(PushUrlGuard.CreateGuardedHandler(() => false).AllowAutoRedirect);
|
||||
|
||||
[Fact]
|
||||
public void GuardedHandler_BypassesProxies() =>
|
||||
Assert.False(PushUrlGuard.CreateGuardedHandler(() => false).UseProxy);
|
||||
|
||||
[Fact]
|
||||
public async Task GuardedHandler_AllowPrivate_ConnectsToLoopback()
|
||||
{
|
||||
using var listener = new System.Net.Sockets.TcpListener(IPAddress.Loopback, 0);
|
||||
listener.Start();
|
||||
var port = ((IPEndPoint)listener.LocalEndpoint).Port;
|
||||
var server = Task.Run(async () =>
|
||||
{
|
||||
using var client = await listener.AcceptTcpClientAsync();
|
||||
var stream = client.GetStream();
|
||||
var buffer = new byte[4096];
|
||||
var request = "";
|
||||
while (!request.Contains("\r\n\r\n"))
|
||||
{
|
||||
var read = await stream.ReadAsync(buffer);
|
||||
if (read == 0) break;
|
||||
request += System.Text.Encoding.ASCII.GetString(buffer, 0, read);
|
||||
}
|
||||
await stream.WriteAsync("HTTP/1.1 200 OK\r\nContent-Length: 2\r\nConnection: close\r\n\r\nok"u8.ToArray());
|
||||
});
|
||||
using var http = new HttpClient(PushUrlGuard.CreateGuardedHandler(() => true,
|
||||
(_, _) => Task.FromResult(new[] { IPAddress.Loopback })));
|
||||
Assert.Equal("ok", await http.GetStringAsync($"http://hooks.example:{port}/x"));
|
||||
await server;
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("tok\r\nX-Evil: 1", null, "token")]
|
||||
[InlineData(null, "Bearer x", "scheme")]
|
||||
|
||||
Reference in New Issue
Block a user