documentation cleanse, sprints work and planning. remaining non EF DAL migration to EF
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
@@ -13,6 +14,7 @@ using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Npgsql;
|
||||
using StellaOps.Auth.Abstractions;
|
||||
using StellaOps.Infrastructure.Postgres.Testing;
|
||||
using StellaOps.Scanner.Reachability.Slices;
|
||||
using StellaOps.Scanner.Storage;
|
||||
@@ -27,6 +29,14 @@ namespace StellaOps.Scanner.WebService.Tests;
|
||||
|
||||
public sealed class ScannerApplicationFactory : WebApplicationFactory<ServiceStatus>, IAsyncLifetime, IAsyncDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Default tenant identifier injected into every test client via the
|
||||
/// <c>X-StellaOps-Tenant</c> header so that <c>RequireTenant()</c> endpoint filters
|
||||
/// resolve a valid tenant context without requiring per-request configuration.
|
||||
/// Tests that need a specific tenant can override this header per request.
|
||||
/// </summary>
|
||||
public const string DefaultTestTenant = "default";
|
||||
|
||||
private readonly bool skipPostgres;
|
||||
private readonly Dictionary<string, string?> configuration = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
@@ -151,6 +161,32 @@ public sealed class ScannerApplicationFactory : WebApplicationFactory<ServiceSta
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an HTTP client with the default test tenant header pre-configured.
|
||||
/// All endpoints under <c>MapGroup(...).RequireTenant()</c> require a resolved tenant
|
||||
/// context; this header satisfies that requirement for generic test scenarios.
|
||||
/// Tests that need a different tenant can override the header per request using
|
||||
/// <c>request.Headers.TryAddWithoutValidation(StellaOpsHttpHeaderNames.Tenant, "other-tenant")</c>.
|
||||
/// </summary>
|
||||
public new HttpClient CreateClient()
|
||||
{
|
||||
var client = base.CreateClient();
|
||||
client.DefaultRequestHeaders.TryAddWithoutValidation(StellaOpsHttpHeaderNames.Tenant, DefaultTestTenant);
|
||||
return client;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an HTTP client with the given options and the default test tenant header pre-configured.
|
||||
/// This override ensures that callers using <c>CreateClient(options)</c> also receive the tenant
|
||||
/// header, which is required by <c>RequireTenant()</c> endpoint filters.
|
||||
/// </summary>
|
||||
public new HttpClient CreateClient(WebApplicationFactoryClientOptions options)
|
||||
{
|
||||
var client = base.CreateClient(options);
|
||||
client.DefaultRequestHeaders.TryAddWithoutValidation(StellaOpsHttpHeaderNames.Tenant, DefaultTestTenant);
|
||||
return client;
|
||||
}
|
||||
|
||||
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
||||
{
|
||||
if (!initialized)
|
||||
|
||||
Reference in New Issue
Block a user