< Summary

Class:Azure.Security.KeyVault.Keys.KeyVaultKey
Assembly:Azure.Security.KeyVault.Keys
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Keys\src\KeyVaultKey.cs
Covered lines:23
Uncovered lines:0
Coverable lines:23
Total lines:92
Line coverage:100% (23 of 23)
Covered branches:6
Total branches:6
Branch coverage:100% (6 of 6)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
.ctor(...)-100%100%
get_Id()-100%100%
get_Name()-100%100%
get_Key()-100%100%
get_KeyType()-100%100%
get_KeyOperations()-100%100%
get_Properties()-100%100%
ReadProperty(...)-100%100%
Azure.Security.KeyVault.IJsonDeserializable.ReadProperties(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Keys\src\KeyVaultKey.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.Text.Json;
 7
 8namespace Azure.Security.KeyVault.Keys
 9{
 10    /// <summary>
 11    /// <see cref="KeyVaultKey"/> is the resource consisting of a value and its <see cref="Properties"/>.
 12    /// </summary>
 13    public class KeyVaultKey : IJsonDeserializable
 14    {
 15        private const string KeyPropertyName = "key";
 16
 30217        internal KeyVaultKey(KeyProperties properties = null)
 18        {
 30219            Properties = properties ?? new KeyProperties();
 30220        }
 21
 22        /// <summary>
 23        /// Initializes a new instance of the <see cref="KeyVaultKey"/> class.
 24        /// </summary>
 25        /// <param name="name">The name of the key.</param>
 26        /// <exception cref="ArgumentException"><paramref name="name"/> is an empty string.</exception>
 27        /// <exception cref="ArgumentNullException"><paramref name="name"/> is null.</exception>
 60428        public KeyVaultKey(string name)
 29        {
 60430            Properties = new KeyProperties(name);
 60431        }
 32
 33        /// <summary>
 34        /// Gets the key identifier.
 35        /// </summary>
 52036        public Uri Id => Properties.Id;
 37
 38        /// <summary>
 39        /// Gets the name of the key.
 40        /// </summary>
 74041        public string Name => Properties.Name;
 42
 43        /// <summary>
 44        /// Gets the cryptographic key, the key type, and the operations you can perform using the key.
 45        /// </summary>
 46        /// <remarks>
 47        /// See http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18 for specifications of a JSON web key.
 48        /// </remarks>
 361249        public JsonWebKey Key { get; internal set; }
 50
 51        /// <summary>
 52        /// Gets the <see cref="KeyType"/> for this <see cref="JsonWebKey"/>.
 53        /// </summary>
 2454        public KeyType KeyType => Key.KeyType;
 55
 56        /// <summary>
 57        /// Gets the operations you can perform using the key.
 58        /// </summary>
 6059        public IReadOnlyCollection<KeyOperation> KeyOperations => Key.KeyOps;
 60
 61        /// <summary>
 62        /// Gets additional properties of the <see cref="KeyVaultKey"/>.
 63        /// </summary>
 370664        public KeyProperties Properties { get; }
 65
 66        internal virtual void ReadProperty(JsonProperty prop)
 67        {
 137668            switch (prop.Name)
 69            {
 70                case KeyPropertyName:
 67671                    Key = new JsonWebKey();
 67672                    Key.ReadProperties(prop.Value);
 73
 67674                    Uri id = new Uri(Key.Id);
 67675                    Properties.ParseId(id);
 67676                    break;
 77
 78                default:
 70079                    Properties.ReadProperty(prop);
 80                    break;
 81            }
 70082        }
 83
 84        void IJsonDeserializable.ReadProperties(JsonElement json)
 85        {
 460086            foreach (JsonProperty prop in json.EnumerateObject())
 87            {
 160488                ReadProperty(prop);
 89            }
 69690        }
 91    }
 92}