Implements tests for commit 45f9aa3bd5

This commit is contained in:
BinaryAlley committed 2026-10-28 22:34:32 +02:00
1 parent d61a114d80
commit aeefa9487e
44 files changed
+6929 -18

No files matched your search

@@ -1,15 +1,11 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Fixtures.Common.Api;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.SecurityTests.Common.Setup;
@@ -27,6 +23,11 @@ public class LuminaWebFactory : WebApplicationFactory<Program>, IDisposable
/// </summary>
public StubApiHttpClient ApiClientStub { get; } = new();
/// <summary>
/// Gets the stub used in place of the remote streaming API client.
/// </summary>
public StubStreamingApiHttpClient StreamingApiClientStub { get; } = new();
/// <summary>
/// Initializes a new instance of the <see cref="LuminaWebFactory"/> class.
/// </summary>
@@ -42,7 +43,7 @@ public class LuminaWebFactory : WebApplicationFactory<Program>, IDisposable
{
builder.ConfigureAppConfiguration((context, config) =>
{
// provide the application configuration values that the Web app validates on startup
// Provide the application configuration values that the Web app validates on startup.
config.AddInMemoryCollection(initialData: new Dictionary<string, string?>
{
["EncryptionSettings:SecretKey"] = TEST_ENCRYPTION_KEY,
@@ -53,11 +54,17 @@ public class LuminaWebFactory : WebApplicationFactory<Program>, IDisposable
});
builder.ConfigureServices(services =>
{
// remove the typed HTTP client registration, so that the stub can take its place
ServiceDescriptor[] apiClientDescriptors = services.Where(serviceDescriptor => serviceDescriptor.ServiceType == typeof(IApiHttpClient)).ToArray();
// Remove the typed HTTP client registration, so that the stub can take its place.
ServiceDescriptor[] apiClientDescriptors = [.. services.Where(serviceDescriptor => serviceDescriptor.ServiceType == typeof(IApiHttpClient))];
foreach (ServiceDescriptor descriptor in apiClientDescriptors)
services.Remove(descriptor);
services.AddSingleton<IApiHttpClient>(ApiClientStub);
// Remove the typed streaming HTTP client registration, so that the streaming stub can take its place.
ServiceDescriptor[] streamingApiClientDescriptors = [.. services.Where(serviceDescriptor => serviceDescriptor.ServiceType == typeof(IStreamingApiHttpClient))];
foreach (ServiceDescriptor descriptor in streamingApiClientDescriptors)
services.Remove(descriptor);
services.AddSingleton<IStreamingApiHttpClient>(StreamingApiClientStub);
});
}
}