From 10e2c4ef226536afae287abdd3fb99f1840f6dad Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Wed, 25 Feb 2026 00:51:37 -0500 Subject: [PATCH] fix(test): use precise InvalidDataException assertion in wrong-key encryption test Code quality review feedback: Should.Throw was too broad, changed to Should.Throw to match the actual exception type thrown when AEAD decryption fails with wrong key. --- tests/NATS.Server.Tests/FileStoreEncryptionTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/NATS.Server.Tests/FileStoreEncryptionTests.cs b/tests/NATS.Server.Tests/FileStoreEncryptionTests.cs index 340eb9e..fd0a22d 100644 --- a/tests/NATS.Server.Tests/FileStoreEncryptionTests.cs +++ b/tests/NATS.Server.Tests/FileStoreEncryptionTests.cs @@ -92,13 +92,13 @@ public class FileStoreEncryptionTests await store.AppendAsync("secret", "data"u8.ToArray(), default); } - // Recovery with wrong key should throw or return no messages + // Recovery with wrong key should throw InvalidDataException (from CryptographicException) var act = () => new FileStore(new FileStoreOptions { Directory = dir.FullName, Cipher = StoreCipher.ChaCha, EncryptionKey = key2, }); - Should.Throw(act); + Should.Throw(act); } }