Path: redb-identity/tests/redb.Identity.Tests/Infrastructure/ExternalProviderFixture.cs
Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity
Page: https://redbase.app/src/dev-2026-12-06/redb-identity/tests/redb.Identity.Tests/Infrastructure/ExternalProviderFixture.cs
----
using redb.Identity.Core.Services;
namespace redb.Identity.Tests.Infrastructure;
///
/// A configurable fake external user provider for integration testing.
/// Instantiated per-test (not via DI) and passed directly to LoginService constructor.
///
public sealed class FakeExternalUserProvider : IExternalUserProvider
{
public string ProviderName { get; set; } = "fake-test";
public int Priority { get; set; } = 10;
///
/// Map of username → result handler. Return null to skip, non-null to claim the user.
///
public Dictionary> UserHandlers { get; } = new();
public Task AuthenticateAsync(string username, string password, CancellationToken ct = default)
{
if (!UserHandlers.TryGetValue(username, out var handler))
return Task.FromResult(null);
return Task.FromResult(handler(password));
}
}