using System.Security.Cryptography; using Managing.Core; using Xunit; namespace Managing.Application.Tests; public class CryptoHelpersTests { [Fact] public void EncryptAesGcm_And_DecryptAesGcm_RoundTrip_Works() { // Arrange var secretKey = "KaigenXCowchain"; // 32 bytes var token = "0xC6327E7191726EDBcaA7f8b7FBec147dc2A5d830-NotOsasa"; // Act var encrypted = CryptoHelpers.EncryptAesGcm(token, secretKey); var decrypted = CryptoHelpers.DecryptAesGcm(encrypted, secretKey); // Assert Assert.NotNull(encrypted); Assert.NotEqual(token, encrypted); // Should be encrypted Assert.Equal(token, decrypted); // Should decrypt to original } [Fact] public void DecryptAesGcm_WithWrongKey_Throws() { // Arrange var secretKey = "supersecretkey1234567890123456"; var wrongKey = "wrongsecretkey6543210987654321"; var token = "0xabcdef-jane"; var encrypted = CryptoHelpers.EncryptAesGcm(token, secretKey); // Act & Assert Assert.Throws(() => CryptoHelpers.DecryptAesGcm(encrypted, wrongKey)); } }