< Summary

Class:Azure.Storage.Sas.SasQueryParametersExtensions
Assembly:Azure.Storage.Blobs
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs\src\Sas\SasQueryParametersExtensions.cs
Covered lines:20
Uncovered lines:1
Coverable lines:21
Total lines:74
Line coverage:95.2% (20 of 21)
Covered branches:15
Total branches:16
Branch coverage:93.7% (15 of 16)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
ParseKeyProperties(...)-95.24%93.75%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs\src\Sas\SasQueryParametersExtensions.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.Globalization;
 7using System.Linq;
 8using System.Text;
 9
 10namespace Azure.Storage.Sas
 11{
 12    internal static class SasQueryParametersExtensions
 13    {
 14        /// <summary>
 15        /// Parses the key properties into the QueryParameters instance.
 16        /// </summary>
 17        /// <param name="parameters">
 18        /// The BlobSasQueryParameters or DataLakeSasQueryParameters instance.
 19        /// </param>
 20        /// <param name="values">
 21        /// Dictionary of keys and values.
 22        /// </param>
 23        internal static void ParseKeyProperties(
 24            this
 25#if BlobSDK
 26            BlobSasQueryParameters
 27#elif DataLakeSDK
 28            DataLakeSasQueryParameters
 29#endif
 30            parameters,
 31            IDictionary<string, string> values)
 32        {
 33            // make copy, otherwise we'll get an exception when we remove
 14834            IEnumerable<KeyValuePair<string, string>> kvps = values.ToArray();
 14835            parameters.KeyProperties = new UserDelegationKeyProperties();
 53636            foreach (KeyValuePair<string, string> kv in kvps)
 37            {
 12038                var isSasKey = true;
 39                // these are already decoded
 12040                switch (kv.Key.ToUpperInvariant())
 41                {
 42                    case Constants.Sas.Parameters.KeyObjectIdUpper:
 2043                        parameters.KeyProperties.ObjectId = kv.Value;
 2044                        break;
 45                    case Constants.Sas.Parameters.KeyTenantIdUpper:
 2046                        parameters.KeyProperties.TenantId = kv.Value;
 2047                        break;
 48                    case Constants.Sas.Parameters.KeyStartUpper:
 2049                        parameters.KeyProperties.StartsOn = DateTimeOffset.ParseExact(kv.Value, Constants.SasTimeFormat,
 2050                        break;
 51                    case Constants.Sas.Parameters.KeyExpiryUpper:
 2052                        parameters.KeyProperties.ExpiresOn = DateTimeOffset.ParseExact(kv.Value, Constants.SasTimeFormat
 2053                        break;
 54                    case Constants.Sas.Parameters.KeyServiceUpper:
 2055                        parameters.KeyProperties.Service = kv.Value;
 2056                        break;
 57                    case Constants.Sas.Parameters.KeyVersionUpper:
 2058                        parameters.KeyProperties.Version = kv.Value;
 2059                        break;
 60
 61                    default:
 062                        isSasKey = false;
 63                        break;
 64                }
 65
 66                // Remove the query parameter if it's part of the SAS
 12067                if (isSasKey)
 68                {
 12069                    values.Remove(kv.Key);
 70                }
 71            }
 14872        }
 73    }
 74}

Methods/Properties

ParseKeyProperties(...)