#region ========================================================================= USING ===================================================================================== using Bogus; using Lumina.Infrastructure.Common.Models.DTO.Configuration; using Microsoft.Extensions.Options; using NSubstitute; using System; using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; #endregion namespace Lumina.Infrastructure.Fixtures.Core.Security; /// /// Test-support class for cryptography service tests. /// [ExcludeFromCodeCoverage] public class CryptographyServiceFixture { /// /// Creates a valid encryption settings model for testing. /// /// The configured options. public static IOptions CreateEncryptionSettings() { // Generate a valid 256-bit (32 byte) key for AES-256 byte[] key = new byte[32]; RandomNumberGenerator.Fill(key); string base64Key = Convert.ToBase64String(key); EncryptionSettingsDto settings = new() { SecretKey = base64Key }; IOptions options = Substitute.For>(); options.Value.Returns(settings); return options; } /// /// Creates test data for encryption/decryption. /// /// A string to be encrypted/decrypted. public static string CreateTestData() { return new Faker().Lorem.Sentence(); } }