public async Task InvalidPathToEncrypt() { TestDoc testDoc = TestDoc.Create(); EncryptionOptions encryptionOptionsWithInvalidPathToEncrypt = new EncryptionOptions() { DataEncryptionKeyId = LegacyEncryptionProcessorTests.dekId, EncryptionAlgorithm = CosmosEncryptionAlgorithm.AEAes256CbcHmacSha256Randomized, PathsToEncrypt = new List <string>() { "/SensitiveStr", "/Invalid" } }; Stream encryptedStream = await EncryptionProcessor.EncryptAsync( testDoc.ToStream(), LegacyEncryptionProcessorTests.mockEncryptor.Object, encryptionOptionsWithInvalidPathToEncrypt, new CosmosDiagnosticsContext(), CancellationToken.None); JObject encryptedDoc = EncryptionProcessor.BaseSerializer.FromStream <JObject>(encryptedStream); (JObject decryptedDoc, DecryptionContext decryptionContext) = await EncryptionProcessor.DecryptAsync( encryptedDoc, LegacyEncryptionProcessorTests.mockEncryptor.Object, new CosmosDiagnosticsContext(), CancellationToken.None); LegacyEncryptionProcessorTests.VerifyDecryptionSucceeded( decryptedDoc, testDoc, 1, decryptionContext, invalidPathsConfigured: true); }
public async Task ValidateDecryptStream() { TestDoc testDoc = TestDoc.Create(); Stream encryptedStream = await EncryptionProcessor.EncryptAsync( testDoc.ToStream(), LegacyEncryptionProcessorTests.mockEncryptor.Object, LegacyEncryptionProcessorTests.encryptionOptions, new CosmosDiagnosticsContext(), CancellationToken.None); (Stream decryptedStream, DecryptionContext decryptionContext) = await EncryptionProcessor.DecryptAsync( encryptedStream, LegacyEncryptionProcessorTests.mockEncryptor.Object, new CosmosDiagnosticsContext(), CancellationToken.None); JObject decryptedDoc = EncryptionProcessor.BaseSerializer.FromStream <JObject>(decryptedStream); LegacyEncryptionProcessorTests.VerifyDecryptionSucceeded( decryptedDoc, testDoc, TestDoc.PathsToEncrypt.Count, decryptionContext); }
public async Task ValidateEncryptDecryptDocument() { TestDoc testDoc = TestDoc.Create(); JObject encryptedDoc = await LegacyEncryptionProcessorTests.VerifyEncryptionSucceeded(testDoc); (JObject decryptedDoc, DecryptionContext decryptionContext) = await EncryptionProcessor.DecryptAsync( encryptedDoc, LegacyEncryptionProcessorTests.mockEncryptor.Object, new CosmosDiagnosticsContext(), CancellationToken.None); LegacyEncryptionProcessorTests.VerifyDecryptionSucceeded( decryptedDoc, testDoc, decryptionContext); }
public async Task EncryptDecryptPropertyWithNullValue() { TestDoc testDoc = TestDoc.Create(); testDoc.SensitiveStr = null; JObject encryptedDoc = await LegacyEncryptionProcessorTests.VerifyEncryptionSucceeded(testDoc); (JObject decryptedDoc, DecryptionContext decryptionContext) = await EncryptionProcessor.DecryptAsync( encryptedDoc, LegacyEncryptionProcessorTests.mockEncryptor.Object, new CosmosDiagnosticsContext(), CancellationToken.None); LegacyEncryptionProcessorTests.VerifyDecryptionSucceeded( decryptedDoc, testDoc, decryptionContext); }