fix: disable unsolicited background UI automation
This commit is contained in:
@@ -15,6 +15,34 @@ public sealed class EventPumpTests
|
||||
{ yield return new AgentEvent("evt", "ui-current", "session", "message", "summary", DateTimeOffset.UtcNow); await Task.Delay(Timeout.Infinite, ct); }
|
||||
}
|
||||
|
||||
private sealed class DisabledSourceBackend : IAgentBackend, IAgentEventSource
|
||||
{
|
||||
public bool ListenCalled { get; private set; }
|
||||
public IReadOnlyList<AgentCapability> Capabilities => [new("listener-events", true, true, false, true, false, "read", false, 30, "disabled", [])];
|
||||
public Task<object> StatusAsync(CancellationToken ct) => Task.FromResult<object>(new { ok = true });
|
||||
public async IAsyncEnumerable<AgentEvent> ListenAsync([EnumeratorCancellation] CancellationToken ct)
|
||||
{
|
||||
ListenCalled = true;
|
||||
await Task.CompletedTask;
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DisabledListenerDoesNotStartUiSource()
|
||||
{
|
||||
var source = new DisabledSourceBackend();
|
||||
using var pump = new EventPump(source, new EventHub(), new ServiceOptions
|
||||
{
|
||||
DataDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N")),
|
||||
CredentialFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"), "credentials.json")
|
||||
});
|
||||
await pump.StartAsync(default);
|
||||
await Task.Delay(100);
|
||||
await pump.StopAsync(default);
|
||||
Assert.False(source.ListenCalled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PumpForwardsToTheConfiguredPrincipal()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user