Beispiel #1
0
        public async Task EncryptDecryptPropertyWithNullValue()
        {
            TestDoc testDoc = TestDoc.Create();

            JObject encryptedDoc = await PropertyEncryptionProcessorTests.VerifyEncryptionSucceeded(testDoc);

            JObject decryptedDoc = await PropertyEncryptionProcessor.DecryptAsync(
                encryptedDoc,
                PropertyEncryptionProcessorTests.mockEncryptor.Object,
                new CosmosDiagnosticsContext(),
                PathsToEncrypt,
                CancellationToken.None);

            PropertyEncryptionProcessorTests.VerifyDecryptionSucceeded(
                decryptedDoc,
                testDoc);
        }
Beispiel #2
0
        public async Task ValidateDecryptStream()
        {
            TestDoc testDoc = TestDoc.Create();

            Stream encryptedStream = await PropertyEncryptionProcessor.EncryptAsync(
                testDoc.ToStream(),
                PropertyEncryptionProcessorTests.mockEncryptor.Object,
                PropertyEncryptionProcessorTests.propertyEncryptionOptions,
                new CosmosDiagnosticsContext(),
                CancellationToken.None);

            Stream decryptedStream = await PropertyEncryptionProcessor.DecryptAsync(
                encryptedStream,
                PropertyEncryptionProcessorTests.mockEncryptor.Object,
                new CosmosDiagnosticsContext(),
                PropertyEncryptionProcessorTests.PathsToEncrypt,
                CancellationToken.None);

            JObject decryptedDoc = PropertyEncryptionProcessor.BaseSerializer.FromStream <JObject>(decryptedStream);

            PropertyEncryptionProcessorTests.VerifyDecryptionSucceeded(
                decryptedDoc,
                testDoc);
        }