audit notes work completed, test fixes work (95% done), new sprints, new data sources setup and configuration

This commit is contained in:
master
2026-01-14 10:48:00 +02:00
parent d7be6ba34b
commit 95d5898650
379 changed files with 40695 additions and 19041 deletions

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<UseXunitV3>true</UseXunitV3>
</PropertyGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Moq" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\__Libraries\StellaOps.Router.AspNet\StellaOps.Router.AspNet.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,223 @@
using StellaOps.Microservice.AspNetCore;
using StellaOps.Router.AspNet;
using StellaOps.Router.Common.Enums;
using Xunit;
namespace StellaOps.Router.AspNet.Tests;
/// <summary>
/// Tests for StellaRouterOptions.
/// </summary>
public sealed class StellaRouterOptionsTests
{
[Fact]
public void StellaRouterOptions_RequiredProperties_MustBeSet()
{
var options = new StellaRouterOptions
{
ServiceName = "test-service",
Version = "1.0.0",
Region = "us-east-1"
};
Assert.Equal("test-service", options.ServiceName);
Assert.Equal("1.0.0", options.Version);
Assert.Equal("us-east-1", options.Region);
}
[Fact]
public void StellaRouterOptions_DefaultValues_AreCorrect()
{
var options = new StellaRouterOptions
{
ServiceName = "test",
Version = "1.0.0",
Region = "us-west-2"
};
Assert.True(options.EnableAspNetBridge);
Assert.True(options.EnableStellaEndpoints);
Assert.Equal(DispatchStrategy.AspNetFirst, options.DispatchStrategy);
Assert.Equal(AuthorizationMappingStrategy.Hybrid, options.AuthorizationMapping);
Assert.Equal(MissingAuthorizationBehavior.RequireExplicit, options.OnMissingAuthorization);
Assert.Equal(TimeSpan.FromSeconds(30), options.DefaultTimeout);
Assert.Equal(TimeSpan.FromSeconds(10), options.HeartbeatInterval);
}
[Fact]
public void StellaRouterOptions_ExcludedPaths_HasDefaults()
{
var options = new StellaRouterOptions
{
ServiceName = "test",
Version = "1.0.0",
Region = "eu-west-1"
};
Assert.Contains("/health", options.ExcludedPathPrefixes);
Assert.Contains("/metrics", options.ExcludedPathPrefixes);
Assert.Contains("/swagger", options.ExcludedPathPrefixes);
Assert.Contains("/openapi", options.ExcludedPathPrefixes);
}
[Fact]
public void StellaRouterOptions_InstanceId_IsOptional()
{
var options = new StellaRouterOptions
{
ServiceName = "test",
Version = "1.0.0",
Region = "ap-northeast-1"
};
Assert.Null(options.InstanceId);
options.InstanceId = "instance-001";
Assert.Equal("instance-001", options.InstanceId);
}
[Fact]
public void StellaRouterOptions_Gateways_InitiallyEmpty()
{
var options = new StellaRouterOptions
{
ServiceName = "test",
Version = "1.0.0",
Region = "us-east-1"
};
Assert.Empty(options.Gateways);
}
[Fact]
public void StellaRouterOptions_WithGateways_ContainsConfig()
{
var options = new StellaRouterOptions
{
ServiceName = "test",
Version = "1.0.0",
Region = "us-east-1",
Gateways =
{
new RouterGatewayConfig
{
Host = "gateway1.example.com",
Port = 9100,
TransportType = TransportType.Tcp
},
new RouterGatewayConfig
{
Host = "gateway2.example.com",
Port = 9101,
TransportType = TransportType.Certificate,
UseTls = true,
CertificatePath = "/certs/client.pem"
}
}
};
Assert.Equal(2, options.Gateways.Count);
Assert.Equal("gateway1.example.com", options.Gateways[0].Host);
Assert.True(options.Gateways[1].UseTls);
}
[Fact]
public void StellaRouterOptions_ReconnectBackoff_HasDefaults()
{
var options = new StellaRouterOptions
{
ServiceName = "test",
Version = "1.0.0",
Region = "us-east-1"
};
Assert.Equal(TimeSpan.FromSeconds(1), options.ReconnectBackoffInitial);
Assert.Equal(TimeSpan.FromSeconds(30), options.ReconnectBackoffMax);
}
[Fact]
public void StellaRouterOptions_YamlConfigPath_IsOptional()
{
var options = new StellaRouterOptions
{
ServiceName = "test",
Version = "1.0.0",
Region = "us-east-1"
};
Assert.Null(options.YamlConfigPath);
options.YamlConfigPath = "/etc/stella/microservice.yaml";
Assert.Equal("/etc/stella/microservice.yaml", options.YamlConfigPath);
}
[Theory]
[InlineData(DispatchStrategy.AspNetFirst)]
[InlineData(DispatchStrategy.StellaFirst)]
[InlineData(DispatchStrategy.AspNetOnly)]
[InlineData(DispatchStrategy.StellaOnly)]
public void StellaRouterOptions_DispatchStrategy_AllValues_AreValid(DispatchStrategy strategy)
{
var options = new StellaRouterOptions
{
ServiceName = "test",
Version = "1.0.0",
Region = "us-east-1",
DispatchStrategy = strategy
};
Assert.Equal(strategy, options.DispatchStrategy);
}
}
/// <summary>
/// Tests for RouterGatewayConfig.
/// </summary>
public sealed class RouterGatewayConfigTests
{
[Fact]
public void RouterGatewayConfig_DefaultValues_AreCorrect()
{
var config = new RouterGatewayConfig();
Assert.Equal("localhost", config.Host);
Assert.Equal(9100, config.Port);
Assert.Equal(TransportType.InMemory, config.TransportType);
Assert.False(config.UseTls);
Assert.Null(config.CertificatePath);
}
[Fact]
public void RouterGatewayConfig_CanBeCustomized()
{
var config = new RouterGatewayConfig
{
Host = "router.example.com",
Port = 443,
TransportType = TransportType.Certificate,
UseTls = true,
CertificatePath = "/etc/ssl/certs/client.pem"
};
Assert.Equal("router.example.com", config.Host);
Assert.Equal(443, config.Port);
Assert.Equal(TransportType.Certificate, config.TransportType);
Assert.True(config.UseTls);
Assert.Equal("/etc/ssl/certs/client.pem", config.CertificatePath);
}
[Theory]
[InlineData(TransportType.InMemory)]
[InlineData(TransportType.Tcp)]
[InlineData(TransportType.Certificate)]
[InlineData(TransportType.Messaging)]
public void RouterGatewayConfig_TransportType_AllValues_AreValid(TransportType transport)
{
var config = new RouterGatewayConfig
{
TransportType = transport
};
Assert.Equal(transport, config.TransportType);
}
}

View File

@@ -0,0 +1,7 @@
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"diagnosticMessages": true,
"parallelizeAssembly": true,
"parallelizeTestCollections": true,
"maxParallelThreads": -1
}