Created test to ensure decryption failures throw an exception in AeadCryptographyProvider

This commit is contained in:
David Sparer
2016-10-13 11:33:03 -06:00
parent ba0a9bbe58
commit 75839f330c

View File

@@ -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<string> decryptMethod = () => _cryptographyProvider.Decrypt(cipherText, "wrongKey".ConvertToSecureString());
Assert.That(decryptMethod, Throws.TypeOf<EncryptionException>());
}
}
}