Path: redb-identity/tests/redb.Identity.Tests/Soap/SoapFacadeModuleTests.cs Snapshot: redb-identity, 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-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/tests/redb.Identity.Tests/Soap/SoapFacadeModuleTests.cs ---- using System.Net; using System.Net.Sockets; using AwesomeAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Route.Core; using Xunit; namespace redb.Identity.Tests.Soap; /// /// F1 — the WS-Trust facade module boots: its config binder reads the Tsak-merged section, its module /// host builds a child container, and its route builder mounts the STS listener. /// /// InitRoute.main is called exactly the way the worker calls it, so everything but Tsak's own ALC /// loading is exercised. The packaging path is verified by loading the .tpkg in a worker. /// /// public class SoapFacadeModuleTests : IAsyncLifetime { private ServiceProvider _sp = null!; private RouteContext _context = null!; private int _port; private static int GetFreePort() { var listener = new TcpListener(IPAddress.Loopback, 0); listener.Start(); var port = ((IPEndPoint)listener.LocalEndpoint).Port; listener.Stop(); return port; } public Task InitializeAsync() { _port = GetFreePort(); var services = new ServiceCollection(); services.AddLogging(); _sp = services.BuildServiceProvider(); _context = new RouteContext(_sp, "identity.soap-test"); return Task.CompletedTask; } public async Task DisposeAsync() { await _context.DisposeAsync(); await _sp.DisposeAsync(); } /// /// What Tsak hands a module: the merged 5-layer configuration as a nested dictionary. Using the real /// property name means the binder is exercised rather than bypassed. /// private void Configure(params (string Key, object? Value)[] soapSettings) { var soap = new Dictionary { ["Host"] = "127.0.0.1", ["Port"] = _port, }; foreach (var (key, value) in soapSettings) soap[key] = value; _context.SetProperty>("IdentityTransport", new Dictionary { ["Soap"] = soap }); } [Fact] public async Task Module_boots_and_mounts_the_sts_route() { // TLS is mandatory for this facade; a test has no certificate, so it takes the documented way out // — the same one an operator behind a terminating proxy takes. Configure(("Ssl", false), ("AllowPlaintext", true)); Identity.Soap.InitRoute.main(_context); await _context.Start(); // One route, not four: WS-Trust puts every operation on one address and tells them apart by the // WS-Addressing Action. The endpoint count in a worker log is therefore 1 for this module. _context.Routes.Select(r => r.RouteId).Should().Contain("soap-identity-sts"); } /// /// The refusal is the feature. UsernameToken carries the client secret in clear text, so an STS /// on plain HTTP publishes credentials to anyone on the path — and a warning in a log is read after /// the fact, when the credentials have already travelled. /// [Fact] public async Task Without_tls_the_facade_refuses_to_start() { Configure(("Ssl", false)); Identity.Soap.InitRoute.main(_context); var boot = async () => await _context.Start(); (await boot.Should().ThrowAsync()) .WithMessage("*refuses to start without TLS*"); } /// /// A typo in the client-certificate mode must not read as «no certificate»: that would turn mTLS off /// on an endpoint whose operator believes it is on, and nothing anywhere would say so. /// [Fact] public async Task An_unknown_client_certificate_mode_is_refused() { Configure(("AllowPlaintext", true), ("Ssl", false), ("ClientCertificateMode", "Required")); Identity.Soap.InitRoute.main(_context); var boot = async () => await _context.Start(); (await boot.Should().ThrowAsync()) .WithMessage("*ClientCertificateMode*"); } }