diff --git a/src/AirGap/StellaOps.AirGap.Policy/StellaOps.AirGap.Policy.Analyzers.Tests/StellaOps.AirGap.Policy.Analyzers.Tests.csproj b/src/AirGap/StellaOps.AirGap.Policy/StellaOps.AirGap.Policy.Analyzers.Tests/StellaOps.AirGap.Policy.Analyzers.Tests.csproj index f85ac89b4..3cf9f8acb 100644 --- a/src/AirGap/StellaOps.AirGap.Policy/StellaOps.AirGap.Policy.Analyzers.Tests/StellaOps.AirGap.Policy.Analyzers.Tests.csproj +++ b/src/AirGap/StellaOps.AirGap.Policy/StellaOps.AirGap.Policy.Analyzers.Tests/StellaOps.AirGap.Policy.Analyzers.Tests.csproj @@ -12,6 +12,7 @@ + diff --git a/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/Resilience/LdapConnectorResilienceTests.cs b/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/Resilience/LdapConnectorResilienceTests.cs index 898d6bd0d..5656a4d22 100644 --- a/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/Resilience/LdapConnectorResilienceTests.cs +++ b/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/Resilience/LdapConnectorResilienceTests.cs @@ -17,8 +17,6 @@ using StellaOps.Authority.Plugin.Ldap.Credentials; using StellaOps.Authority.Plugin.Ldap.Monitoring; using StellaOps.Authority.Plugin.Ldap.Tests.Fakes; using StellaOps.Authority.Plugin.Ldap.Tests.TestHelpers; -using StellaOps.Authority.Storage.Documents; -using StellaOps.Authority.Storage.InMemory.Stores; using Xunit; using Xunit.Abstractions; @@ -228,7 +226,7 @@ public sealed class LdapConnectorResilienceTests var store = CreateStore(options, new FakeLdapConnectionFactory(connection)); // Act - Func act = () => store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None); + Func act = async () => await store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None); // Assert await act.Should().ThrowAsync(); @@ -250,7 +248,7 @@ public sealed class LdapConnectorResilienceTests var store = CreateStore(options, new FakeLdapConnectionFactory(connection)); // Act - Func act = () => store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None); + Func act = async () => await store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None); // Assert await act.Should().ThrowAsync(); @@ -277,7 +275,7 @@ public sealed class LdapConnectorResilienceTests cts.Cancel(); // Pre-cancel // Act - Func act = () => store.VerifyPasswordAsync("user", "Password1!", cts.Token); + Func act = async () => await store.VerifyPasswordAsync("user", "Password1!", cts.Token); // Assert await act.Should().ThrowAsync(); @@ -375,20 +373,34 @@ public sealed class LdapConnectorResilienceTests private LdapCredentialStore CreateStore(LdapPluginOptions options, ILdapConnectionFactory connectionFactory) { var monitor = new StaticOptionsMonitor(options); - var userStore = new InMemoryUserStore(_timeProvider); - var sessionStore = new InMemorySessionStore(_timeProvider); - var claimsCache = new FakeLdapClaimsCache(); - return new LdapCredentialStore( "corp-ldap", monitor, connectionFactory, - userStore, - sessionStore, + NullLogger.Instance, + new LdapMetrics("corp-ldap"), _auditStore, - claimsCache, - _timeProvider, - NullLoggerFactory.Instance); + _timeProvider); + } + + #endregion + + #region Test Helper Classes + + private sealed class StaticOptionsMonitor : IOptionsMonitor + { + private readonly LdapPluginOptions value; + + public StaticOptionsMonitor(LdapPluginOptions options) + { + value = options ?? throw new ArgumentNullException(nameof(options)); + } + + public LdapPluginOptions CurrentValue => value; + + public LdapPluginOptions Get(string? name) => value; + + public IDisposable? OnChange(Action listener) => null; } #endregion diff --git a/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/Security/LdapConnectorSecurityTests.cs b/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/Security/LdapConnectorSecurityTests.cs index aaaf18354..bbf2fe8ab 100644 --- a/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/Security/LdapConnectorSecurityTests.cs +++ b/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/Security/LdapConnectorSecurityTests.cs @@ -11,11 +11,12 @@ using System.Threading; using System.Threading.Tasks; using FluentAssertions; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using StellaOps.Authority.Plugin.Ldap.Connections; using StellaOps.Authority.Plugin.Ldap.Credentials; +using StellaOps.Authority.Plugin.Ldap.Monitoring; using StellaOps.Authority.Plugin.Ldap.Tests.Fakes; using StellaOps.Authority.Plugin.Ldap.Tests.TestHelpers; -using StellaOps.Authority.Storage.InMemory.Stores; using Xunit; using Xunit.Abstractions; @@ -169,7 +170,7 @@ public sealed class LdapConnectorSecurityTests var store = CreateStore(options, new FakeLdapConnectionFactory(connection)); // Act - Func act = () => store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None); + Func act = async () => await store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None); // Assert await act.Should().ThrowAsync(); @@ -226,8 +227,8 @@ public sealed class LdapConnectorSecurityTests Host = "ldap://ldap.internal", // Non-secure BindDn = "cn=service,dc=example,dc=internal", BindPasswordSecret = "secret", - UserDnFormat = "uid={username},ou=people,dc=example,dc=internal", - TrustStore = new LdapTrustStoreOptions { Mode = LdapTrustStoreMode.None } + UserDnFormat = "uid={username},ou=people,dc=example,dc=internal" + // Note: Using default TrustStore settings - LdapTrustStoreMode only supports System or Bundle } }; @@ -355,20 +356,34 @@ public sealed class LdapConnectorSecurityTests private LdapCredentialStore CreateStore(LdapPluginOptions options, ILdapConnectionFactory connectionFactory) { var monitor = new StaticOptionsMonitor(options); - var userStore = new InMemoryUserStore(_timeProvider); - var sessionStore = new InMemorySessionStore(_timeProvider); - var claimsCache = new FakeLdapClaimsCache(); - return new LdapCredentialStore( "corp-ldap", monitor, connectionFactory, - userStore, - sessionStore, + NullLogger.Instance, + new LdapMetrics("corp-ldap"), _auditStore, - claimsCache, - _timeProvider, - NullLoggerFactory.Instance); + _timeProvider); + } + + #endregion + + #region Test Helper Classes + + private sealed class StaticOptionsMonitor : IOptionsMonitor + { + private readonly LdapPluginOptions value; + + public StaticOptionsMonitor(LdapPluginOptions options) + { + value = options ?? throw new ArgumentNullException(nameof(options)); + } + + public LdapPluginOptions CurrentValue => value; + + public LdapPluginOptions Get(string? name) => value; + + public IDisposable? OnChange(Action listener) => null; } #endregion diff --git a/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/StellaOps.Authority.Plugin.Ldap.Tests.csproj b/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/StellaOps.Authority.Plugin.Ldap.Tests.csproj index bb5d6c0f2..4c68dfb8f 100644 --- a/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/StellaOps.Authority.Plugin.Ldap.Tests.csproj +++ b/src/Authority/StellaOps.Authority/StellaOps.Authority.Plugin.Ldap.Tests/StellaOps.Authority.Plugin.Ldap.Tests.csproj @@ -16,6 +16,8 @@ + + diff --git a/src/Concelier/Directory.Build.props b/src/Concelier/Directory.Build.props index 76bcc4939..ff3eb4df6 100644 --- a/src/Concelier/Directory.Build.props +++ b/src/Concelier/Directory.Build.props @@ -12,8 +12,8 @@ - + @@ -21,7 +21,7 @@ Link="Shared/ConcelierFixtureCollection.cs" Condition="Exists('$(MSBuildThisFileDirectory)StellaOps.Concelier.Tests.Shared\ConcelierFixtureCollection.cs')" /> + Condition="Exists('$(MSBuildThisFileDirectory)..\__Tests\__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj')" /> diff --git a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AdvisoryMergeServiceTests.cs b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AdvisoryMergeServiceTests.cs index 73a69c65d..409cb7006 100644 --- a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AdvisoryMergeServiceTests.cs +++ b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AdvisoryMergeServiceTests.cs @@ -2,9 +2,11 @@ using System.Collections.Concurrent; using System.Collections.Immutable; using System.Linq; using System.Threading.Tasks; +using FluentAssertions; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Time.Testing; using StellaOps.Concelier.Core; +using Xunit; using StellaOps.Concelier.Core.Events; using StellaOps.Concelier.Merge.Services; using StellaOps.Concelier.Models; diff --git a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AdvisoryPrecedenceMergerTests.cs b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AdvisoryPrecedenceMergerTests.cs index f544a4eb8..bbf898703 100644 --- a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AdvisoryPrecedenceMergerTests.cs +++ b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AdvisoryPrecedenceMergerTests.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; +using FluentAssertions; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Time.Testing; using StellaOps.Concelier.Merge.Options; using StellaOps.Concelier.Merge.Services; using StellaOps.Concelier.Models; +using Xunit; namespace StellaOps.Concelier.Merge.Tests; diff --git a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AffectedPackagePrecedenceResolverTests.cs b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AffectedPackagePrecedenceResolverTests.cs index 88c3acd94..8a0fb5a93 100644 --- a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AffectedPackagePrecedenceResolverTests.cs +++ b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AffectedPackagePrecedenceResolverTests.cs @@ -1,6 +1,8 @@ using System; +using FluentAssertions; using StellaOps.Concelier.Merge.Services; using StellaOps.Concelier.Models; +using Xunit; namespace StellaOps.Concelier.Merge.Tests; diff --git a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AliasGraphResolverTests.cs b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AliasGraphResolverTests.cs index 255fc835d..6cdb93bd6 100644 --- a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AliasGraphResolverTests.cs +++ b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/AliasGraphResolverTests.cs @@ -1,8 +1,10 @@ using System; using System.Threading; using System.Threading.Tasks; +using FluentAssertions; using StellaOps.Concelier.Merge.Services; using StellaOps.Concelier.Storage.Aliases; +using Xunit; namespace StellaOps.Concelier.Merge.Tests; diff --git a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/ApkVersionComparerTests.cs b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/ApkVersionComparerTests.cs index c8402f8ed..ffd94dc95 100644 --- a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/ApkVersionComparerTests.cs +++ b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/ApkVersionComparerTests.cs @@ -1,6 +1,8 @@ +using FluentAssertions; using StellaOps.Concelier.Merge.Comparers; using StellaOps.Concelier.Normalization.Distro; using StellaOps.VersionComparison; +using Xunit; namespace StellaOps.Concelier.Merge.Tests; diff --git a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/BackportProvenanceE2ETests.cs b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/BackportProvenanceE2ETests.cs index 7723a7f7b..fdf212f77 100644 --- a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/BackportProvenanceE2ETests.cs +++ b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/BackportProvenanceE2ETests.cs @@ -13,6 +13,7 @@ using StellaOps.Concelier.Merge.Identity; using StellaOps.Concelier.Merge.Services; using StellaOps.Concelier.Models; using StellaOps.Concelier.Storage.MergeEvents; +using Xunit; namespace StellaOps.Concelier.Merge.Tests; diff --git a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/DebianEvrComparerTests.cs b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/DebianEvrComparerTests.cs index 642824375..aaf8c864c 100644 --- a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/DebianEvrComparerTests.cs +++ b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/DebianEvrComparerTests.cs @@ -1,5 +1,7 @@ +using FluentAssertions; using StellaOps.Concelier.Merge.Comparers; using StellaOps.Concelier.Normalization.Distro; +using Xunit; namespace StellaOps.Concelier.Merge.Tests; diff --git a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/NevraComparerTests.cs b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/NevraComparerTests.cs index 8acfa4384..9f40b922c 100644 --- a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/NevraComparerTests.cs +++ b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/NevraComparerTests.cs @@ -1,5 +1,7 @@ +using FluentAssertions; using StellaOps.Concelier.Merge.Comparers; using StellaOps.Concelier.Normalization.Distro; +using Xunit; namespace StellaOps.Concelier.Merge.Tests; diff --git a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/SemanticVersionRangeResolverTests.cs b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/SemanticVersionRangeResolverTests.cs index 5c8b2322f..e70285db9 100644 --- a/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/SemanticVersionRangeResolverTests.cs +++ b/src/Concelier/__Tests/StellaOps.Concelier.Merge.Tests/SemanticVersionRangeResolverTests.cs @@ -1,4 +1,6 @@ +using FluentAssertions; using StellaOps.Concelier.Merge.Comparers; +using Xunit; namespace StellaOps.Concelier.Merge.Tests; diff --git a/src/Directory.Build.props b/src/Directory.Build.props index cf044527a..6e8c6dc48 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -25,9 +25,7 @@ $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\plugins\scanner\analyzers\lang\')) true true - $(MSBuildThisFileDirectory)StellaOps.Concelier.Testing\ - $(MSBuildThisFileDirectory)Concelier\__Libraries\StellaOps.Concelier.Testing\ - $(MSBuildThisFileDirectory)StellaOps.Concelier.Tests.Shared\ + $(MSBuildThisFileDirectory)__Tests\__Libraries\StellaOps.Concelier.Testing\ $(MSBuildThisFileDirectory)Concelier\StellaOps.Concelier.Tests.Shared\ diff --git a/src/StellaOps.sln b/src/StellaOps.sln index 59f00cad0..38fe7f1d8 100644 --- a/src/StellaOps.sln +++ b/src/StellaOps.sln @@ -21,7 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Concelier", "Concelier", "{ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "__Libraries", "__Libraries", "{166ECC12-EF41-266B-D99C-4764D5FBD04E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StellaOps.Concelier.Testing", "Concelier\__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj", "{60BA1521-B6FC-43F6-ABEF-4471A06289E1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StellaOps.Concelier.Testing", "__Tests\__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj", "{60BA1521-B6FC-43F6-ABEF-4471A06289E1}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StellaOps.Concelier.Connector.Common", "Concelier\__Libraries\StellaOps.Concelier.Connector.Common\StellaOps.Concelier.Connector.Common.csproj", "{6F482CF0-1D61-45EF-859C-6242C8BA08F4}" EndProject @@ -151,7 +151,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StellaOps.Router.Transport. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StellaOps.Router.Common", "__Libraries\StellaOps.Router.Common\StellaOps.Router.Common.csproj", "{C3577C67-CC31-4A24-805A-BAA947405103}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StellaOps.Router.Transport.Udp.Tests", "..\tests\StellaOps.Router.Transport.Udp.Tests\StellaOps.Router.Transport.Udp.Tests.csproj", "{3AEDB2CC-5CD9-4B69-9106-56282212E17A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StellaOps.Router.Transport.Udp.Tests", "__Tests\StellaOps.Router.Transport.Udp.Tests\StellaOps.Router.Transport.Udp.Tests.csproj", "{3AEDB2CC-5CD9-4B69-9106-56282212E17A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StellaOps.Router.Transport.RabbitMq", "__Libraries\StellaOps.Router.Transport.RabbitMq\StellaOps.Router.Transport.RabbitMq.csproj", "{2C866CEC-F804-4911-A684-FEB4B53CDA6D}" EndProject diff --git a/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/ConnectionFailureTests.cs b/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/ConnectionFailureTests.cs index 1db69e1bf..549b1b46c 100644 --- a/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/ConnectionFailureTests.cs +++ b/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/ConnectionFailureTests.cs @@ -1,10 +1,16 @@ using System.Net; using System.Net.Sockets; +using System.Threading.Channels; +using FluentAssertions; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using StellaOps.Router.Common.Enums; using StellaOps.Router.Common.Frames; using StellaOps.Router.Common.Models; +using StellaOps.Router.Transport.InMemory; +using StellaOps.Router.Transport.Tls; +using Xunit; namespace StellaOps.Router.Transport.Tcp.Tests; @@ -122,13 +128,21 @@ public sealed class ConnectionFailureTests : IDisposable { Host = "127.0.0.1", Port = _port, - ConnectionTimeout = TimeSpan.FromSeconds(1) + ConnectTimeout = TimeSpan.FromSeconds(1) }; - var client = new TcpTransportClient(options, _clientLogger); + var client = new TcpTransportClient(Options.Create(options), _clientLogger); + var instance = new InstanceDescriptor + { + InstanceId = Guid.NewGuid().ToString("N"), + ServiceName = "test-service", + Version = "1.0.0", + Region = "local" + }; + var endpoints = Array.Empty(); // Act & Assert - var action = async () => await client.ConnectAsync(default); + var action = async () => await client.ConnectAsync(instance, endpoints, default); await action.Should().ThrowAsync(); await client.DisposeAsync(); @@ -141,13 +155,21 @@ public sealed class ConnectionFailureTests : IDisposable { Host = "invalid.hostname.that.does.not.exist.local", Port = 12345, - ConnectionTimeout = TimeSpan.FromSeconds(2) + ConnectTimeout = TimeSpan.FromSeconds(2) }; - var client = new TcpTransportClient(options, _clientLogger); + var client = new TcpTransportClient(Options.Create(options), _clientLogger); + var instance = new InstanceDescriptor + { + InstanceId = Guid.NewGuid().ToString("N"), + ServiceName = "test-service", + Version = "1.0.0", + Region = "local" + }; + var endpoints = Array.Empty(); // Act & Assert - var action = async () => await client.ConnectAsync(default); + var action = async () => await client.ConnectAsync(instance, endpoints, default); await action.Should().ThrowAsync(); await client.DisposeAsync(); @@ -261,17 +283,25 @@ public sealed class ConnectionFailureTests : IDisposable { Host = "10.255.255.1", // Non-routable address to force timeout Port = 12345, - ConnectionTimeout = TimeSpan.FromMilliseconds(500) + ConnectTimeout = TimeSpan.FromMilliseconds(500) }; - var client = new TcpTransportClient(options, _clientLogger); + var client = new TcpTransportClient(Options.Create(options), _clientLogger); + var instance = new InstanceDescriptor + { + InstanceId = Guid.NewGuid().ToString("N"), + ServiceName = "test-service", + Version = "1.0.0", + Region = "local" + }; + var endpoints = Array.Empty(); using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2)); // Act var sw = System.Diagnostics.Stopwatch.StartNew(); try { - await client.ConnectAsync(cts.Token); + await client.ConnectAsync(instance, endpoints, cts.Token); } catch { @@ -296,13 +326,21 @@ public sealed class ConnectionFailureTests : IDisposable { Host = "10.255.255.1", // Non-routable to force long connection attempt Port = 12345, - ConnectionTimeout = TimeSpan.FromSeconds(30) + ConnectTimeout = TimeSpan.FromSeconds(30) }; - var client = new TcpTransportClient(options, _clientLogger); - + var client = new TcpTransportClient(Options.Create(options), _clientLogger); + var instance = new InstanceDescriptor + { + InstanceId = Guid.NewGuid().ToString("N"), + ServiceName = "test-service", + Version = "1.0.0", + Region = "local" + }; + var endpoints = Array.Empty(); + // Start connection in background - var connectTask = client.ConnectAsync(default); + var connectTask = client.ConnectAsync(instance, endpoints, default); // Give it a moment to start await Task.Delay(100); @@ -400,7 +438,7 @@ public sealed class ConnectionFailureTests : IDisposable Port = _port }; - var client = new TcpTransportClient(options, _clientLogger); + var client = new TcpTransportClient(Options.Create(options), _clientLogger); // Before ConnectAsync, client should not be connected // The internal state should be "not connected" @@ -442,12 +480,12 @@ public sealed class TlsConnectionFailureTests Port = 443, MaxReconnectAttempts = 3, MaxReconnectBackoff = TimeSpan.FromSeconds(15), - SslProtocols = System.Security.Authentication.SslProtocols.Tls13 + EnabledProtocols = System.Security.Authentication.SslProtocols.Tls13 }; options.MaxReconnectAttempts.Should().Be(3); options.MaxReconnectBackoff.Should().Be(TimeSpan.FromSeconds(15)); - options.SslProtocols.Should().Be(System.Security.Authentication.SslProtocols.Tls13); + options.EnabledProtocols.Should().Be(System.Security.Authentication.SslProtocols.Tls13); } #endregion @@ -464,8 +502,8 @@ public sealed class TlsConnectionFailureTests { Host = "self-signed.badssl.com", Port = 443, - TargetHost = "self-signed.badssl.com", - ConnectionTimeout = TimeSpan.FromSeconds(5) + ExpectedServerHostname = "self-signed.badssl.com", + ConnectTimeout = TimeSpan.FromSeconds(5) }; // The connection should fail due to certificate validation @@ -530,13 +568,14 @@ public sealed class InMemoryConnectionFailureTests await channel.ToMicroservice.Reader.ReadAsync(); Assert.Fail("Should have thrown"); } + catch (ChannelClosedException) + { + // ChannelClosedException inherits from InvalidOperationException, so catch it first + // When channel is completed with an error, ReadAsync throws ChannelClosedException + } catch (InvalidOperationException ex) { ex.Message.Should().Be("Simulated failure"); } - catch (ChannelClosedException) - { - // Also acceptable - } } } diff --git a/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/StellaOps.Router.Transport.Tcp.Tests.csproj b/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/StellaOps.Router.Transport.Tcp.Tests.csproj index 4267c00a7..321290c20 100644 --- a/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/StellaOps.Router.Transport.Tcp.Tests.csproj +++ b/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/StellaOps.Router.Transport.Tcp.Tests.csproj @@ -22,6 +22,12 @@ + + + + + + diff --git a/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/TcpTransportComplianceTests.cs b/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/TcpTransportComplianceTests.cs index 6169b1b60..132fa5aec 100644 --- a/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/TcpTransportComplianceTests.cs +++ b/src/__Libraries/__Tests/StellaOps.Router.Transport.Tcp.Tests/TcpTransportComplianceTests.cs @@ -52,7 +52,7 @@ public sealed class TcpTransportComplianceTests restored.Method.Should().Be(request.Method); restored.Path.Should().Be(request.Path); restored.Headers.Should().BeEquivalentTo(request.Headers); - restored.Payload.ToArray().Should().BeEquivalentTo(request.Payload); + restored.Payload.ToArray().Should().Equal(request.Payload.ToArray()); restored.TimeoutSeconds.Should().Be(request.TimeoutSeconds); restored.SupportsStreaming.Should().Be(request.SupportsStreaming); } @@ -89,7 +89,7 @@ public sealed class TcpTransportComplianceTests restored!.RequestId.Should().Be(response.RequestId); restored.StatusCode.Should().Be(response.StatusCode); restored.Headers.Should().BeEquivalentTo(response.Headers); - restored.Payload.ToArray().Should().BeEquivalentTo(response.Payload); + restored.Payload.ToArray().Should().Equal(response.Payload.ToArray()); restored.HasMoreChunks.Should().Be(response.HasMoreChunks); } diff --git a/src/__Libraries/__Tests/StellaOps.Router.Transport.Tls.Tests/StellaOps.Router.Transport.Tls.Tests.csproj b/src/__Libraries/__Tests/StellaOps.Router.Transport.Tls.Tests/StellaOps.Router.Transport.Tls.Tests.csproj index 8fa84464f..34ee798cc 100644 --- a/src/__Libraries/__Tests/StellaOps.Router.Transport.Tls.Tests/StellaOps.Router.Transport.Tls.Tests.csproj +++ b/src/__Libraries/__Tests/StellaOps.Router.Transport.Tls.Tests/StellaOps.Router.Transport.Tls.Tests.csproj @@ -23,4 +23,8 @@ + + + + diff --git a/src/__Libraries/__Tests/StellaOps.Router.Transport.Tls.Tests/TlsTransportComplianceTests.cs b/src/__Libraries/__Tests/StellaOps.Router.Transport.Tls.Tests/TlsTransportComplianceTests.cs index 8d2d9f22f..ec8f79a19 100644 --- a/src/__Libraries/__Tests/StellaOps.Router.Transport.Tls.Tests/TlsTransportComplianceTests.cs +++ b/src/__Libraries/__Tests/StellaOps.Router.Transport.Tls.Tests/TlsTransportComplianceTests.cs @@ -4,9 +4,11 @@ using System.Security.Authentication; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text; +using FluentAssertions; using StellaOps.Router.Common.Enums; using StellaOps.Router.Common.Frames; using StellaOps.Router.Common.Models; +using Xunit; namespace StellaOps.Router.Transport.Tls.Tests; diff --git a/src/__Tests/StellaOps.Router.Transport.Udp.Tests/StellaOps.Router.Transport.Udp.Tests.csproj b/src/__Tests/StellaOps.Router.Transport.Udp.Tests/StellaOps.Router.Transport.Udp.Tests.csproj index e5214f38a..285c5a410 100644 --- a/src/__Tests/StellaOps.Router.Transport.Udp.Tests/StellaOps.Router.Transport.Udp.Tests.csproj +++ b/src/__Tests/StellaOps.Router.Transport.Udp.Tests/StellaOps.Router.Transport.Udp.Tests.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/__Tests/__Libraries/StellaOps.Concelier.Testing/StellaOps.Concelier.Testing.csproj b/src/__Tests/__Libraries/StellaOps.Concelier.Testing/StellaOps.Concelier.Testing.csproj index 0956c74fc..6a38f7c9a 100644 --- a/src/__Tests/__Libraries/StellaOps.Concelier.Testing/StellaOps.Concelier.Testing.csproj +++ b/src/__Tests/__Libraries/StellaOps.Concelier.Testing/StellaOps.Concelier.Testing.csproj @@ -13,8 +13,8 @@ - - - + + +