consolidate the tests locations
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.11.0" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.11.0" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="3.11.0" PrivateAssets="all" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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<Task> act = () => store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None);
|
||||
Func<Task> act = async () => await store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await act.Should().ThrowAsync<TimeoutException>();
|
||||
@@ -250,7 +248,7 @@ public sealed class LdapConnectorResilienceTests
|
||||
var store = CreateStore(options, new FakeLdapConnectionFactory(connection));
|
||||
|
||||
// Act
|
||||
Func<Task> act = () => store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None);
|
||||
Func<Task> act = async () => await store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await act.Should().ThrowAsync<InvalidOperationException>();
|
||||
@@ -277,7 +275,7 @@ public sealed class LdapConnectorResilienceTests
|
||||
cts.Cancel(); // Pre-cancel
|
||||
|
||||
// Act
|
||||
Func<Task> act = () => store.VerifyPasswordAsync("user", "Password1!", cts.Token);
|
||||
Func<Task> act = async () => await store.VerifyPasswordAsync("user", "Password1!", cts.Token);
|
||||
|
||||
// Assert
|
||||
await act.Should().ThrowAsync<OperationCanceledException>();
|
||||
@@ -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<LdapCredentialStore>.Instance,
|
||||
new LdapMetrics("corp-ldap"),
|
||||
_auditStore,
|
||||
claimsCache,
|
||||
_timeProvider,
|
||||
NullLoggerFactory.Instance);
|
||||
_timeProvider);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Test Helper Classes
|
||||
|
||||
private sealed class StaticOptionsMonitor : IOptionsMonitor<LdapPluginOptions>
|
||||
{
|
||||
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<LdapPluginOptions, string?> listener) => null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -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<Task> act = () => store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None);
|
||||
Func<Task> act = async () => await store.VerifyPasswordAsync("user", "Password1!", CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await act.Should().ThrowAsync<InvalidOperationException>();
|
||||
@@ -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<LdapCredentialStore>.Instance,
|
||||
new LdapMetrics("corp-ldap"),
|
||||
_auditStore,
|
||||
claimsCache,
|
||||
_timeProvider,
|
||||
NullLoggerFactory.Instance);
|
||||
_timeProvider);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Test Helper Classes
|
||||
|
||||
private sealed class StaticOptionsMonitor : IOptionsMonitor<LdapPluginOptions>
|
||||
{
|
||||
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<LdapPluginOptions, string?> listener) => null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="10.0.0" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj"
|
||||
Condition="Exists('$(MSBuildThisFileDirectory)__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj')" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\__Tests\__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj"
|
||||
Condition="Exists('$(MSBuildThisFileDirectory)..\__Tests\__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj')" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)StellaOps.Concelier.Tests.Shared\AssemblyInfo.cs"
|
||||
Link="Shared/AssemblyInfo.cs"
|
||||
Condition="Exists('$(MSBuildThisFileDirectory)StellaOps.Concelier.Tests.Shared\AssemblyInfo.cs')" />
|
||||
@@ -21,7 +21,7 @@
|
||||
Link="Shared/ConcelierFixtureCollection.cs"
|
||||
Condition="Exists('$(MSBuildThisFileDirectory)StellaOps.Concelier.Tests.Shared\ConcelierFixtureCollection.cs')" />
|
||||
<Using Include="StellaOps.Concelier.Testing"
|
||||
Condition="Exists('$(MSBuildThisFileDirectory)__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj')" />
|
||||
Condition="Exists('$(MSBuildThisFileDirectory)..\__Tests\__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj')" />
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using StellaOps.Concelier.Merge.Services;
|
||||
using StellaOps.Concelier.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Concelier.Merge.Tests;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using FluentAssertions;
|
||||
using StellaOps.Concelier.Merge.Comparers;
|
||||
using StellaOps.Concelier.Normalization.Distro;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Concelier.Merge.Tests;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using FluentAssertions;
|
||||
using StellaOps.Concelier.Merge.Comparers;
|
||||
using StellaOps.Concelier.Normalization.Distro;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Concelier.Merge.Tests;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using FluentAssertions;
|
||||
using StellaOps.Concelier.Merge.Comparers;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Concelier.Merge.Tests;
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
<ScannerLangAnalyzerPluginOutputRoot Condition="'$(ScannerLangAnalyzerPluginOutputRoot)' == ''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\plugins\scanner\analyzers\lang\'))</ScannerLangAnalyzerPluginOutputRoot>
|
||||
<IsScannerLangAnalyzerPlugin Condition="'$(IsScannerLangAnalyzerPlugin)' == '' and $([System.String]::Copy('$(MSBuildProjectName)').StartsWith('StellaOps.Scanner.Analyzers.Lang.'))">true</IsScannerLangAnalyzerPlugin>
|
||||
<UseConcelierTestInfra Condition="'$(UseConcelierTestInfra)' == ''">true</UseConcelierTestInfra>
|
||||
<ConcelierTestingPath Condition="'$(ConcelierTestingPath)' == '' and Exists('$(MSBuildThisFileDirectory)StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj')">$(MSBuildThisFileDirectory)StellaOps.Concelier.Testing\</ConcelierTestingPath>
|
||||
<ConcelierTestingPath Condition="'$(ConcelierTestingPath)' == '' and Exists('$(MSBuildThisFileDirectory)Concelier\__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj')">$(MSBuildThisFileDirectory)Concelier\__Libraries\StellaOps.Concelier.Testing\</ConcelierTestingPath>
|
||||
<ConcelierSharedTestsPath Condition="'$(ConcelierSharedTestsPath)' == '' and Exists('$(MSBuildThisFileDirectory)StellaOps.Concelier.Tests.Shared\AssemblyInfo.cs')">$(MSBuildThisFileDirectory)StellaOps.Concelier.Tests.Shared\</ConcelierSharedTestsPath>
|
||||
<ConcelierTestingPath Condition="'$(ConcelierTestingPath)' == '' and Exists('$(MSBuildThisFileDirectory)__Tests\__Libraries\StellaOps.Concelier.Testing\StellaOps.Concelier.Testing.csproj')">$(MSBuildThisFileDirectory)__Tests\__Libraries\StellaOps.Concelier.Testing\</ConcelierTestingPath>
|
||||
<ConcelierSharedTestsPath Condition="'$(ConcelierSharedTestsPath)' == '' and Exists('$(MSBuildThisFileDirectory)Concelier\StellaOps.Concelier.Tests.Shared\AssemblyInfo.cs')">$(MSBuildThisFileDirectory)Concelier\StellaOps.Concelier.Tests.Shared\</ConcelierSharedTestsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<EndpointDescriptor>();
|
||||
|
||||
// Act & Assert
|
||||
var action = async () => await client.ConnectAsync(default);
|
||||
var action = async () => await client.ConnectAsync(instance, endpoints, default);
|
||||
await action.Should().ThrowAsync<Exception>();
|
||||
|
||||
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<EndpointDescriptor>();
|
||||
|
||||
// Act & Assert
|
||||
var action = async () => await client.ConnectAsync(default);
|
||||
var action = async () => await client.ConnectAsync(instance, endpoints, default);
|
||||
await action.Should().ThrowAsync<Exception>();
|
||||
|
||||
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<EndpointDescriptor>();
|
||||
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<EndpointDescriptor>();
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\StellaOps.Router.Transport.Tcp\StellaOps.Router.Transport.Tcp.csproj" />
|
||||
<ProjectReference Include="..\..\StellaOps.Router.Transport.Tls\StellaOps.Router.Transport.Tls.csproj" />
|
||||
<ProjectReference Include="..\..\StellaOps.Router.Transport.InMemory\StellaOps.Router.Transport.InMemory.csproj" />
|
||||
<ProjectReference Include="..\..\StellaOps.Router.Common\StellaOps.Router.Common.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
<Using Include="FluentAssertions" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,4 +23,8 @@
|
||||
<ProjectReference Include="..\..\StellaOps.Router.Transport.Tls\StellaOps.Router.Transport.Tls.csproj" />
|
||||
<ProjectReference Include="..\..\StellaOps.Router.Common\StellaOps.Router.Common.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
<Using Include="FluentAssertions" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\__Libraries\StellaOps.Router.Transport.Udp\StellaOps.Router.Transport.Udp.csproj" />
|
||||
<ProjectReference Include="../../__Libraries/StellaOps.Router.Transport.Udp/StellaOps.Router.Transport.Udp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../StellaOps.Concelier.Connector.Common/StellaOps.Concelier.Connector.Common.csproj" />
|
||||
<ProjectReference Include="../StellaOps.Concelier.Storage.Postgres/StellaOps.Concelier.Storage.Postgres.csproj" />
|
||||
<ProjectReference Include="../../../__Tests/__Libraries/StellaOps.Infrastructure.Postgres.Testing/StellaOps.Infrastructure.Postgres.Testing.csproj" />
|
||||
<ProjectReference Include="../../../Concelier/__Libraries/StellaOps.Concelier.Connector.Common/StellaOps.Concelier.Connector.Common.csproj" />
|
||||
<ProjectReference Include="../../../Concelier/__Libraries/StellaOps.Concelier.Storage.Postgres/StellaOps.Concelier.Storage.Postgres.csproj" />
|
||||
<ProjectReference Include="../StellaOps.Infrastructure.Postgres.Testing/StellaOps.Infrastructure.Postgres.Testing.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user