Пример #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);
 }