< Summary

Information
Class: Elsa.Identity.Services.DefaultClientIdGenerator
Assembly: Elsa.Identity
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Services/DefaultClientIdGenerator.cs
Line coverage
33%
Covered lines: 4
Uncovered lines: 8
Coverable lines: 12
Total lines: 35
Line coverage: 33.3%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GenerateAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Services/DefaultClientIdGenerator.cs

#LineLine coverage
 1using Elsa.Identity.Constants;
 2using Elsa.Identity.Contracts;
 3using Elsa.Identity.Models;
 4
 5namespace Elsa.Identity.Services;
 6
 7/// <inheritdoc />
 8public class DefaultClientIdGenerator : IClientIdGenerator
 9{
 10    private readonly IRandomStringGenerator _randomStringGenerator;
 11    private readonly IApplicationProvider _applicationProvider;
 12
 13    /// <summary>
 14    /// Initializes a new instance of the <see cref="DefaultClientIdGenerator"/> class.
 15    /// </summary>
 116    public DefaultClientIdGenerator(IRandomStringGenerator randomStringGenerator, IApplicationProvider applicationProvid
 17    {
 118        _randomStringGenerator = randomStringGenerator;
 119        _applicationProvider = applicationProvider;
 120    }
 21
 22    /// <inheritdoc />
 23    public async Task<string> GenerateAsync(CancellationToken cancellationToken = default)
 24    {
 025        while (true)
 26        {
 027            var clientId = _randomStringGenerator.Generate(16, CharacterSequences.AlphanumericSequence);
 028            var filter = new ApplicationFilter { ClientId = clientId };
 029            var application = await _applicationProvider.FindAsync(filter, cancellationToken);
 30
 031            if (application == null)
 032                return clientId;
 033        }
 034    }
 35}