Path: redb-route/tests/redb.Route.Tests.SignalR/SignalRConnectionFactoryTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.SignalR/SignalRConnectionFactoryTests.cs ---- using redb.Route.Core; using redb.Route.SignalR; namespace redb.Route.Tests.SignalR; /// /// The hub access token and TLS certificate password must be able to live in the registry instead /// of the endpoint URI, so they never reach logs, telemetry, or the dashboard. /// public sealed class SignalRConnectionFactoryTests { private const string Secret = "hubAcc3ssT0ken"; private static SignalRComponent Wire(string name, SignalRConnectionFactory factory) { var context = new RouteContext(); var component = new SignalRComponent(); context.AddComponent(component); context.AddToRegistry(name, factory); return component; } [Fact] public void Factory_SuppliesAccessToken_WhenUriCarriesNone() { var component = Wire("chat-hub", new SignalRConnectionFactory { AccessToken = Secret, Ssl = true, SslCertPath = "/etc/redb/certs/server.pfx", SslCertPassword = "pfxPw" }); var uri = EndpointUriParser.Parse("signalr://0.0.0.0:5000/chatHub?connectionFactory=chat-hub"); var endpoint = (SignalREndpoint)component.CreateEndpoint(uri); endpoint.EndpointOptions.AccessToken.Should().Be(Secret); uri.ToUriString().Should().NotContain(Secret); uri.ToString().Should().NotContain(Secret); } [Fact] public void ExplicitUriValue_WinsOverFactory() { var component = Wire("f", new SignalRConnectionFactory { AccessToken = "from-factory" }); var uri = EndpointUriParser.Parse( "signalr://0.0.0.0:5000/chatHub?connectionFactory=f&accessToken=from-uri"); var endpoint = (SignalREndpoint)component.CreateEndpoint(uri); endpoint.EndpointOptions.AccessToken.Should().Be("from-uri"); } [Fact] public void MissingFactory_FailsLoud() { var context = new RouteContext(); var component = new SignalRComponent(); context.AddComponent(component); var uri = EndpointUriParser.Parse("signalr://0.0.0.0:5000/chatHub?connectionFactory=absent"); var act = () => component.CreateEndpoint(uri); // A typo in connectionFactory must fail loud, not fall back silently act.Should().Throw() .Which.Message.Should().Contain("absent"); } }