Skip to content

Commit

Permalink
RDMPDEV-1638 Unit test fix for caching of encryption/decryption crede…
Browse files Browse the repository at this point in the history
…ntials
  • Loading branch information
tznind committed Oct 14, 2019
1 parent dcb1316 commit b58e3cd
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using System;
using System.IO;
using System.Security.Cryptography;
using NUnit.Framework;
using Rdmp.Core.Curation.Data;
using Rdmp.Core.Repositories.Managers;
Expand Down Expand Up @@ -77,8 +78,10 @@ public void Encrypt()
keyLocation.CreateNewKeyFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "my.key"));
var p = keyLocation.OpenKeyFile();

CatalogueRepository.EncryptionManager.ClearAllInjections();
var s = CatalogueRepository.EncryptionManager.GetEncrypter();
var exception = Assert.Throws<Exception>(()=>s.Decrypt(encrypter.Value));

var exception = Assert.Throws<CryptographicException>(()=>s.Decrypt(encrypter.Value));
Assert.IsTrue(exception.Message.StartsWith("Could not decrypt an encrypted string, possibly you are trying to decrypt it after having changed the PrivateKey "));

string encrypted = s.Encrypt(value);
Expand Down

0 comments on commit b58e3cd

Please sign in to comment.