< Summary

Information
Class: Elsa.Secrets.Types.RsaKeySecretTypeProvider
Assembly: Elsa.Secrets
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Secrets/Types/RsaKeySecretTypeProvider.cs
Line coverage
81%
Covered lines: 13
Uncovered lines: 3
Coverable lines: 16
Total lines: 33
Line coverage: 81.2%
Branch coverage
75%
Covered branches: 6
Total branches: 8
Branch coverage: 75%
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(...)100%11100%
ValidateRotation(...)100%210%
ValidatePayload(...)75%9875%

File(s)

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

#LineLine coverage
 1namespace Elsa.Secrets.Types;
 2
 3public class RsaKeySecretTypeProvider : ISecretTypeProvider
 4{
 625    public SecretTypeDescriptor Descriptor { get; } = new(
 316        SecretTypeNames.RsaKey,
 317        "RSA Key",
 318        "RSA key material stored as encrypted text or referenced from configuration.",
 319        "secret-rsa-key",
 3110        [SecretStoreNames.Encrypted, SecretStoreNames.Configuration]);
 11
 212    public bool Validate(CreateSecretRequest request, out string? error) => ValidatePayload(request.StoreName, request.V
 13
 014    public bool ValidateRotation(RotateSecretRequest request, string storeName, out string? error) => ValidatePayload(st
 15
 16    private static bool ValidatePayload(string storeName, string? value, string? configurationKey, out string? error)
 17    {
 218        if (storeName == SecretStoreNames.Encrypted && string.IsNullOrWhiteSpace(value))
 19        {
 120            error = "RSA key material is required for encrypted secrets.";
 121            return false;
 22        }
 23
 124        if (storeName == SecretStoreNames.Configuration && string.IsNullOrWhiteSpace(configurationKey))
 25        {
 126            error = "A configuration key is required for configuration-backed RSA key secrets.";
 127            return false;
 28        }
 29
 030        error = null;
 031        return true;
 32    }
 33}