< Summary

Information
Class: Elsa.Secrets.Types.X509CertificateSecretTypeProvider
Assembly: Elsa.Secrets
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Secrets/Types/X509CertificateSecretTypeProvider.cs
Line coverage
94%
Covered lines: 16
Uncovered lines: 1
Coverable lines: 17
Total lines: 34
Line coverage: 94.1%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
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(...)100%1212100%

File(s)

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

#LineLine coverage
 1namespace Elsa.Secrets.Types;
 2
 3public class X509CertificateSecretTypeProvider : ISecretTypeProvider
 4{
 645    public SecretTypeDescriptor Descriptor { get; } = new(
 316        SecretTypeNames.X509Certificate,
 317        "X.509 Certificate",
 318        "A certificate reference, such as a thumbprint or configuration-backed certificate identity.",
 319        "secret-x509-certificate",
 3110        [SecretStoreNames.Encrypted, SecretStoreNames.Configuration]);
 11
 312    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, IDictionary<string, s
 17    {
 318        var hasThumbprint = metadata.TryGetValue("thumbprint", out var thumbprint) && !string.IsNullOrWhiteSpace(thumbpr
 319        if (storeName == SecretStoreNames.Encrypted && string.IsNullOrWhiteSpace(value) && !hasThumbprint)
 20        {
 121            error = "Certificate material or a thumbprint metadata value is required.";
 122            return false;
 23        }
 24
 225        if (storeName == SecretStoreNames.Configuration && string.IsNullOrWhiteSpace(configurationKey))
 26        {
 127            error = "A configuration key is required for configuration-backed certificate secrets.";
 128            return false;
 29        }
 30
 131        error = null;
 132        return true;
 33    }
 34}