< Summary

Class:Azure.Security.KeyVault.Certificates.KeyVaultCertificate
Assembly:Azure.Security.KeyVault.Certificates
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Certificates\src\KeyVaultCertificate.cs
Covered lines:18
Uncovered lines:5
Coverable lines:23
Total lines:94
Line coverage:78.2% (18 of 23)
Covered branches:10
Total branches:14
Branch coverage:71.4% (10 of 14)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_Id()-0%100%
get_Name()-100%100%
get_KeyId()-0%100%
set_KeyId(...)-0%0%
get_SecretId()-0%100%
set_SecretId(...)-0%0%
get_Properties()-100%100%
get_Cer()-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.Certificates\src\KeyVaultCertificate.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Text.Json;
 6
 7namespace Azure.Security.KeyVault.Certificates
 8{
 9    /// <summary>
 10    /// An Azure Key Vault certificate.
 11    /// </summary>
 12    public class KeyVaultCertificate : IJsonDeserializable
 13    {
 14        private const string KeyIdPropertyName = "kid";
 15        private const string SecretIdPropertyName = "sid";
 16        private const string CERPropertyName = "cer";
 17
 18        private string _keyId;
 19        private string _secretId;
 20
 7621        internal KeyVaultCertificate(CertificateProperties properties = null)
 22        {
 7623            Properties = properties ?? new CertificateProperties();
 7624        }
 25
 26        /// <summary>
 27        /// Gets the identifier of the certificate.
 28        /// </summary>
 029        public Uri Id => Properties.Id;
 30
 31        /// <summary>
 32        /// Gets the name of the certificate.
 33        /// </summary>
 3234        public string Name => Properties.Name;
 35
 36        /// <summary>
 37        /// Gets the identifier of the Key Vault Key backing the certificate.
 38        /// </summary>
 39        public Uri KeyId
 40        {
 041            get => new Uri(_keyId);
 042            internal set => _keyId = value?.ToString();
 43        }
 44
 45        /// <summary>
 46        /// Gets the identifier of the Key Vault Secret which contains the PEM of PFX formatted content of the certifica
 47        /// </summary>
 48        public Uri SecretId
 49        {
 050            get => new Uri(_secretId);
 051            internal set => _secretId = value?.ToString();
 52        }
 53
 54        /// <summary>
 55        /// Gets additional properties of the <see cref="KeyVaultCertificate"/>.
 56        /// </summary>
 36057        public CertificateProperties Properties { get; }
 58
 59        /// <summary>
 60        /// Gets the CER formatted public X509 certificate.
 61        /// </summary>
 8862        public byte[] Cer { get; internal set; }
 63
 64        internal virtual void ReadProperty(JsonProperty prop)
 65        {
 49266            switch (prop.Name)
 67            {
 68                case KeyIdPropertyName:
 6869                    _keyId = prop.Value.GetString();
 6870                    break;
 71
 72                case SecretIdPropertyName:
 6873                    _secretId = prop.Value.GetString();
 6874                    break;
 75
 76                case CERPropertyName:
 6877                    Cer = prop.Value.GetBytesFromBase64();
 6878                    break;
 79
 80                default:
 28881                    Properties.ReadProperty(prop);
 82                    break;
 83            }
 28884        }
 85
 86        void IJsonDeserializable.ReadProperties(JsonElement json)
 87        {
 130488            foreach (JsonProperty prop in json.EnumerateObject())
 89            {
 57690                ReadProperty(prop);
 91            }
 7692        }
 93    }
 94}