コード例 #1
0
        public void TestAzureTableCryptoThrowsTableNotFoundException()
        {
            var keyStore = new SymmetricKeyCache(rsaHelper, tableManager);

            var c = new AzureCrypto(keyStore);

            Action action = () => c.GetEncryptor();
            action.ShouldThrow<AzureCryptoException>();
        }
コード例 #2
0
        public void EncryptionShouldWorkAsExpected()
        {
            var newKey = rsaHelper.CreateNewAesSymmetricKeyset();
            tableManager.AddSymmetricKey(newKey);

            var keyStore = new SymmetricKeyCache(rsaHelper, tableManager);
            var c = new AzureCrypto(keyStore);

            var encryptedString = c.EncryptStringAndBase64(TestString);
            encryptedString.Should().NotBeNullOrEmpty("Because the encryption failed");
            encryptedString.Should().NotMatch(TestString);
        }
コード例 #3
0
        public void TestAzureTableCryptoHasValidEncryptor()
        {
            var newKey = rsaHelper.CreateNewAesSymmetricKeyset();
            tableManager.AddSymmetricKey(newKey);

            var keyStore = new SymmetricKeyCache(rsaHelper, tableManager);
            var c = new AzureCrypto(keyStore);
            c.Should().NotBeNull("At this stage the contstructor should have succeeded");

            var encryptor = c.GetEncryptor();
            encryptor.Should().NotBeNull("Because the keystore is initialized and there is a key");
        }
コード例 #4
0
        public void DecryptionShouldReturnTheOriginalString()
        {
            var newKey = rsaHelper.CreateNewAesSymmetricKeyset();
            tableManager.AddSymmetricKey(newKey);

            var keyStore = new SymmetricKeyCache(rsaHelper, tableManager);
            var c = new AzureCrypto(keyStore);

            var encryptedString = c.EncryptStringAndBase64(TestString);
            var decryptedString = c.DecryptStringFromBase64(encryptedString);

            decryptedString.ShouldBeEquivalentTo(TestString);
        }
コード例 #5
0
 public void TestAzureTableCryptoInitializesSuccessfully()
 {
     var keyStore = new SymmetricKeyCache(rsaHelper, tableManager );
     var c = new AzureCrypto(keyStore);
     Assert.IsNotNull(c);
 }