From 93826044426d83490be22fb7b0d22b012f149430 Mon Sep 17 00:00:00 2001 From: Heimdall Date: Tue, 10 Nov 2026 19:20:22 +0000 Subject: [PATCH] desk: pin decoding failures as misses in the {mind} resolver tests Hand mutation showed strict UTF-8, non-ASCII refusal and bad-escape refusal were unobserved; a configured id that spells the failure now exposes each. Co-Authored-By: Claude Sonnet 5.5 --- .../Bifrost.Web.Tests/DeskMindRoutesTests.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Bifrost.Web.Tests/DeskMindRoutesTests.cs b/tests/Bifrost.Web.Tests/DeskMindRoutesTests.cs index b7b2207..f8d9604 100644 --- a/tests/Bifrost.Web.Tests/DeskMindRoutesTests.cs +++ b/tests/Bifrost.Web.Tests/DeskMindRoutesTests.cs @@ -101,5 +101,25 @@ public sealed class DeskMindRoutesTests Assert.Equal("/s/A", routes.Resolve("A")!.Socket); } + [Fact] + public void A_decoding_failure_is_a_miss_even_when_the_failure_spells_a_configured_id() + { + var replacement = char.ConvertFromUtf32(0xFFFD); + var e = char.ConvertFromUtf32(0xE9); + var routes = new DeskMindRoutes([ + new DeskMindOptions { Id = replacement, Socket = "/s/replacement" }, + new DeskMindOptions { Id = e, Socket = "/s/e-acute" }, + new DeskMindOptions { Id = "a%zz", Socket = "/s/bad-escape" }, + new DeskMindOptions { Id = "100%", Socket = "/s/trailing" }, + ]); + + Assert.Null(routes.Resolve("%ff")); // not UTF-8, not U+FFFD + Assert.Null(routes.Resolve(char.ConvertFromUtf32(0xC3) + char.ConvertFromUtf32(0xA9))); // UTF-8 bytes as raw chars + Assert.Null(routes.Resolve("a%zz")); + Assert.Null(routes.Resolve("100%")); + Assert.Equal("/s/replacement", routes.Resolve("%ef%bf%bd")!.Socket); // the real encoding still resolves + Assert.Equal("/s/e-acute", routes.Resolve("%c3%a9")!.Socket); + } + private static string Short(string value) => value.Length > 40 ? value[..40] + "..." : value; }