< Summary

Class:Azure.Security.KeyVault.Secrets.SecretAttributes
Assembly:Azure.Security.KeyVault.Secrets
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Secrets\src\SecretAttributes.cs
Covered lines:33
Uncovered lines:0
Coverable lines:33
Total lines:98
Line coverage:100% (33 of 33)
Covered branches:40
Total branches:40
Branch coverage:100% (40 of 40)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.cctor()-100%100%
get_Enabled()-100%100%
get_NotBefore()-100%100%
get_ExpiresOn()-100%100%
get_CreatedOn()-100%100%
get_UpdatedOn()-100%100%
get_RecoverableDays()-100%100%
get_RecoveryLevel()-100%100%
ReadProperties(...)-100%100%
WriteProperties(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Secrets\src\SecretAttributes.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.Secrets
 8{
 9    internal struct SecretAttributes
 10    {
 11        private const string EnabledPropertyName = "enabled";
 12        private const string NotBeforePropertyName = "nbf";
 13        private const string ExpiresPropertyName = "exp";
 14        private const string CreatedPropertyName = "created";
 15        private const string UpdatedPropertyName = "updated";
 16        private const string RecoverableDaysPropertyName = "recoverableDays";
 17        private const string RecoveryLevelPropertyName = "recoveryLevel";
 18
 219        private static readonly JsonEncodedText s_enabledPropertyNameBytes = JsonEncodedText.Encode(EnabledPropertyName)
 220        private static readonly JsonEncodedText s_notBeforePropertyNameBytes = JsonEncodedText.Encode(NotBeforePropertyN
 221        private static readonly JsonEncodedText s_expiresPropertyNameBytes = JsonEncodedText.Encode(ExpiresPropertyName)
 22
 363223        public bool? Enabled { get; set; }
 24
 206025        public DateTimeOffset? NotBefore { get; set; }
 26
 207627        public DateTimeOffset? ExpiresOn { get; set; }
 28
 154829        public DateTimeOffset? CreatedOn { get; internal set; }
 30
 154431        public DateTimeOffset? UpdatedOn { get; internal set; }
 32
 1033        public int? RecoverableDays { get; internal set; }
 34
 154435        public string RecoveryLevel { get; internal set; }
 36
 37        internal void ReadProperties(JsonElement json)
 38        {
 1552839            foreach (JsonProperty prop in json.EnumerateObject())
 40            {
 621641                switch (prop.Name)
 42                {
 43                    case EnabledPropertyName:
 154444                        Enabled = prop.Value.GetBoolean();
 154445                        break;
 46
 47                    case NotBeforePropertyName:
 1248                        NotBefore = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64());
 1249                        break;
 50
 51                    case ExpiresPropertyName:
 2452                        ExpiresOn = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64());
 2453                        break;
 54
 55                    case CreatedPropertyName:
 154456                        CreatedOn = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64());
 154457                        break;
 58
 59                    case UpdatedPropertyName:
 154460                        UpdatedOn = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64());
 154461                        break;
 62
 63                    case RecoverableDaysPropertyName:
 464                        RecoverableDays = prop.Value.GetInt32();
 465                        break;
 66
 67                    case RecoveryLevelPropertyName:
 154468                        RecoveryLevel = prop.Value.GetString();
 69                        break;
 70                }
 71            }
 154872        }
 73
 74        internal void WriteProperties(Utf8JsonWriter json)
 75        {
 2476            if (Enabled.HasValue)
 77            {
 2078                json.WriteBoolean(s_enabledPropertyNameBytes, Enabled.Value);
 79            }
 80
 2481            if (NotBefore.HasValue)
 82            {
 483                json.WriteNumber(s_notBeforePropertyNameBytes, NotBefore.Value.ToUnixTimeSeconds());
 84            }
 85
 2486            if (ExpiresOn.HasValue)
 87            {
 888                json.WriteNumber(s_expiresPropertyNameBytes, ExpiresOn.Value.ToUnixTimeSeconds());
 89            }
 90
 91            // Created is read-only don't serialize
 92            // Updated is read-only don't serialize
 93            // RecoverableDays is read-only don't serialize
 94            // RecoveryLevel is read-only don't serialize
 2495        }
 96    }
 97
 98}