< Summary

Information
Class: Elsa.Secrets.Models.Secret
Assembly: Elsa.Secrets
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Secrets/Models/Secret.cs
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 50
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_Name()100%11100%
get_DisplayName()100%11100%
get_Description()100%11100%
get_TypeName()100%11100%
get_StoreName()100%11100%
get_Scope()100%11100%
get_ManagedOwnerId()100%11100%
get_ManagedGenerationId()100%11100%
get_IsLifecycleManaged()100%22100%
get_Tags()100%11100%
get_Status()100%11100%
get_CreatedAt()100%11100%
get_UpdatedAt()100%11100%
get_Versions()100%11100%
get_LatestActiveVersion()100%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Secrets/Models/Secret.cs

#LineLine coverage
 1using System.ComponentModel.DataAnnotations.Schema;
 2using System.Text.Json.Serialization;
 3using Elsa.Common.Entities;
 4
 5namespace Elsa.Secrets.Models;
 6
 7public class Secret : Entity
 8{
 9    /// <summary>
 10    /// Assigns the identifier the property initializer used to provide.
 11    /// </summary>
 12    /// <remarks>
 13    /// <see cref="Entity.Id"/> is declared <c>null!</c>, and nothing in this module assigns a secret's id --
 14    /// there is no identity generator on the create path, so the initializer this replaces was load-bearing.
 15    /// Dropping it while deriving would have produced a null id on every insert, which unit tests that build
 16    /// a Secret by hand would not have noticed.
 17    /// </remarks>
 60118    public Secret()
 19    {
 60120        Id = Guid.NewGuid().ToString("N");
 60121    }
 22
 157123    public string Name { get; set; } = default!;
 91724    public string DisplayName { get; set; } = default!;
 68125    public string? Description { get; set; }
 129626    public string TypeName { get; set; } = SecretTypeNames.Text;
 132227    public string StoreName { get; set; } = SecretStoreNames.Encrypted;
 68628    public string? Scope { get; set; }
 29    /// <summary>Stable owner identifier for a lifecycle-managed generation. Generic secret requests cannot set this mar
 75030    public string? ManagedOwnerId { get; set; }
 31
 32    /// <summary>Generation identifier owned by <see cref="ManagedOwnerId"/>.</summary>
 73833    public string? ManagedGenerationId { get; set; }
 34
 35    [JsonIgnore]
 36    [NotMapped]
 12337    public bool IsLifecycleManaged => ManagedOwnerId != null || ManagedGenerationId != null;
 38
 39    [System.Text.Json.Serialization.JsonConverter(typeof(CaseInsensitiveHashSetConverter))]
 137940    public HashSet<string> Tags { get; set; } = new(StringComparer.OrdinalIgnoreCase);
 91941    public SecretStatus Status { get; set; } = SecretStatus.Active;
 122542    public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
 65043    public DateTimeOffset? UpdatedAt { get; set; }
 154244    public IList<SecretVersion> Versions { get; set; } = [];
 45
 13746    public SecretVersion? LatestActiveVersion => Versions
 9047        .Where(x => x.Status == SecretStatus.Active && !x.IsExpired())
 7248        .OrderByDescending(x => x.Version)
 13749        .FirstOrDefault();
 50}