From 75839f330c4fec7f83a7105d9b1b75ecc1d96ba2 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Thu, 13 Oct 2016 11:33:03 -0600 Subject: [PATCH] Created test to ensure decryption failures throw an exception in AeadCryptographyProvider --- .../Security/AeadCryptographyProviderTests.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mRemoteNGTests/Security/AeadCryptographyProviderTests.cs b/mRemoteNGTests/Security/AeadCryptographyProviderTests.cs index 8d3511626..68f0ee856 100644 --- a/mRemoteNGTests/Security/AeadCryptographyProviderTests.cs +++ b/mRemoteNGTests/Security/AeadCryptographyProviderTests.cs @@ -4,6 +4,8 @@ using System.Security; using mRemoteNG.Security; using mRemoteNG.Security.SymmetricEncryption; using NUnit.Framework; +using NUnit.Framework.Constraints; +using Org.BouncyCastle.Security; namespace mRemoteNGTests.Security @@ -72,5 +74,13 @@ namespace mRemoteNGTests.Security } return combinationList; } + + [Test] + public void DecryptionFailureThrowsException() + { + var cipherText = _cryptographyProvider.Encrypt(_plainText, _encryptionKey); + ActualValueDelegate decryptMethod = () => _cryptographyProvider.Decrypt(cipherText, "wrongKey".ConvertToSecureString()); + Assert.That(decryptMethod, Throws.TypeOf()); + } } } \ No newline at end of file