mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Centralizes and standardizes test fixtures.
This commit is contained in:
1 parent
dfc513da4f
commit
b648e2f054
294 files changed
+3807
-4437
No files matched your search
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Infrastructure.Common.Models.DTO.Configuration;
|
||||
using Lumina.Infrastructure.Fixtures.Common.Models.DTO.Configuration;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Fixtures.Core.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Test-support 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 JwtSettingsDtoFixture().Create();
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Fixtures.Core.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Test-support 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";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user