< Summary

Information
Class: Elsa.Secrets.Types.TextSecretTypeProvider
Assembly: Elsa.Secrets
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Secrets/Types/TextSecretTypeProvider.cs
Line coverage
81%
Covered lines: 18
Uncovered lines: 4
Coverable lines: 22
Total lines: 47
Line coverage: 81.8%
Branch coverage
87%
Covered branches: 14
Total branches: 16
Branch coverage: 87.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Descriptor()100%11100%
.ctor()100%11100%
Validate(...)87.5%9875%
ValidateRotation(...)87.5%9875%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Secrets/Types/TextSecretTypeProvider.cs

#LineLine coverage
 1namespace Elsa.Secrets.Types;
 2
 3public class TextSecretTypeProvider : ISecretTypeProvider
 4{
 1155    public SecretTypeDescriptor Descriptor { get; } = new(
 316        SecretTypeNames.Text,
 317        "Text",
 318        "A text value such as a password, token, or connection string.",
 319        "secret-text",
 3110        [SecretStoreNames.Encrypted, SecretStoreNames.Configuration]);
 11
 12    public bool Validate(CreateSecretRequest request, out string? error)
 13    {
 2814        if (request.StoreName == SecretStoreNames.Encrypted && string.IsNullOrEmpty(request.Value))
 15        {
 116            error = "A text value is required for encrypted secrets.";
 117            return false;
 18        }
 19
 2720        if (request.StoreName == SecretStoreNames.Configuration && string.IsNullOrWhiteSpace(request.ConfigurationKey))
 21        {
 022            error = "A configuration key is required for configuration-backed secrets.";
 023            return false;
 24        }
 25
 2726        error = null;
 2727        return true;
 28    }
 29
 30    public bool ValidateRotation(RotateSecretRequest request, string storeName, out string? error)
 31    {
 432        if (storeName == SecretStoreNames.Encrypted && string.IsNullOrEmpty(request.Value))
 33        {
 134            error = "A replacement value is required.";
 135            return false;
 36        }
 37
 338        if (storeName == SecretStoreNames.Configuration && string.IsNullOrWhiteSpace(request.ConfigurationKey))
 39        {
 040            error = "A replacement configuration key is required.";
 041            return false;
 42        }
 43
 344        error = null;
 345        return true;
 46    }
 47}