Last active
December 30, 2015 04:29
-
-
Save jkuemerle/7776705 to your computer and use it in GitHub Desktop.
EncryptedType Test Implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [EncryptedType] | |
| public class EncTest { | |
| public string ID { get; set; } | |
| [EncryptedValue] | |
| public string SSN { get; set; } | |
| public string IntegrityValue() { return this.ID; } | |
| public EncTest() { | |
| this.ID = Guid.NewGuid().ToString(); | |
| } | |
| } | |
| [Test] | |
| public void TestAspect() | |
| { | |
| var n = new EncTest(); | |
| var s = new CeloClavis.TestServer(); | |
| ((IEncryptedType)n).KeyServer = s; | |
| ((IEncryptedType)n).EncryptionKeys = s.Map; | |
| ((IEncryptedType)n).Integrity("SSN", n.IntegrityValue); | |
| n.SSN = "111-11-1111"; | |
| Assert.AreNotEqual("111-11-1111", n.SSN); | |
| } | |
| [Test] | |
| public void TestDecryption() | |
| { | |
| var n = new EncTest(); | |
| var s = new CeloClavis.TestServer(); | |
| ((IEncryptedType)n).KeyServer = s; | |
| ((IEncryptedType)n).EncryptionKeys = s.Map; | |
| ((IEncryptedType)n).Integrity(() => n.SSN, n.IntegrityValue); | |
| n.SSN = "111-11-1111"; | |
| Assert.AreEqual("111-11-1111", ((IEncryptedType)n).AsClear(() => n.SSN)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment