Add unit tests for Router configuration and transport layers
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled

- Implemented tests for RouterConfig, RoutingOptions, StaticInstanceConfig, and RouterConfigOptions to ensure default values are set correctly.
- Added tests for RouterConfigProvider to validate configurations and ensure defaults are returned when no file is specified.
- Created tests for ConfigValidationResult to check success and error scenarios.
- Developed tests for ServiceCollectionExtensions to verify service registration for RouterConfig.
- Introduced UdpTransportTests to validate serialization, connection, request-response, and error handling in UDP transport.
- Added scripts for signing authority gaps and hashing DevPortal SDK snippets.
This commit is contained in:
StellaOps Bot
2025-12-05 08:01:47 +02:00
parent 635c70e828
commit 6a299d231f
294 changed files with 28434 additions and 1329 deletions

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Gateway\StellaOps.Gateway.WebService\StellaOps.Gateway.WebService.csproj" />
<ProjectReference Include="..\..\..\..\src\__Libraries\StellaOps.Router.Transport.InMemory\StellaOps.Router.Transport.InMemory.csproj" />
<ProjectReference Include="..\..\..\..\src\__Libraries\StellaOps.Router.Config\StellaOps.Router.Config.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="router.yaml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,53 @@
using StellaOps.Gateway.WebService;
using StellaOps.Gateway.WebService.Authorization;
using StellaOps.Gateway.WebService.Middleware;
using StellaOps.Router.Config;
using StellaOps.Router.Transport.InMemory;
var builder = WebApplication.CreateBuilder(args);
// Router configuration from YAML
builder.Services.AddRouterConfig(options =>
{
options.ConfigPath = "router.yaml";
options.EnableHotReload = true;
});
// Gateway routing services
builder.Services.AddGatewayRouting(builder.Configuration);
// In-memory transport for demo (can switch to TCP/TLS for production)
builder.Services.AddInMemoryTransport();
// Authority integration (no-op for demo)
builder.Services.AddNoOpAuthorityIntegration();
var app = builder.Build();
// Middleware pipeline
app.UseForwardedHeaders();
app.UseMiddleware<PayloadLimitsMiddleware>();
app.UseAuthentication();
app.UseMiddleware<EndpointResolutionMiddleware>();
app.UseClaimsAuthorization();
app.UseMiddleware<RoutingDecisionMiddleware>();
// Simple health endpoint
app.MapGet("/health", () => Results.Ok(new { status = "healthy" }));
// Catch-all for routed requests
app.MapFallback(async context =>
{
// The RoutingDecisionMiddleware would have dispatched the request
// If we reach here, no route was found
context.Response.StatusCode = 404;
await context.Response.WriteAsJsonAsync(new { error = "Not Found", message = "No matching endpoint" });
});
app.Run();
// Partial class for WebApplicationFactory integration testing
namespace Examples.Gateway
{
public partial class Program { }
}

View File

@@ -0,0 +1,13 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"GatewayNode": {
"Region": "demo",
"NodeId": "gw-demo-01"
}
}

View File

@@ -0,0 +1,50 @@
# Router Configuration for Example Gateway
# This file configures how the gateway routes requests to microservices
gateway:
nodeId: "gw-demo-01"
region: "demo"
listenPort: 8080
# Payload limits
payloadLimits:
maxRequestBodyBytes: 10485760 # 10 MB
maxStreamingChunkBytes: 65536 # 64 KB
# Health monitoring
healthMonitoring:
staleThreshold: "00:00:30"
checkInterval: "00:00:05"
# Transport configuration
transports:
# In-memory transport (for demo)
inMemory:
enabled: true
# TCP transport (production)
# tcp:
# enabled: true
# port: 5100
# backlog: 100
# TLS transport (production with encryption)
# tls:
# enabled: true
# port: 5101
# certificatePath: "certs/gateway.pfx"
# certificatePassword: "demo"
# Routing configuration
routing:
# Default routing algorithm
algorithm: "round-robin"
# Region affinity (prefer local microservices)
regionAffinity: true
affinityWeight: 0.8
# Logging
logging:
level: "Information"
requestLogging: true