From 8f48c11f75b0f39a71d69954cd5fdcea3deed492 Mon Sep 17 00:00:00 2001 From: Avicennasis <913872+Avicennasis@users.noreply.github.com> Date: Fri, 28 Aug 2026 10:57:23 +0000 Subject: [PATCH] Add missing error path test for MaxPlainTextSize in CryptoService Added test `Encrypt_ExceedsMaxPlainTextSize_ThrowsArgumentException` to `CryptoServiceTests.cs` to ensure that calling `CryptoService.Encrypt` with a string larger than 10MB correctly throws an `ArgumentException` to prevent DoS vulnerabilities. --- TypeIt4Me.Tests/CryptoServiceTests.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TypeIt4Me.Tests/CryptoServiceTests.cs b/TypeIt4Me.Tests/CryptoServiceTests.cs index 4a3aff7..3fd6abc 100644 --- a/TypeIt4Me.Tests/CryptoServiceTests.cs +++ b/TypeIt4Me.Tests/CryptoServiceTests.cs @@ -82,6 +82,14 @@ public void EncryptDecrypt_RoundTrip_PreservesPlaintext() Assert.Equal(plaintext, decrypted); } + [Fact] + public void Encrypt_ExceedsMaxPlainTextSize_ThrowsArgumentException() + { + var plaintext = new string('A', 10 * 1024 * 1024 + 1); + var pin = "testpin"; + Assert.Throws(() => CryptoService.Encrypt(plaintext, pin)); + } + [Fact] public void EncryptDecrypt_UnicodeText_PreservesContent() {