From fe93fcbed624065c376eac46647f4a8603f71977 Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> Date: Mon, 20 Jul 2026 22:04:45 +0100 Subject: [PATCH] .NET: Add source-type-agnostic consent regression test for a2a_preview --- .../ToolboxConsentParserTests.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/ToolboxConsentParserTests.cs b/dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/ToolboxConsentParserTests.cs index 4f3e961526c..3d008ef0f16 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/ToolboxConsentParserTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/ToolboxConsentParserTests.cs @@ -24,6 +24,32 @@ public void TryParseConsentRequired_SingleConsentError_ReturnsTrueWithUrlAndTool Assert.Equal("https://login.example.com/consent?data=abc", consent.ConsentUrl); } + [Theory] + [InlineData("mcp")] + [InlineData("a2a_preview")] + [InlineData("some_future_source")] + public void TryParseConsentRequired_IsSourceTypeAgnostic_ReturnsTrue(string sourceType) + { + // Arrange: consent detection keys off the nested CONSENT_REQUIRED error code, not the + // tool source "type". Work IQ emits "a2a_preview" (issue #7227) rather than "mcp"; the + // parser must surface consent for any source type so hosting does not fail like the + // Python parser that hard-coded type == "mcp". + string message = + "Request failed (remote): tools/list failed for 1 tool source(s), succeeded for 0 tool source(s) " + + "{\"errors\":[{\"name\":\"work-iq-connection\",\"type\":\"" + sourceType + "\"," + + "\"error\":{\"code\":\"CONSENT_REQUIRED\",\"message\":\"https://consent.example/login?data=xyz\"}}]}"; + + // Act + var parsed = ToolboxConsentParser.TryParseConsentRequired("work-iq-toolbox", message, out var consents); + + // Assert + Assert.True(parsed); + var consent = Assert.Single(consents); + Assert.Equal("work-iq-toolbox", consent.ToolboxName); + Assert.Equal("work-iq-connection", consent.ToolName); + Assert.Equal("https://consent.example/login?data=xyz", consent.ConsentUrl); + } + [Fact] public void TryParseConsentRequired_MultipleConsentErrors_ReturnsAll() {