< Summary

Information
Class: AsiBackbone.Signing.ManagedKey.ManagedKeySigningServiceCollectionExtensions
Assembly: AsiBackbone.Signing.ManagedKey
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Signing.ManagedKey/ManagedKeySigningServiceCollectionExtensions.cs
Line coverage
54%
Covered lines: 12
Uncovered lines: 10
Coverable lines: 22
Total lines: 57
Line coverage: 54.5%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddAsiBackboneManagedKeySigning(...)100%11100%
AddAsiBackboneManagedKeySigning(...)100%210%

File(s)

/home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Signing.ManagedKey/ManagedKeySigningServiceCollectionExtensions.cs

#LineLine coverage
 1using AsiBackbone.Core.Signing;
 2using Microsoft.Extensions.DependencyInjection;
 3
 4namespace AsiBackbone.Signing.ManagedKey;
 5
 6/// <summary>
 7/// Provides dependency injection registration helpers for managed-key signing.
 8/// </summary>
 9public static class ManagedKeySigningServiceCollectionExtensions
 10{
 11    /// <summary>
 12    /// Adds managed-key signing with a host-owned managed-key client factory.
 13    /// </summary>
 14    public static IServiceCollection AddAsiBackboneManagedKeySigning(
 15        this IServiceCollection services,
 16        Action<ManagedKeySigningOptions> configure,
 17        Func<IServiceProvider, IManagedKeySigningClient> clientFactory)
 18    {
 219        ArgumentNullException.ThrowIfNull(services);
 220        ArgumentNullException.ThrowIfNull(configure);
 221        ArgumentNullException.ThrowIfNull(clientFactory);
 22
 223        ManagedKeySigningOptions options = new();
 224        configure(options);
 225        options.Validate();
 26
 227        _ = services.AddSingleton(options);
 228        _ = services.AddSingleton(clientFactory);
 229        _ = services.AddSingleton<ManagedKeySigningService>();
 230        _ = services.AddSingleton<IAsiBackboneSigningService>(serviceProvider =>
 431            serviceProvider.GetRequiredService<ManagedKeySigningService>());
 32
 233        return services;
 34    }
 35
 36    /// <summary>
 37    /// Adds managed-key signing using an already-registered <see cref="IManagedKeySigningClient" />.
 38    /// </summary>
 39    public static IServiceCollection AddAsiBackboneManagedKeySigning(
 40        this IServiceCollection services,
 41        Action<ManagedKeySigningOptions> configure)
 42    {
 043        ArgumentNullException.ThrowIfNull(services);
 044        ArgumentNullException.ThrowIfNull(configure);
 45
 046        ManagedKeySigningOptions options = new();
 047        configure(options);
 048        options.Validate();
 49
 050        _ = services.AddSingleton(options);
 051        _ = services.AddSingleton<ManagedKeySigningService>();
 052        _ = services.AddSingleton<IAsiBackboneSigningService>(serviceProvider =>
 053            serviceProvider.GetRequiredService<ManagedKeySigningService>());
 54
 055        return services;
 56    }
 57}