< Summary

Class:Azure.Storage.Blobs.BlobClientSideEncryptor
Assembly:Azure.Storage.Blobs
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs\src\BlobClientSideEncryptor.cs
Covered lines:0
Uncovered lines:11
Coverable lines:11
Total lines:57
Line coverage:0% (0 of 11)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%100%
ClientSideEncryptInternal()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs\src\BlobClientSideEncryptor.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.IO;
 7using System.Threading;
 8using System.Threading.Tasks;
 9using Azure.Storage.Cryptography;
 10using Azure.Storage.Cryptography.Models;
 11using Metadata = System.Collections.Generic.IDictionary<string, string>;
 12
 13namespace Azure.Storage.Blobs
 14{
 15    internal class BlobClientSideEncryptor
 16    {
 17        private readonly ClientSideEncryptor _encryptor;
 18
 019        public BlobClientSideEncryptor(ClientSideEncryptor encryptor)
 20        {
 021            _encryptor = encryptor;
 022        }
 23
 24        /// <summary>
 25        /// Applies client-side encryption to the data for upload.
 26        /// </summary>
 27        /// <param name="content">
 28        /// Content to encrypt.
 29        /// </param>
 30        /// <param name="metadata">
 31        /// Metadata to add encryption metadata to.
 32        /// </param>
 33        /// <param name="async">
 34        /// Whether to perform this operation asynchronously.
 35        /// </param>
 36        /// <param name="cancellationToken">
 37        /// Cancellation token.
 38        /// </param>
 39        /// <returns>Transformed content stream and metadata.</returns>
 40        public async Task<(Stream, Metadata)> ClientSideEncryptInternal(
 41            Stream content,
 42            Metadata metadata,
 43            bool async,
 44            CancellationToken cancellationToken)
 45        {
 046            (Stream nonSeekableCiphertext, EncryptionData encryptionData) = await _encryptor.EncryptInternal(
 047                content,
 048                async,
 049                cancellationToken).ConfigureAwait(false);
 50
 051            metadata ??= new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 052            metadata[Constants.ClientSideEncryption.EncryptionDataKey] = EncryptionDataSerializer.Serialize(encryptionDa
 53
 054            return (nonSeekableCiphertext, metadata);
 055        }
 56    }
 57}