Path: redb-identity/tests/redb.Identity.Web.Tests/WebHostFixture.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.Web.Tests/WebHostFixture.cs
----
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
using AwesomeAssertions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.Configuration;
using Xunit;
namespace redb.Identity.Web.Tests;
///
/// Hosts redb.Identity.Web in-process via WebApplicationFactory.
/// Overrides Identity:* config so OIDC discovery does NOT call out
/// to a real authority during smoke tests.
///
public class WebHostFixture : WebApplicationFactory
{
/// Authority that will fail discovery (loopback w/ closed port).
public const string UnreachableAuthority = "http://127.0.0.1:1/";
public const string UnreachableMetadata = "http://127.0.0.1:1/.well-known/openid-configuration";
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.UseEnvironment("Development");
builder.ConfigureAppConfiguration((_, cfg) =>
{
cfg.AddInMemoryCollection(new Dictionary
{
["Identity:Authority"] = UnreachableAuthority,
["Identity:MetadataAddress"] = UnreachableMetadata,
["Identity:RequireHttpsMetadata"] = "false",
["Identity:ApiBaseUrl"] = UnreachableAuthority,
["Identity:ClientId"] = "identity-web",
["Identity:ClientSecret"] = "test-secret",
["Identity:Scopes:0"] = "openid",
["Identity:Scopes:1"] = "profile",
["Identity:Scopes:2"] = "identity:manage",
// W6-0: backchannel service-account creds + slow poll (1h)
// so RevokedSidsPollHostedService does not hit the unreachable
// authority during tests.
["Identity:BackchannelClient:ClientId"] = "test-backchannel",
["Identity:BackchannelClient:ClientSecret"] = "test-secret",
["Identity:BackchannelClient:Scopes:0"] = "identity:manage",
["Identity:RevokedSids:PollInterval"] = "01:00:00",
["Bootstrap:Enabled"] = "false",
["Bootstrap:Endpoint"] = "http://127.0.0.1:1/internal/bootstrap-admin",
["Bootstrap:Secret"] = "",
});
});
}
}