< Summary

Information
Class: Elsa.Identity.Providers.AdminUserProvider
Assembly: Elsa.Identity
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Providers/AdminUserProvider.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 36
Line coverage: 0%
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
.ctor(...)100%210%
FindAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Providers/AdminUserProvider.cs

#LineLine coverage
 1using Elsa.Identity.Contracts;
 2using Elsa.Identity.Entities;
 3using Elsa.Identity.Models;
 4
 5namespace Elsa.Identity.Providers;
 6
 7/// <summary>
 8/// Represents a user provider that always returns a single admin user. This is useful for development purposes.
 9/// </summary>
 10public class AdminUserProvider : IUserProvider
 11{
 12    private readonly User _adminUser;
 13
 14    /// <summary>
 15    /// Initializes a new instance of the <see cref="AdminUserProvider"/> class.
 16    /// </summary>
 017    public AdminUserProvider(ISecretHasher secretHasher)
 18    {
 019        var hashedSecret = secretHasher.HashSecret("password");
 20
 021        _adminUser = new User
 022        {
 023            Id = "admin",
 024            Name = "admin",
 025            HashedPassword = hashedSecret.EncodeSecret(),
 026            HashedPasswordSalt = hashedSecret.EncodeSalt(),
 027            Roles = { "admin" }
 028        };
 029    }
 30
 31    /// <inheritdoc />
 32    public Task<User?> FindAsync(UserFilter filter, CancellationToken cancellationToken = default)
 33    {
 034        return Task.FromResult(_adminUser)!;
 35    }
 36}