diff --git a/source/Halibut.Tests.DotMemory/Halibut.Tests.DotMemory.csproj b/source/Halibut.Tests.DotMemory/Halibut.Tests.DotMemory.csproj index cbd3546a..84fb9e31 100644 --- a/source/Halibut.Tests.DotMemory/Halibut.Tests.DotMemory.csproj +++ b/source/Halibut.Tests.DotMemory/Halibut.Tests.DotMemory.csproj @@ -39,7 +39,7 @@ - + diff --git a/source/Halibut.Tests/Halibut.Tests.csproj b/source/Halibut.Tests/Halibut.Tests.csproj index a89c6a6e..4862ad72 100644 --- a/source/Halibut.Tests/Halibut.Tests.csproj +++ b/source/Halibut.Tests/Halibut.Tests.csproj @@ -44,10 +44,11 @@ + - + diff --git a/source/Halibut.Tests/Support/BackwardsCompatibility/LatestClientAndPreviousServiceVersionBuilder.cs b/source/Halibut.Tests/Support/BackwardsCompatibility/LatestClientAndPreviousServiceVersionBuilder.cs index 4d0d041d..e2a3c904 100644 --- a/source/Halibut.Tests/Support/BackwardsCompatibility/LatestClientAndPreviousServiceVersionBuilder.cs +++ b/source/Halibut.Tests/Support/BackwardsCompatibility/LatestClientAndPreviousServiceVersionBuilder.cs @@ -1,12 +1,17 @@ using System; +using System.Collections.Concurrent; +using System.IO; using System.Threading; using System.Threading.Tasks; +using Halibut.Diagnostics; using Halibut.Diagnostics.LogCreators; using Halibut.Logging; using Halibut.TestProxy; using Halibut.Tests.Support.Logging; using Halibut.Transport.Proxy; using Octopus.TestPortForwarder; +using Serilog; +using ILog = Halibut.Diagnostics.ILog; namespace Halibut.Tests.Support.BackwardsCompatibility { @@ -21,6 +26,7 @@ public class LatestClientAndPreviousServiceVersionBuilder : IClientAndServiceBui ProxyFactory? proxyFactory; Reference? proxyServiceReference; LogLevel halibutLogLevel = LogLevel.Trace; + StringWriter? loggerStringWriter; readonly OldServiceAvailableServices availableServices = new(false, false); LatestClientAndPreviousServiceVersionBuilder(ServiceConnectionType serviceConnectionType, CertAndThumbprint serviceCertAndThumbprint) @@ -59,6 +65,12 @@ public static LatestClientAndPreviousServiceVersionBuilder ForServiceConnectionT } } + public LatestClientAndPreviousServiceVersionBuilder RecordingLogs(out StringWriter stringWriter) + { + loggerStringWriter = stringWriter = new(); + return this; + } + public LatestClientAndPreviousServiceVersionBuilder WithServiceVersion(Version? version) { this.version = version; @@ -149,7 +161,11 @@ async Task IClientAndServiceBuilder.Build(CancellationToken c public async Task Build(CancellationToken cancellationToken) { - var logger = new SerilogLoggerBuilder().Build().ForContext(); + var logger = loggerStringWriter == null + ? new SerilogLoggerBuilder() + .Build().ForContext() + : new LoggerConfiguration().WriteTo.TextWriter(loggerStringWriter).CreateLogger(); + CancellationTokenSource cancellationTokenSource = new(); if (version == null) { diff --git a/source/Halibut.Tests/TlsFixture.cs b/source/Halibut.Tests/TlsFixture.cs index ffc332f0..f6d9f057 100644 --- a/source/Halibut.Tests/TlsFixture.cs +++ b/source/Halibut.Tests/TlsFixture.cs @@ -22,6 +22,7 @@ using FluentAssertions; using Halibut.Exceptions; using Halibut.Tests.Support; +using Halibut.Tests.Support.BackwardsCompatibility; using Halibut.Tests.Support.TestAttributes; using Halibut.Tests.Support.TestCases; using Halibut.Tests.TestServices.Async; @@ -62,5 +63,26 @@ public async Task LatestClientAndServiceUseBestAvailableSslProtocol(ClientAndSer .Should().Contain(logEvent => logEvent.FormattedMessage.Contains($"using protocol {expectedSslProtocol}")); } } + + [Test] + // [PreviousClientAndLatestServiceVersionsTestCases(testNetworkConditions: false)] + [LatestClientAndPreviousServiceVersionsTestCases(testNetworkConditions: false)] + public async Task PreviousClientXorServiceUsageMakeSslProtocolFallBackOnTls12(ClientAndServiceTestCase clientAndServiceTestCase) + { + await using (var clientAndService = await ((LatestClientAndPreviousServiceVersionBuilder)(clientAndServiceTestCase.CreateTestCaseBuilder() + .WithStandardServices())) + .RecordingLogs(out var stringWriter) + .Build(CancellationToken)) + { + var echo = clientAndService.CreateAsyncClient(); + await echo.SayHelloAsync("World"); + const SslProtocols expectedProtocol = SslProtocols.Tls12; + var expectedLogFragment = clientAndServiceTestCase.ServiceConnectionType == ServiceConnectionType.Listening + ? $"client connected with {expectedProtocol}" + : $"using protocol {expectedProtocol}"; + var logs = stringWriter.ToString(); + logs.Should().Contain(expectedLogFragment); + } + } } } \ No newline at end of file diff --git a/source/Octopus.TestPortForwarder/Octopus.TestPortForwarder.csproj b/source/Octopus.TestPortForwarder/Octopus.TestPortForwarder.csproj index b9a5fa5f..405b6263 100644 --- a/source/Octopus.TestPortForwarder/Octopus.TestPortForwarder.csproj +++ b/source/Octopus.TestPortForwarder/Octopus.TestPortForwarder.csproj @@ -14,7 +14,7 @@ net8.0 - +