#region ========================================================================= USING ===================================================================================== using Bogus; using Lumina.Infrastructure.Common.Models.DTO.Configuration; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Security.Cryptography; #endregion namespace Lumina.Infrastructure.Fixtures.Common.Models.DTO.Configuration; /// /// Fixture class for the class. /// [ExcludeFromCodeCoverage] public class JwtSettingsDtoFixture { private readonly Faker _faker = new(); /// /// Creates a valid . /// /// Optional. The secret key used to sign the JWT. /// Optional. The duration (in minutes) for which the JWT is valid. /// Optional. The issuer of the JWT. /// Optional. The intended audience for the JWT. /// The created . public JwtSettingsDto Create( string? secretKey = null, int? expiryMinutes = null, string? issuer = null, string? audience = null) { byte[] key = new byte[32]; RandomNumberGenerator.Fill(key); return new JwtSettingsDto { SecretKey = secretKey ?? Convert.ToBase64String(key), ExpiryMinutes = expiryMinutes ?? _faker.Random.Int(1, 120), Issuer = issuer ?? _faker.Company.CompanyName(), Audience = audience ?? _faker.Company.CompanyName() }; } /// /// Creates a list of instances with randomized test data. /// /// Number of instances to create. /// List of configured instances. public List CreateMany(int count = 3) { return [.. Enumerable.Range(0, count).Select(_ => Create())]; } }