< Summary

Class:Azure.Security.KeyVault.Keys.Cryptography.SecretKey
Assembly:Azure.Security.KeyVault.Keys
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Keys\src\Cryptography\SecretKey.cs
Covered lines:21
Uncovered lines:1
Coverable lines:22
Total lines:53
Line coverage:95.4% (21 of 22)
Covered branches:6
Total branches:6
Branch coverage:100% (6 of 6)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Keys\src\Cryptography\SecretKey.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.Keys.Cryptography
 8{
 9    internal class SecretKey : KeyVaultKey
 10    {
 11        private const string IdPropertyName = "id";
 12        private const string ValuePropertyName = "value";
 13        private const string ContentTypePropertyName = "contentType";
 14
 1215        public SecretKey()
 16        {
 1217            Key = new JsonWebKey(new[] { KeyOperation.Encrypt, KeyOperation.Decrypt, KeyOperation.WrapKey, KeyOperation.
 1218            {
 1219                KeyType = Keys.KeyType.Oct,
 1220            };
 1221        }
 22
 023        public string ContentType { get; private set; }
 24
 25        internal override void ReadProperty(JsonProperty prop)
 26        {
 1627            switch (prop.Name)
 28            {
 29                case IdPropertyName:
 430                    Key.Id = prop.Value.GetString();
 431                    Properties.Id = new Uri(Key.Id);
 432                    KeyVaultIdentifier kvid = KeyVaultIdentifier.Parse(Properties.Id);
 433                    Properties.Name = kvid.Name;
 434                    Properties.VaultUri = kvid.VaultUri;
 435                    Properties.Version = kvid.Version;
 436                    break;
 37
 38                case ContentTypePropertyName:
 439                    ContentType = prop.Value.GetString();
 440                    break;
 41
 42                case ValuePropertyName:
 443                    byte[] keyBytes = Base64Url.Decode(prop.Value.GetString());
 444                    Key.K = keyBytes;
 445                    break;
 46
 47                default:
 448                    base.ReadProperty(prop);
 49                    break;
 50            }
 451        }
 52    }
 53}