Centralizes and standardizes test fixtures.

This commit is contained in:
BinaryAlley committed 2026-08-15 02:58:17 -07:00
1 parent dfc513da4f
commit b648e2f054
294 files changed
+3807 -4437

No files matched your search

@@ -1,41 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Infrastructure.Common.Models.DTO.Configuration;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Infrastructure.UnitTests.Core.Authentication.Fixtures;
/// <summary>
/// Fixture class for JWT token generation tests.
/// </summary>
[ExcludeFromCodeCoverage]
public class JwtTokenGeneratorFixture
{
/// <summary>
/// Creates a valid JWT settings model for testing.
/// </summary>
/// <returns>The created settings model.</returns>
public static JwtSettingsDto CreateJwtSettings()
{
return new Faker<JwtSettingsDto>()
.CustomInstantiator(f => new JwtSettingsDto
{
SecretKey = "this-is-a-very-long-secret-key-for-testing-jwt-tokens",
ExpiryMinutes = 30,
Issuer = "test-issuer",
Audience = "test-audience"
})
.Generate();
}
/// <summary>
/// Creates test user credentials.
/// </summary>
/// <returns>A tuple containing the user ID and username.</returns>
public static (string Id, string Username) CreateUserCredentials()
{
return (Guid.NewGuid().ToString(), new Faker().Person.UserName);
}
}
@@ -1,37 +0,0 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Infrastructure.UnitTests.Core.Authentication.Fixtures;
/// <summary>
/// Fixture class for QR code generation tests.
/// </summary>
[ExcludeFromCodeCoverage]
public class QRCodeGeneratorFixture
{
/// <summary>
/// Creates test data for QR code generation.
/// </summary>
/// <returns>A tuple containing username and secret bytes.</returns>
public static (string Username, byte[] Secret) CreateQrCodeTestData()
{
string username = new Faker().Person.UserName;
byte[] secret = new byte[20]; // Standard TOTP secret length
new Random().NextBytes(secret);
return (username, secret);
}
/// <summary>
/// Gets the expected otpauth URI format for validation.
/// </summary>
/// <param name="username">The username to use in the URI.</param>
/// <param name="base32Secret">The Base32 encoded secret.</param>
/// <returns>The formatted otpauth URI.</returns>
public static string GetExpectedOtpauthUri(string username, string base32Secret)
{
return $"otpauth://totp/Lumina:{Uri.EscapeDataString(username)}?secret={base32Secret}&issuer=Lumina";
}
}
@@ -2,7 +2,7 @@
using Lumina.Application.Common.Infrastructure.Time;
using Lumina.Infrastructure.Common.Models.DTO.Configuration;
using Lumina.Infrastructure.Core.Authentication;
using Lumina.Infrastructure.UnitTests.Core.Authentication.Fixtures;
using Lumina.Infrastructure.Fixtures.Core.Authentication;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using NSubstitute;
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Infrastructure.Core.Authentication;
using Lumina.Infrastructure.UnitTests.Core.Authentication.Fixtures;
using Lumina.Infrastructure.Fixtures.Core.Authentication;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion