Bundle: redb-identity / tests/redb.Identity.Client.Tests (tests.redb.Identity.Client.Tests.txt), 23 files Snapshot: 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 Index: https://redbase.app/src/dev-2026-12-06/redb-identity/_index.txt ==== Path: redb-identity/tests/redb.Identity.Client.Tests/Auth/BearerTokenHandlerTests.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.Client.Tests/Auth/BearerTokenHandlerTests.cs ---- using System.Net; using AwesomeAssertions; using Microsoft.Extensions.Options; using redb.Identity.Client.Auth; using redb.Identity.Client.Tests.TestKit; using Xunit; namespace redb.Identity.Client.Tests.Auth; public sealed class BearerTokenHandlerTests { [Fact] public async Task Adds_Authorization_Header_When_Token_Available() { var fake = new FakeHttpMessageHandler(HttpStatusCode.OK, "{}"); var handler = new BearerTokenHandler(new StaticTokenProvider("abc.def.ghi")) { InnerHandler = fake }; var http = new HttpClient(handler) { BaseAddress = new Uri("https://x.test/") }; var resp = await http.GetAsync("/api/users"); resp.StatusCode.Should().Be(HttpStatusCode.OK); fake.Requests.Should().ContainSingle(); fake.Requests[0].Headers.Authorization.Should().NotBeNull(); fake.Requests[0].Headers.Authorization!.Scheme.Should().Be("Bearer"); fake.Requests[0].Headers.Authorization!.Parameter.Should().Be("abc.def.ghi"); } [Fact] public async Task Does_Nothing_When_Token_Is_Null() { var fake = new FakeHttpMessageHandler(HttpStatusCode.OK, "{}"); var handler = new BearerTokenHandler(new StaticTokenProvider(null)) { InnerHandler = fake }; var http = new HttpClient(handler) { BaseAddress = new Uri("https://x.test/") }; await http.GetAsync("/api/users"); fake.Requests[0].Headers.Authorization.Should().BeNull(); } [Fact] public async Task Does_Nothing_When_Token_Is_Empty() { var fake = new FakeHttpMessageHandler(HttpStatusCode.OK, "{}"); var handler = new BearerTokenHandler(new StaticTokenProvider("")) { InnerHandler = fake }; var http = new HttpClient(handler) { BaseAddress = new Uri("https://x.test/") }; await http.GetAsync("/api/users"); fake.Requests[0].Headers.Authorization.Should().BeNull(); } private sealed class StaticTokenProvider : IAccessTokenProvider { private readonly string? _token; public StaticTokenProvider(string? token) => _token = token; public Task GetAccessTokenAsync(CancellationToken ct = default) => Task.FromResult(_token); } } public sealed class ClientCredentialsAccessTokenProviderTests { [Fact] public async Task Throws_When_No_ClientCredentials_Configured() { var fake = new FakeHttpMessageHandler(HttpStatusCode.OK, "{}"); var http = new HttpClient(fake); var opts = Options.Create(new IdentityClientOptions { BaseUrl = new Uri("https://id.test/") }); var provider = new ClientCredentialsAccessTokenProvider(http, opts); var act = () => provider.GetAccessTokenAsync(); await act.Should().ThrowAsync(); } [Fact] public async Task Caches_Token_Until_Expiry() { var calls = 0; var fake = new FakeHttpMessageHandler(req => { if (req.RequestUri!.AbsolutePath == "/.well-known/openid-configuration") return Task.FromResult(FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, Discovery)); calls++; return Task.FromResult(FakeHttpMessageHandler.BuildResponse( HttpStatusCode.OK, "{\"access_token\":\"tk-1\",\"token_type\":\"Bearer\",\"expires_in\":3600}")); }); var http = new HttpClient(fake); var opts = Options.Create(new IdentityClientOptions { BaseUrl = new Uri("https://id.test/"), Authority = new Uri("https://id.test/"), ClientId = "cli", ClientSecret = "sec", Scopes = ["identity:read"], }); using var provider = new ClientCredentialsAccessTokenProvider(http, opts); var t1 = await provider.GetAccessTokenAsync(); var t2 = await provider.GetAccessTokenAsync(); var t3 = await provider.GetAccessTokenAsync(); t1.Should().Be("tk-1"); t2.Should().Be("tk-1"); t3.Should().Be("tk-1"); calls.Should().Be(1); } [Fact] public async Task Posts_Form_With_grant_type_client_credentials() { var fake = new FakeHttpMessageHandler(req => Task.FromResult(FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, req.RequestUri!.AbsolutePath == "/.well-known/openid-configuration" ? Discovery : "{\"access_token\":\"tk-2\",\"expires_in\":3600}"))); var http = new HttpClient(fake); var opts = Options.Create(new IdentityClientOptions { BaseUrl = new Uri("https://id.test/"), Authority = new Uri("https://id.test/"), ClientId = "my-client", ClientSecret = "shh", Scopes = ["identity:read", "identity:users:read"], }); using var provider = new ClientCredentialsAccessTokenProvider(http, opts); await provider.GetAccessTokenAsync(); fake.Requests.Should().HaveCount(2); fake.Requests[1].Method.Should().Be(HttpMethod.Post); fake.Requests[1].RequestUri!.ToString().Should().Be("https://id.test/connect/token"); fake.RequestBodies[1].Should().Contain("grant_type=client_credentials"); fake.RequestBodies[1].Should().Contain("client_id=my-client"); fake.RequestBodies[1].Should().Contain("client_secret=shh"); // form-encoded space — '+' or '%20' (fake.RequestBodies[1]!.Contains("scope=identity%3Aread+identity%3Ausers%3Aread") || fake.RequestBodies[1]!.Contains("scope=identity%3Aread%20identity%3Ausers%3Aread")) .Should().BeTrue(); } private const string Discovery = "{\"issuer\":\"https://id.test/\",\"token_endpoint\":\"https://id.test/connect/token\"}"; } Path: redb-identity/tests/redb.Identity.Client.Tests/Backchannel/BackchannelTokenProviderTests.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.Client.Tests/Backchannel/BackchannelTokenProviderTests.cs ---- using System.Net; using AwesomeAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using redb.Identity.Client.Backchannel; using redb.Identity.Client.Tests.TestKit; using Xunit; namespace redb.Identity.Client.Tests.Backchannel; /// /// The backchannel client takes its token from the token endpoint that the discovery document of /// names, never from the API base URL: the management /// API can listen on a port of its own, where there is no token endpoint. /// public sealed class BackchannelTokenProviderTests { private const string Discovery = "https://id.test/.well-known/openid-configuration"; private const string TokenEndpoint = "https://id.test/connect/token"; private static BackchannelIdentityClientOptions Options(Uri? authority = null) => new() { BaseUrl = new Uri("http://localhost:5003/"), Authority = authority ?? new Uri("https://id.test/"), ClientId = "identity-backchannel", ClientSecret = "secret", }; private static FakeHttpMessageHandler Server(int expiresIn = 3600, Func? discoveryUp = null) => new(req => { var url = req.RequestUri!.ToString(); if (req.Method == HttpMethod.Get && url == Discovery) { return Task.FromResult(discoveryUp is null || discoveryUp() ? FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, $$"""{"issuer":"https://id.test/","token_endpoint":"{{TokenEndpoint}}"}""") : FakeHttpMessageHandler.BuildResponse(HttpStatusCode.ServiceUnavailable, null)); } if (req.Method == HttpMethod.Post && url == TokenEndpoint) { return Task.FromResult(FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, $$"""{"access_token":"tok","expires_in":{{expiresIn}}}""")); } return Task.FromResult(FakeHttpMessageHandler.BuildResponse(HttpStatusCode.NotFound, null)); }); [Fact] public async Task The_token_comes_from_the_token_endpoint_of_the_authority_not_from_the_api_base_url() { var server = Server(); using var provider = new BackchannelTokenProvider(new HttpClient(server), Microsoft.Extensions.Options.Options.Create(Options())); var token = await provider.GetAccessTokenAsync(); token.Should().Be("tok"); server.Requests.Select(r => $"{r.Method} {r.RequestUri}").Should().Equal( $"GET {Discovery}", $"POST {TokenEndpoint}"); } [Fact] public async Task An_authority_with_a_path_keeps_it_in_the_discovery_address() { var server = new FakeHttpMessageHandler(HttpStatusCode.NotFound, null); using var provider = new BackchannelTokenProvider(new HttpClient(server), Microsoft.Extensions.Options.Options.Create(Options(new Uri("https://id.test/tenant-a")))); await FluentActions.Awaiting(() => provider.GetAccessTokenAsync()).Should().ThrowAsync(); server.Requests[0].RequestUri!.ToString().Should().Be("https://id.test/tenant-a/.well-known/openid-configuration"); } [Fact] public async Task The_discovery_document_is_read_once_and_the_token_endpoint_kept() { var server = Server(expiresIn: 0); using var provider = new BackchannelTokenProvider(new HttpClient(server), Microsoft.Extensions.Options.Options.Create(Options())); await provider.GetAccessTokenAsync(); await provider.GetAccessTokenAsync(); server.Requests.Count(r => r.RequestUri!.ToString() == Discovery).Should().Be(1); server.Requests.Count(r => r.RequestUri!.ToString() == TokenEndpoint).Should().Be(2); } [Fact] public async Task An_unreachable_authority_fails_the_request_and_the_next_request_reads_discovery_again() { var up = false; var server = Server(discoveryUp: () => up); using var provider = new BackchannelTokenProvider(new HttpClient(server), Microsoft.Extensions.Options.Options.Create(Options())); await FluentActions.Awaiting(() => provider.GetAccessTokenAsync()).Should().ThrowAsync(); up = true; (await provider.GetAccessTokenAsync()).Should().Be("tok"); server.Requests.Count(r => r.RequestUri!.ToString() == Discovery).Should().Be(2); } [Fact] public void Without_an_authority_the_options_are_refused_and_the_message_names_the_key() { var services = new ServiceCollection(); services.AddBackchannelIdentityClient(o => { o.BaseUrl = new Uri("http://localhost:5003/"); o.ClientId = "identity-backchannel"; o.ClientSecret = "secret"; }); using var sp = services.BuildServiceProvider(); var act = () => sp.GetRequiredService>().Value; act.Should().Throw() .WithMessage("*BackchannelIdentityClientOptions.Authority*"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/AccountClientTests.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.Client.Tests/Endpoints/AccountClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Users; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class AccountClientTests { private const string Base = "/api/v1/identity/me"; // ── Profile ── [Fact] public async Task GetMyProfile_GET_me() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"id\":1,\"login\":\"alice\"}"); await fx.Client.GetMyProfileAsync(); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Get); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be(Base); } [Fact] public async Task UpdateMyProfile_PUT_me_with_body() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"id\":1,\"displayName\":\"Alice\"}"); await fx.Client.UpdateMyProfileAsync(new MeUpdateProfileRequest { DisplayName = "Alice" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be(Base); fx.Handler.RequestBodies[0].Should().Contain("\"displayName\":\"Alice\""); } // ── Password ── [Fact] public async Task ChangeMyPassword_PUT_me_password() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true,\"sessionsRevoked\":3}"); await fx.Client.ChangeMyPasswordAsync(new MeChangePasswordRequest { OldPassword = "old", NewPassword = "new" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/password"); fx.Handler.RequestBodies[0].Should().Contain("\"oldPassword\":\"old\"").And.Contain("\"newPassword\":\"new\""); } // ── Sessions ── [Fact] public async Task ListMySessions_GET_me_sessions() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "[]"); await fx.Client.ListMySessionsAsync(); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/sessions"); } [Fact] public async Task RevokeMyCurrentSession_DELETE_to_current_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.RevokeMyCurrentSessionAsync(); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/sessions/current"); } [Fact] public async Task RevokeMySession_DELETE_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.RevokeMySessionAsync(7); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/sessions/7"); } [Fact] public async Task RevokeMyOtherSessions_DELETE_to_others_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true,\"revoked\":3}"); await fx.Client.RevokeMyOtherSessionsAsync(); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/sessions/others"); } // ── MFA (self) ── [Fact] public async Task GetMyMfaStatus_GET_me_mfa() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"totp\":false}"); await fx.Client.GetMyMfaStatusAsync(); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/mfa"); } [Fact] public async Task SetupMyMfa_POST_setup_subroute_with_body() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"qr\":\"...\"}"); await fx.Client.SetupMyMfaAsync(new Dictionary { ["method"] = "totp" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/mfa/setup"); fx.Handler.RequestBodies[0].Should().Contain("\"method\":\"totp\""); } [Fact] public async Task ConfirmMyMfa_POST_confirm_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.ConfirmMyMfaAsync(new Dictionary { ["code"] = "123456" }); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/mfa/confirm"); } [Fact] public async Task DisableMyMfaMethod_DELETE_by_method() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.DisableMyMfaMethodAsync("totp"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/mfa/totp"); } [Fact] public async Task RegenerateMyRecoveryCodes_POST_to_recovery_codes() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"codes\":[\"a\"]}"); await fx.Client.RegenerateMyRecoveryCodesAsync(); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/mfa/recovery-codes"); } [Fact] public async Task DownloadMyRecoveryCodes_GET_returns_HttpResponseMessage() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "code-1\ncode-2\n", mediaType: "text/plain"); var resp = await fx.Client.DownloadMyRecoveryCodesAsync(); try { resp.IsSuccessStatusCode.Should().BeTrue(); (await resp.Content.ReadAsStringAsync()).Should().Contain("code-1"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/mfa/recovery-codes/download"); } finally { resp.Dispose(); } } // ── WebAuthn (self) ── [Fact] public async Task GetMyWebAuthnStatus_GET_webauthn() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"enrolled\":false}"); await fx.Client.GetMyWebAuthnStatusAsync(); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/webauthn"); } [Fact] public async Task BeginMyWebAuthnRegistration_POST_register_begin() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"options\":{}}"); await fx.Client.BeginMyWebAuthnRegistrationAsync(new Dictionary { ["display_name"] = "Yubikey" }); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/webauthn/register/begin"); } [Fact] public async Task CompleteMyWebAuthnRegistration_POST_register_complete() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"key\":\"k1\"}"); await fx.Client.CompleteMyWebAuthnRegistrationAsync(new Dictionary { ["attestation"] = "x" }); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/webauthn/register/complete"); } [Fact] public async Task ListMyWebAuthnCredentials_GET_credentials() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "[]"); await fx.Client.ListMyWebAuthnCredentialsAsync(); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/webauthn/credentials"); } [Fact] public async Task RenameMyWebAuthnCredential_PATCH_by_key() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.RenameMyWebAuthnCredentialAsync("k1", new Dictionary { ["name"] = "Yubikey 5" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Patch); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/webauthn/credentials/k1"); fx.Handler.RequestBodies[0].Should().Contain("\"name\":\"Yubikey 5\""); } [Fact] public async Task DeleteMyWebAuthnCredential_DELETE_by_key() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.DeleteMyWebAuthnCredentialAsync("k1"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/webauthn/credentials/k1"); } // ── Consents (self) ── [Fact] public async Task ListMyConsents_GET_consents() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "[]"); await fx.Client.ListMyConsentsAsync(); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/consents"); } [Fact] public async Task RevokeMyConsent_DELETE_by_clientId() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.RevokeMyConsentAsync("client-x"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/consents/client-x"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/ApplicationsClientTests.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.Client.Tests/Endpoints/ApplicationsClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Applications; using redb.Identity.Contracts.Common; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class ApplicationsClientTests { [Fact] public async Task ListApplications_GETs_paged_endpoint() { var paged = new PagedResult { Items = [new() { Id = "a1", ClientId = "c1" }], Total = 1, Offset = 0, Count = 25, }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(paged)); var result = await fx.Client.ListApplicationsAsync(0, 25); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Get); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/applications?offset=0&count=25"); result.Items.Should().HaveCount(1); result.Items[0].ClientId.Should().Be("c1"); } [Fact] public async Task GetApplication_GETs_by_id() { var app = new ApplicationResponse { Id = "abc", ClientId = "my-client" }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(app)); var result = await fx.Client.GetApplicationAsync("abc"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Get); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/applications/abc"); result.ClientId.Should().Be("my-client"); } [Fact] public async Task CreateApplication_POSTs_request_body() { var created = new ApplicationResponse { Id = "new", ClientId = "x" }; var fx = new IdentityClientFixture(HttpStatusCode.Created, IdentityClientFixture.Json(created)); var req = new CreateApplicationRequest { ClientId = "x", DisplayName = "X" }; var result = await fx.Client.CreateApplicationAsync(req); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/applications"); fx.Handler.RequestBodies[0].Should().Contain("\"clientId\":\"x\""); result.Id.Should().Be("new"); } [Fact] public async Task UpdateApplication_PUTs_to_id_path() { var updated = new ApplicationResponse { Id = "abc", ClientId = "renamed" }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(updated)); var req = new UpdateApplicationRequest { Id = "abc", DisplayName = "renamed" }; var result = await fx.Client.UpdateApplicationAsync("abc", req); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/applications/abc"); result.ClientId.Should().Be("renamed"); } [Fact] public async Task DeleteApplication_DELETE_returns_void_on_success() { var fx = new IdentityClientFixture(HttpStatusCode.NoContent); await fx.Client.DeleteApplicationAsync("xyz"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/applications/xyz"); } [Fact] public async Task DeleteApplication_throws_ApiException_on_404() { var fx = new IdentityClientFixture(HttpStatusCode.NotFound, "{\"title\":\"App not found\",\"status\":404}", "application/problem+json"); var act = () => fx.Client.DeleteApplicationAsync("nope"); var ex = await act.Should().ThrowAsync(); ex.Which.StatusCode.Should().Be(HttpStatusCode.NotFound); ex.Which.ProblemDetails!.Title.Should().Be("App not found"); } [Fact] public async Task RotateApplicationSecret_POSTs_to_rotate_secret_subroute_and_returns_newSecret() { // The contract: server echoes the application back with NewSecret populated exactly once. var rotated = new ApplicationResponse { Id = "42", ClientId = "svc-a", ClientType = "confidential", NewSecret = "BASE64-PLAINTEXT-RETURNED-ONCE" }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(rotated)); var result = await fx.Client.RotateApplicationSecretAsync("42"); var req = fx.Handler.Requests.Single(); req.Method.Should().Be(HttpMethod.Post); req.RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/applications/42/rotate-secret"); // Empty body: the route id alone identifies the target. (req.Content?.Headers.ContentLength ?? 0).Should().Be(0); result.NewSecret.Should().Be("BASE64-PLAINTEXT-RETURNED-ONCE"); result.ClientId.Should().Be("svc-a"); } [Fact] public async Task RotateApplicationSecret_throws_ApiException_on_400_for_public_client() { var fx = new IdentityClientFixture( HttpStatusCode.BadRequest, "{\"title\":\"Public clients have no client_secret to rotate.\",\"status\":400,\"type\":\"invalid_client_type\"}", "application/problem+json"); var act = () => fx.Client.RotateApplicationSecretAsync("99"); var ex = await act.Should().ThrowAsync(); ex.Which.StatusCode.Should().Be(HttpStatusCode.BadRequest); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/AuditClientTests.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.Client.Tests/Endpoints/AuditClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Audit; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class AuditClientTests { [Fact] public async Task QueryAudit_GET_default_offset_count() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new AuditQueryResponse { Total = 0, Count = 50, Items = [] })); await fx.Client.QueryAuditAsync(new AuditQueryRequest()); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Get); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/audit?offset=0&count=50"); } [Fact] public async Task QueryAudit_GET_full_filter_serialized() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new AuditQueryResponse { Total = 0, Count = 25, Items = [] })); var filter = new AuditQueryRequest { EventType = "user.login", Category = "authentication", UserId = "alice", ClientId = "client-x", From = new DateTimeOffset(2026, 5, 1, 0, 0, 0, TimeSpan.Zero), To = new DateTimeOffset(2026, 5, 2, 0, 0, 0, TimeSpan.Zero), Offset = 0, Count = 25, }; await fx.Client.QueryAuditAsync(filter); var qs = fx.Handler.Requests.Single().RequestUri!.PathAndQuery; qs.Should().StartWith("/api/v1/identity/audit?") .And.Contain("eventType=user.login") .And.Contain("category=authentication") .And.Contain("userId=alice") .And.Contain("clientId=client-x") .And.Contain("from=") .And.Contain("to=") .And.Contain("offset=0") .And.Contain("count=25"); } [Fact] public async Task QueryAudit_parses_AuditQueryResponse_DTO() { var dto = new AuditQueryResponse { Total = 1, Offset = 0, Count = 25, Items = [new AuditQueryItem { EventId = "e1", EventType = "x", Category = "y", Timestamp = DateTimeOffset.UnixEpoch }] }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(dto)); var result = await fx.Client.QueryAuditAsync(new AuditQueryRequest { Count = 25 }); result.Items.Should().ContainSingle().Which.EventId.Should().Be("e1"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/AuthorityRuleTests.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.Client.Tests/Endpoints/AuthorityRuleTests.cs ---- using System.Net; using AwesomeAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using redb.Identity.Client.Auth; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Tokens; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; /// /// One rule for the whole client: is the management API, and every /// protocol address (token, introspection, revocation, userinfo, discovery, JWKS) comes from the discovery document /// of . Here the API sits on a management port of its own, where none /// of those endpoints exist. /// public sealed class AuthorityRuleTests { private const string Discovery = "https://issuer.test/.well-known/openid-configuration"; private static readonly IdentityClientOptions Opts = new() { BaseUrl = new Uri("http://localhost:5003/"), Authority = new Uri("https://issuer.test/"), ClientId = "svc", ClientSecret = "secret", Scopes = ["identity:manage"], }; private static FakeHttpMessageHandler Server() => new(req => { var url = req.RequestUri!.ToString(); var body = url switch { Discovery => """ {"issuer":"https://issuer.test/", "token_endpoint":"https://issuer.test/connect/token", "introspection_endpoint":"https://issuer.test/connect/introspect", "revocation_endpoint":"https://issuer.test/connect/revocation", "userinfo_endpoint":"https://issuer.test/connect/userinfo", "jwks_uri":"https://issuer.test/.well-known/jwks"} """, "https://issuer.test/connect/token" => """{"access_token":"tok","token_type":"Bearer","expires_in":3600}""", "https://issuer.test/connect/introspect" => """{"active":true}""", "https://issuer.test/connect/revocation" => "{}", "https://issuer.test/connect/userinfo" => """{"sub":"alice"}""", "https://issuer.test/.well-known/jwks" => """{"keys":[]}""", _ => null, }; return Task.FromResult(body is null ? FakeHttpMessageHandler.BuildResponse(HttpStatusCode.NotFound, null) : FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, body)); }); private static IdentityClient Client(FakeHttpMessageHandler server) => new(new HttpClient(server) { BaseAddress = Opts.BaseUrl }, Options.Create(Opts)); private static string[] Calls(FakeHttpMessageHandler server) => server.Requests.Select(r => $"{r.Method} {r.RequestUri}").ToArray(); [Fact] public async Task Client_credentials_token_comes_from_the_token_endpoint_of_the_authority() { var server = Server(); using var provider = new ClientCredentialsAccessTokenProvider(new HttpClient(server), Options.Create(Opts)); (await provider.GetAccessTokenAsync()).Should().Be("tok"); Calls(server).Should().Equal($"GET {Discovery}", "POST https://issuer.test/connect/token"); } [Fact] public async Task Discovery_document_is_read_at_the_authority() { var server = Server(); var doc = await Client(server).GetDiscoveryDocumentAsync(); doc.GetProperty("issuer").GetString().Should().Be("https://issuer.test/"); Calls(server).Should().Equal($"GET {Discovery}"); } [Fact] public async Task Jwks_is_read_at_the_jwks_uri_the_discovery_names_and_discovery_is_read_once() { var server = Server(); var client = Client(server); await client.GetDiscoveryDocumentAsync(); var jwks = await client.GetJwksAsync(); jwks.GetProperty("keys").GetArrayLength().Should().Be(0); Calls(server).Should().Equal($"GET {Discovery}", "GET https://issuer.test/.well-known/jwks"); } [Fact] public async Task Token_introspection_revocation_and_userinfo_go_to_the_endpoints_the_discovery_names() { var server = Server(); var client = Client(server); await client.RequestTokenAsync(new TokenRequest { GrantType = "client_credentials", ClientId = "svc", ClientSecret = "secret" }); await client.IntrospectTokenAsync("t"); await client.RevokeOAuthTokenAsync("t"); await client.GetUserInfoAsync(); Calls(server).Should().Equal( $"GET {Discovery}", "POST https://issuer.test/connect/token", "POST https://issuer.test/connect/introspect", "POST https://issuer.test/connect/revocation", "GET https://issuer.test/connect/userinfo"); } [Fact] public async Task A_failed_discovery_read_is_not_kept() { var up = false; var inner = Server(); var server = new FakeHttpMessageHandler(req => up || req.RequestUri!.ToString() != Discovery ? inner.SendForTest(req) : Task.FromResult(FakeHttpMessageHandler.BuildResponse(HttpStatusCode.ServiceUnavailable, null))); var client = Client(server); await FluentActions.Awaiting(() => client.GetJwksAsync()).Should().ThrowAsync(); up = true; (await client.GetJwksAsync()).GetProperty("keys").GetArrayLength().Should().Be(0); } [Fact] public void Without_an_authority_the_options_are_refused_and_the_message_names_the_key() { var services = new ServiceCollection(); services.AddIdentityClient(o => o.BaseUrl = new Uri("http://localhost:5003/")); using var sp = services.BuildServiceProvider(); var act = () => sp.GetRequiredService>().Value; act.Should().Throw().WithMessage("IdentityClientOptions.Authority is required*"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/ClaimMappersClientTests.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.Client.Tests/Endpoints/ClaimMappersClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.ClaimMappers; using redb.Identity.Contracts.Common; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class ClaimMappersClientTests { // ── Mappers ── [Fact] public async Task ListClaimMappers_GETs_paged_no_owner() { var paged = new PagedResult { Items = [], Total = 0, Offset = 0, Count = 25 }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(paged)); await fx.Client.ListClaimMappersAsync(); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/claim-mappers?offset=0&count=25"); } [Fact] public async Task ListClaimMappers_GETs_paged_with_owner_filter() { var paged = new PagedResult { Items = [], Total = 0, Offset = 0, Count = 25 }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(paged)); await fx.Client.ListClaimMappersAsync(owner: "application:abc"); fx.Handler.Requests.Single().RequestUri!.PathAndQuery .Should().Be("/api/v1/identity/claim-mappers?offset=0&count=25&owner=application%3Aabc"); } [Fact] public async Task GetClaimMapper_GET_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ClaimMapperResponse { Id = "m1" })); await fx.Client.GetClaimMapperAsync("m1"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/claim-mappers/m1"); } [Fact] public async Task CreateClaimMapper_POST() { var fx = new IdentityClientFixture(HttpStatusCode.Created, IdentityClientFixture.Json(new ClaimMapperResponse { Id = "m2" })); await fx.Client.CreateClaimMapperAsync(new CreateClaimMapperRequest { Name = "n", ClaimType = "ct", SourceKind = "Constant", ConstantValue = "v" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/claim-mappers"); } [Fact] public async Task UpdateClaimMapper_PUT() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ClaimMapperResponse { Id = "m1" })); await fx.Client.UpdateClaimMapperAsync("m1", new UpdateClaimMapperRequest { Id = "m1" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/claim-mappers/m1"); } [Fact] public async Task DeleteClaimMapper_DELETE() { var fx = new IdentityClientFixture(HttpStatusCode.NoContent); await fx.Client.DeleteClaimMapperAsync("m1"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); } // ── Scopes ── [Fact] public async Task ListClaimScopes_GET() { var paged = new PagedResult { Items = [], Total = 0, Offset = 0, Count = 25 }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(paged)); await fx.Client.ListClaimScopesAsync(); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/claim-scopes?offset=0&count=25"); } [Fact] public async Task GetClaimScope_GET_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ClaimScopeResponse { Id = "cs1" })); await fx.Client.GetClaimScopeAsync("cs1"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/claim-scopes/cs1"); } [Fact] public async Task CreateClaimScope_POST() { var fx = new IdentityClientFixture(HttpStatusCode.Created, IdentityClientFixture.Json(new ClaimScopeResponse { Id = "cs2" })); await fx.Client.CreateClaimScopeAsync(new CreateClaimScopeRequest { Name = "x" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/claim-scopes"); } [Fact] public async Task UpdateClaimScope_PUT() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ClaimScopeResponse { Id = "cs1" })); await fx.Client.UpdateClaimScopeAsync("cs1", new UpdateClaimScopeRequest { Id = "cs1" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/claim-scopes/cs1"); } [Fact] public async Task DeleteClaimScope_DELETE() { var fx = new IdentityClientFixture(HttpStatusCode.NoContent); await fx.Client.DeleteClaimScopeAsync("cs1"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); } // ── Assignments ── [Fact] public async Task ListClaimScopeAssignments_GETs_query_string() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "[{\"id\":\"a1\",\"applicationId\":\"app\",\"scopeId\":\"cs1\"}]"); var doc = await fx.Client.ListClaimScopeAssignmentsAsync("app"); fx.Handler.Requests.Single().RequestUri!.PathAndQuery .Should().Be("/api/v1/identity/claim-scopes/assignments?applicationId=app"); doc.GetArrayLength().Should().Be(1); } [Fact] public async Task AssignClaimScope_POST() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"id\":\"a1\",\"applicationId\":\"app\",\"scopeId\":\"cs1\"}"); var doc = await fx.Client.AssignClaimScopeAsync(new AssignClaimScopeRequest { ApplicationId = "app", ScopeId = "cs1" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/claim-scopes/assignments"); doc.GetProperty("id").GetString().Should().Be("a1"); } [Fact] public async Task UnassignClaimScope_DELETE_with_query() { var fx = new IdentityClientFixture(HttpStatusCode.NoContent); await fx.Client.UnassignClaimScopeAsync("app", "cs1"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.PathAndQuery .Should().Be("/api/v1/identity/claim-scopes/assignments?applicationId=app&scopeId=cs1"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/ConsentsAdminClientTests.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.Client.Tests/Endpoints/ConsentsAdminClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class ConsentsAdminClientTests { [Fact] public async Task ListUserConsents_GET() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "[]"); await fx.Client.ListUserConsentsAsync(42); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Get); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/consents?userId=42"); } [Fact] public async Task RevokeUserConsent_DELETE_with_userId_and_applicationId() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.RevokeUserConsentAsync(42, 7); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/consents?userId=42&applicationId=7"); } [Fact] public async Task RevokeAllUserConsents_DELETE_to_all_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.RevokeAllUserConsentsAsync(42); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/consents/all?userId=42"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/FederationClientTests.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.Client.Tests/Endpoints/FederationClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Federation; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class FederationClientTests { [Fact] public async Task ListFederationProviders_GET() { var paged = new PagedResult { Items = [new() { Id = "p1", ProviderId = "google", Kind = "oidc", DisplayName = "Google", ClientId = "g", Scopes = ["openid"] }], Total = 1, Offset = 0, Count = 25, }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(paged)); var result = await fx.Client.ListFederationProvidersAsync(); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/federation-providers?offset=0&count=25"); result.Items[0].ProviderId.Should().Be("google"); } [Fact] public async Task GetFederationProvider_GET_by_id() { var fp = new FederationProviderResponse { Id = "p1", ProviderId = "x", Kind = "oidc", DisplayName = "X", ClientId = "c", Scopes = [] }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(fp)); await fx.Client.GetFederationProviderAsync("p1"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/federation-providers/p1"); } [Fact] public async Task CreateFederationProvider_POST() { var fp = new FederationProviderResponse { Id = "p2", ProviderId = "github", Kind = "github", DisplayName = "GH", ClientId = "x", Scopes = [] }; var fx = new IdentityClientFixture(HttpStatusCode.Created, IdentityClientFixture.Json(fp)); var req = new CreateFederationProviderRequest { ProviderId = "github", Kind = "github", DisplayName = "GH", ClientId = "x" }; await fx.Client.CreateFederationProviderAsync(req); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/federation-providers"); } [Fact] public async Task UpdateFederationProvider_PUT_writeonly_secret() { var fp = new FederationProviderResponse { Id = "p1", ProviderId = "x", Kind = "oidc", DisplayName = "X", ClientId = "c", Scopes = [], HasSecret = true }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(fp)); await fx.Client.UpdateFederationProviderAsync("p1", new UpdateFederationProviderRequest { Id = "p1", ClientSecret = "rotated" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.RequestBodies[0].Should().Contain("\"clientSecret\":\"rotated\""); } [Fact] public async Task DeleteFederationProvider_DELETE() { var fx = new IdentityClientFixture(HttpStatusCode.NoContent); await fx.Client.DeleteFederationProviderAsync("p1"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/GroupsClientTests.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.Client.Tests/Endpoints/GroupsClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Groups; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class GroupsClientTests { [Fact] public async Task ListRootGroups_GETs_paged() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "[{\"id\":1,\"name\":\"root\"}]"); var result = await fx.Client.ListRootGroupsAsync(0, 25); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/groups?offset=0&count=25"); result[0].Name.Should().Be("root"); } [Fact] public async Task GetGroup_GET_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new GroupResponse { Id = 7, Name = "g" })); var g = await fx.Client.GetGroupAsync(7); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/7"); g.Id.Should().Be(7); } [Fact] public async Task CreateGroup_POST() { var fx = new IdentityClientFixture(HttpStatusCode.Created, IdentityClientFixture.Json(new GroupResponse { Id = 1, Name = "g" })); await fx.Client.CreateGroupAsync(new CreateGroupRequest { Name = "g" }); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); } [Fact] public async Task CreateChildGroup_POST_to_children_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.Created, IdentityClientFixture.Json(new GroupResponse { Id = 2, Name = "c", ParentId = 1 })); await fx.Client.CreateChildGroupAsync(1, new CreateGroupRequest { Name = "c" }); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1/children"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); } [Fact] public async Task UpdateGroup_PUT() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true,\"groupId\":1}"); await fx.Client.UpdateGroupAsync(1, new UpdateGroupRequest { Name = "renamed" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1"); } [Fact] public async Task DeleteGroup_DELETE() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.DeleteGroupAsync(1); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); } [Fact] public async Task MoveGroup_POSTs_move_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.MoveGroupAsync(1, new MoveGroupRequest { NewParentGroupId = 2 }); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1/move"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); } [Fact] public async Task GetGroupTree_GETs_tree_subroute_returns_JsonElement() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"id\":1,\"name\":\"r\",\"children\":[]}"); var tree = await fx.Client.GetGroupTreeAsync(1); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1/tree"); tree.GetProperty("name").GetString().Should().Be("r"); } [Fact] public async Task GetGroupPath_GETs_path() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "[{\"id\":1,\"name\":\"r\"}]"); var path = await fx.Client.GetGroupPathAsync(1); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1/path"); path.Should().ContainSingle(); } [Fact] public async Task GetGroupChildren_GETs_children() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "[{\"id\":2,\"name\":\"c\"}]"); var ch = await fx.Client.GetGroupChildrenAsync(1); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1/children"); ch.Should().ContainSingle(); } [Fact] public async Task ListGroupMembers_GETs_members() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new[] { new MemberResponse { MembershipId = 10, UserId = 5, GroupId = 1, Role = "member" } })); var members = await fx.Client.ListGroupMembersAsync(1); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1/members"); members.Should().ContainSingle().Which.UserId.Should().Be(5); } [Fact] public async Task AddGroupMember_POSTs_to_members_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.AddGroupMemberAsync(1, new AddMemberRequest { UserId = 5, Role = "admin" }); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1/members"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); } [Fact] public async Task UpdateGroupMember_PUT_to_user_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.UpdateGroupMemberAsync(1, 5, new UpdateMemberRequest { Role = "owner" }); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1/members/5"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); } [Fact] public async Task RemoveGroupMember_DELETEs_user_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.RemoveGroupMemberAsync(1, 5); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1/members/5"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); } [Fact] public async Task GetUserGroups_GETs_users_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "[{\"groupId\":1,\"groupName\":\"g\",\"role\":\"member\"}]"); var ug = await fx.Client.GetUserGroupsAsync(5); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/users/5/groups"); ug.GetArrayLength().Should().Be(1); } [Fact] public async Task IsGroupMember_GETs_check_subroute_returns_bool() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"isMember\":true,\"groupId\":1,\"userId\":5}"); var ok = await fx.Client.IsGroupMemberAsync(1, 5); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/groups/1/members/5/check"); ok.Should().BeTrue(); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/MfaAdminClientTests.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.Client.Tests/Endpoints/MfaAdminClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class MfaAdminClientTests { private const string Base = "/api/v1/identity/mfa"; [Fact] public async Task GetUserMfaStatus_GET_status_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"totp\":true}"); await fx.Client.GetUserMfaStatusAsync(42); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Get); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/status/42"); } // ── TOTP ── [Fact] public async Task SetupUserTotp_POST_with_userId_username() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"qr\":\"...\"}"); await fx.Client.SetupUserTotpAsync(42, "alice"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/totp/setup"); fx.Handler.RequestBodies[0].Should().Contain("\"userId\":42").And.Contain("\"username\":\"alice\""); } [Fact] public async Task ConfirmUserTotp_POST_with_userId_code_and_setup_token() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.ConfirmUserTotpAsync(42, "123456", "setup-x"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/totp/confirm"); fx.Handler.RequestBodies[0].Should().Contain("\"code\":\"123456\"").And.Contain("\"setupToken\":\"setup-x\""); } [Fact] public async Task DisableUserTotp_DELETE_by_userId() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.DisableUserTotpAsync(42); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/totp/42"); } // ── Recovery codes ── [Fact] public async Task RegenerateUserRecoveryCodes_POST_with_userId_body() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"codes\":[\"a\",\"b\"]}"); await fx.Client.RegenerateUserRecoveryCodesAsync(42); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/recovery-codes/regenerate"); fx.Handler.RequestBodies[0].Should().Contain("\"userId\":42"); } // ── SMS ── [Fact] public async Task SetupUserSms_POST() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"challenge\":\"sent\"}"); await fx.Client.SetupUserSmsAsync(42, "alice", "+15551234567"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/sms/setup"); fx.Handler.RequestBodies[0].Should().Contain("\"destination\":\"+15551234567\""); } [Fact] public async Task ConfirmUserSms_POST() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.ConfirmUserSmsAsync(42, "123456", mfaState: "state-x"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/sms/confirm"); fx.Handler.RequestBodies[0].Should().Contain("\"mfaState\":\"state-x\""); } [Fact] public async Task DisableUserSms_DELETE() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.DisableUserSmsAsync(42); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/sms/42"); } // ── Email ── [Fact] public async Task SetupUserEmail_POST() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"challenge\":\"sent\"}"); await fx.Client.SetupUserEmailAsync(42, "alice", "alice@example.com"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/email/setup"); fx.Handler.RequestBodies[0].Should().Contain("\"destination\":\"alice@example.com\""); } [Fact] public async Task ConfirmUserEmail_POST() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.ConfirmUserEmailAsync(42, "123456", "state-x", "setup-x"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/email/confirm"); fx.Handler.RequestBodies[0].Should().Contain("\"code\":\"123456\"").And.Contain("\"mfaState\":\"state-x\"") .And.Contain("\"setupToken\":\"setup-x\""); } [Fact] public async Task DisableUserEmail_DELETE() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.DisableUserEmailAsync(42); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/email/42"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/RevokedSidsClientTests.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.Client.Tests/Endpoints/RevokedSidsClientTests.cs ---- using System.Net; using System.Text.Json; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Sessions; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class RevokedSidsClientTests { private const string Base = "/api/v1/identity/revoked-sids"; [Fact] public async Task AddRevokedSid_POSTs_request_body_with_all_fields() { HttpRequestMessage? captured = null; var fx = new IdentityClientFixture(req => { captured = req; var entry = new RevokedSidEntry { Sid = "s1", Sub = "u1", ClientId = "c1", RevokedAt = DateTimeOffset.UtcNow, ExpiresAt = DateTimeOffset.UtcNow.AddHours(8) }; return TestKit.FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, IdentityClientFixture.Json(entry)); }); var expires = DateTimeOffset.UtcNow.AddHours(2); var result = await fx.Client.AddRevokedSidAsync("s1", "u1", "c1", expires); captured!.Method.Should().Be(HttpMethod.Post); captured.RequestUri!.AbsolutePath.Should().Be(Base); var bodyJson = await captured.Content!.ReadAsStringAsync(); using var doc = JsonDocument.Parse(bodyJson); doc.RootElement.GetProperty("sid").GetString().Should().Be("s1"); doc.RootElement.GetProperty("sub").GetString().Should().Be("u1"); doc.RootElement.GetProperty("clientId").GetString().Should().Be("c1"); doc.RootElement.GetProperty("expiresAt").GetString().Should().NotBeNullOrEmpty(); result.Sid.Should().Be("s1"); result.Sub.Should().Be("u1"); } [Fact] public async Task AddRevokedSid_with_sub_only_omits_sid() { HttpRequestMessage? captured = null; var fx = new IdentityClientFixture(req => { captured = req; var entry = new RevokedSidEntry { Sub = "u1", RevokedAt = DateTimeOffset.UtcNow, ExpiresAt = DateTimeOffset.UtcNow.AddHours(8) }; return FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, IdentityClientFixture.Json(entry)); }); await fx.Client.AddRevokedSidAsync(sid: null, sub: "u1", clientId: null); var bodyJson = await captured!.Content!.ReadAsStringAsync(); using var doc = JsonDocument.Parse(bodyJson); doc.RootElement.GetProperty("sid").ValueKind.Should().Be(JsonValueKind.Null); doc.RootElement.GetProperty("sub").GetString().Should().Be("u1"); } [Fact] public async Task GetRevokedSidsSince_GETs_without_cursor_when_null() { HttpRequestMessage? captured = null; var fx = new IdentityClientFixture(req => { captured = req; return FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, IdentityClientFixture.Json(new RevokedSidsSinceResponse { Entries = new(), NextCursor = DateTimeOffset.UtcNow, ServerTime = DateTimeOffset.UtcNow })); }); var resp = await fx.Client.GetRevokedSidsSinceAsync(cursor: null); captured!.Method.Should().Be(HttpMethod.Get); captured.RequestUri!.PathAndQuery.Should().Be($"{Base}/since"); resp.Entries.Should().BeEmpty(); } [Fact] public async Task GetRevokedSidsSince_with_cursor_url_encodes_iso_timestamp() { HttpRequestMessage? captured = null; var fx = new IdentityClientFixture(req => { captured = req; return FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, IdentityClientFixture.Json(new RevokedSidsSinceResponse { Entries = new() { new RevokedSidEntry { Sid = "s1", RevokedAt = DateTimeOffset.UtcNow, ExpiresAt = DateTimeOffset.UtcNow.AddHours(8) } }, NextCursor = DateTimeOffset.UtcNow, ServerTime = DateTimeOffset.UtcNow })); }); var cursor = new DateTimeOffset(2025, 4, 1, 12, 30, 0, TimeSpan.Zero); var resp = await fx.Client.GetRevokedSidsSinceAsync(cursor); captured!.RequestUri!.AbsolutePath.Should().Be($"{Base}/since"); captured.RequestUri.Query.Should().Contain("cursor="); // Round-trip the encoded cursor to verify it parses back to the same instant. var rawCursor = System.Web.HttpUtility.ParseQueryString(captured.RequestUri.Query)["cursor"]; DateTimeOffset.Parse(rawCursor!).Should().Be(cursor); resp.Entries.Should().HaveCount(1); resp.Entries[0].Sid.Should().Be("s1"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/ScimClientTests.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.Client.Tests/Endpoints/ScimClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Scim; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class ScimClientTests { private const string Base = "/scim/v2"; // ── Discovery ── [Fact] public async Task GetServiceProviderConfig_GET() { var cfg = new ScimServiceProviderConfig { Bulk = new ScimBulkConfig { Supported = true, MaxOperations = 100 } }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(cfg)); var result = await fx.Client.GetScimServiceProviderConfigAsync(); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/ServiceProviderConfig"); result.Bulk!.Supported.Should().BeTrue(); } [Fact] public async Task GetResourceTypes_GET() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"Resources\":[]}"); await fx.Client.GetScimResourceTypesAsync(); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/ResourceTypes"); } [Fact] public async Task GetSchemas_GET() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"Resources\":[]}"); await fx.Client.GetScimSchemasAsync(); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Schemas"); } // ── Users ── [Fact] public async Task ListScimUsers_GET_with_startIndex_count_filter() { var list = new ScimListResponse { TotalResults = 0, ItemsPerPage = 25, StartIndex = 1, Resources = [] }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(list)); await fx.Client.ListScimUsersAsync(startIndex: 1, count: 25, filter: "userName eq \"alice\""); var qs = fx.Handler.Requests.Single().RequestUri!.PathAndQuery; qs.Should().StartWith($"{Base}/Users?") .And.Contain("startIndex=1") .And.Contain("count=25") .And.Contain("filter=userName%20eq%20%22alice%22"); } [Fact] public async Task GetScimUser_GET_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ScimUser { Id = "u1", UserName = "alice" })); await fx.Client.GetScimUserAsync("u1"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Users/u1"); } [Fact] public async Task CreateScimUser_POST() { var fx = new IdentityClientFixture(HttpStatusCode.Created, IdentityClientFixture.Json(new ScimUser { Id = "u2", UserName = "bob" })); await fx.Client.CreateScimUserAsync(new ScimUser { UserName = "bob" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Users"); } [Fact] public async Task ReplaceScimUser_PUT_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ScimUser { Id = "u1", UserName = "alice2" })); await fx.Client.ReplaceScimUserAsync("u1", new ScimUser { Id = "u1", UserName = "alice2" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Users/u1"); } [Fact] public async Task PatchScimUser_PATCH_by_id_with_ops() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ScimUser { Id = "u1" })); var patch = new ScimPatchRequest { Operations = [new ScimPatchOperation { Op = "replace", Path = "userName", Value = System.Text.Json.JsonDocument.Parse("\"renamed\"").RootElement }], }; await fx.Client.PatchScimUserAsync("u1", patch); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Patch); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Users/u1"); } [Fact] public async Task DeleteScimUser_DELETE_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.NoContent); await fx.Client.DeleteScimUserAsync("u1"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Users/u1"); } // ── Groups ── [Fact] public async Task ListScimGroups_GET_with_startIndex_count() { var list = new ScimListResponse { TotalResults = 0, ItemsPerPage = 25, StartIndex = 1, Resources = [] }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(list)); await fx.Client.ListScimGroupsAsync(); var qs = fx.Handler.Requests.Single().RequestUri!.PathAndQuery; qs.Should().StartWith($"{Base}/Groups?").And.Contain("startIndex=1").And.Contain("count=25"); } [Fact] public async Task GetScimGroup_GET_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ScimGroup { Id = "g1", DisplayName = "g" })); await fx.Client.GetScimGroupAsync("g1"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Groups/g1"); } [Fact] public async Task CreateScimGroup_POST() { var fx = new IdentityClientFixture(HttpStatusCode.Created, IdentityClientFixture.Json(new ScimGroup { Id = "g2", DisplayName = "g" })); await fx.Client.CreateScimGroupAsync(new ScimGroup { DisplayName = "g" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Groups"); } [Fact] public async Task ReplaceScimGroup_PUT_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ScimGroup { Id = "g1", DisplayName = "renamed" })); await fx.Client.ReplaceScimGroupAsync("g1", new ScimGroup { Id = "g1", DisplayName = "renamed" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Groups/g1"); } [Fact] public async Task PatchScimGroup_PATCH_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ScimGroup { Id = "g1" })); var patch = new ScimPatchRequest { Operations = [new ScimPatchOperation { Op = "add", Path = "members", Value = System.Text.Json.JsonDocument.Parse("\"u1\"").RootElement }] }; await fx.Client.PatchScimGroupAsync("g1", patch); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Patch); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Groups/g1"); } [Fact] public async Task DeleteScimGroup_DELETE_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.NoContent); await fx.Client.DeleteScimGroupAsync("g1"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Groups/g1"); } // ── Bulk ── [Fact] public async Task ExecuteScimBulk_POSTs_to_Bulk() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ScimBulkResponse { Operations = [] })); var req = new ScimBulkRequest { Operations = [new ScimBulkOperation { Method = "POST", Path = "/Users", BulkId = "1" }] }; await fx.Client.ExecuteScimBulkAsync(req); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be($"{Base}/Bulk"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/ScopesClientTests.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.Client.Tests/Endpoints/ScopesClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Scopes; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class ScopesClientTests { [Fact] public async Task ListScopes_GET() { var paged = new PagedResult { Items = [new() { Id = "s1", Name = "scope.read" }], Total = 1, Offset = 0, Count = 25 }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(paged)); var result = await fx.Client.ListScopesAsync(); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/scopes?offset=0&count=25"); result.Items[0].Name.Should().Be("scope.read"); } [Fact] public async Task GetScope_GET_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ScopeResponse { Id = "s1", Name = "n" })); await fx.Client.GetScopeAsync("s1"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/scopes/s1"); } [Fact] public async Task CreateScope_POST() { var fx = new IdentityClientFixture(HttpStatusCode.Created, IdentityClientFixture.Json(new ScopeResponse { Id = "s2" })); await fx.Client.CreateScopeAsync(new CreateScopeRequest { Name = "x" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/scopes"); } [Fact] public async Task UpdateScope_PUT() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new ScopeResponse { Id = "s1" })); await fx.Client.UpdateScopeAsync("s1", new UpdateScopeRequest { Id = "s1" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/scopes/s1"); } [Fact] public async Task DeleteScope_DELETE() { var fx = new IdentityClientFixture(HttpStatusCode.NoContent); await fx.Client.DeleteScopeAsync("s1"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/scopes/s1"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/SessionsClientTests.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.Client.Tests/Endpoints/SessionsClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class SessionsClientTests { [Fact] public async Task ListSessions_GET_with_userId_query() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "[]"); await fx.Client.ListSessionsAsync(42); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Get); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/sessions?userId=42"); } [Fact] public async Task RevokeSession_DELETE_with_sessionId_query() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.RevokeSessionAsync(7); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/sessions?sessionId=7"); } [Fact] public async Task RevokeAllUserSessions_DELETE_to_all_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.RevokeAllUserSessionsAsync(42); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/sessions/all?userId=42"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); } [Fact] public async Task ForceLogoutUser_POST_to_logout_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.ForceLogoutUserAsync(42); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/sessions/logout?userId=42"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/TokenOAuthClientTests.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.Client.Tests/Endpoints/TokenOAuthClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Tokens; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class TokenOAuthClientTests { [Fact] public async Task RequestToken_POSTs_form_urlencoded_to_connect_token() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new TokenResponse { AccessToken = "abc", TokenType = "Bearer", ExpiresIn = 3600 })); var resp = await fx.Client.RequestTokenAsync(new TokenRequest { GrantType = "client_credentials", ClientId = "cli", ClientSecret = "sec", Scope = "identity:read", }); var req = fx.Handler.Requests.Single(); req.Method.Should().Be(HttpMethod.Post); req.RequestUri!.AbsolutePath.Should().Be("/connect/token"); req.Content!.Headers.ContentType!.MediaType.Should().Be("application/x-www-form-urlencoded"); var body = fx.Handler.RequestBodies[0]!; body.Should().Contain("grant_type=client_credentials") .And.Contain("client_id=cli") .And.Contain("client_secret=sec"); // scope value may be URL-encoded (body.Contains("scope=identity%3Aread") || body.Contains("scope=identity:read")).Should().BeTrue(); resp.AccessToken.Should().Be("abc"); } [Fact] public async Task IntrospectToken_POSTs_form_to_connect_introspect() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"active\":true}"); await fx.Client.IntrospectTokenAsync(token: "tk", tokenTypeHint: "access_token", clientId: "cli", clientSecret: "sec"); var req = fx.Handler.Requests.Single(); req.RequestUri!.AbsolutePath.Should().Be("/connect/introspect"); req.Content!.Headers.ContentType!.MediaType.Should().Be("application/x-www-form-urlencoded"); fx.Handler.RequestBodies[0].Should().Contain("token=tk") .And.Contain("token_type_hint=access_token") .And.Contain("client_id=cli"); } [Fact] public async Task RevokeOAuthToken_POSTs_form_to_connect_revocation() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{}"); await fx.Client.RevokeOAuthTokenAsync("tk", tokenTypeHint: "refresh_token"); var req = fx.Handler.Requests.Single(); req.RequestUri!.AbsolutePath.Should().Be("/connect/revocation"); fx.Handler.RequestBodies[0].Should().Contain("token=tk").And.Contain("token_type_hint=refresh_token"); } [Fact] public async Task GetUserInfo_GET_to_connect_userinfo() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"sub\":\"alice\"}"); var info = await fx.Client.GetUserInfoAsync(); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Get); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/connect/userinfo"); info.GetProperty("sub").GetString().Should().Be("alice"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/TokensAdminClientTests.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.Client.Tests/Endpoints/TokensAdminClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class TokensAdminClientTests { [Fact] public async Task ListTokens_GET_no_subject() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"items\":[]}"); await fx.Client.ListTokensAsync(); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/tokens?offset=0&count=20"); } [Fact] public async Task ListTokens_GET_with_subject_filter() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"items\":[]}"); await fx.Client.ListTokensAsync(subject: "alice", offset: 5, count: 10); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/tokens?offset=5&count=10&subject=alice"); } [Fact] public async Task RevokeToken_DELETE_by_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.RevokeTokenAdminAsync("tk1"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/tokens/tk1"); } [Fact] public async Task RevokeTokensBySubject_POST_with_body() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"revoked\":3}"); await fx.Client.RevokeTokensBySubjectAsync(new Dictionary { ["subject"] = "alice" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/tokens/revoke-by-subject"); fx.Handler.RequestBodies[0].Should().Contain("\"subject\":\"alice\""); } [Fact] public async Task PruneTokens_POST_to_prune_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"pruned\":42}"); await fx.Client.PruneTokensAsync(); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/tokens/prune"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Endpoints/UsersClientTests.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.Client.Tests/Endpoints/UsersClientTests.cs ---- using System.Net; using AwesomeAssertions; using redb.Identity.Client.Tests.TestKit; using redb.Identity.Contracts.Common; using redb.Identity.Contracts.Users; using Xunit; namespace redb.Identity.Client.Tests.Endpoints; public sealed class UsersClientTests { [Fact] public async Task ListUsers_GETs_paged() { var paged = new PagedResult { Items = [new() { Id = 1, Login = "alice" }], Total = 1, Offset = 0, Count = 25, }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(paged)); var result = await fx.Client.ListUsersAsync(); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be("/api/v1/identity/users?offset=0&count=25"); result.Items[0].Login.Should().Be("alice"); } [Fact] public async Task GetUser_GET_by_login_or_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new UserResponse { Id = 1, Login = "alice" })); await fx.Client.GetUserAsync("alice"); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/users/alice"); } [Fact] public async Task CreateUser_POST_with_body() { var fx = new IdentityClientFixture(HttpStatusCode.Created, IdentityClientFixture.Json(new UserResponse { Id = 42, Login = "bob" })); var result = await fx.Client.CreateUserAsync(new CreateUserRequest { Login = "bob", Password = "P@ss" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/users"); fx.Handler.RequestBodies[0].Should().Contain("\"login\":\"bob\""); result.Id.Should().Be(42); } [Fact] public async Task UpdateUser_PUT_to_numeric_id() { var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(new UserResponse { Id = 5, Login = "x", DisplayName = "X" })); await fx.Client.UpdateUserAsync(5, new UpdateUserRequest { Id = 5, DisplayName = "X" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Put); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/users/5"); } [Fact] public async Task DeleteUser_DELETE() { var fx = new IdentityClientFixture(HttpStatusCode.NoContent); await fx.Client.DeleteUserAsync("alice"); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Delete); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/users/alice"); } [Fact] public async Task ChangeUserPassword_POSTs_subroute() { var fx = new IdentityClientFixture(HttpStatusCode.OK, "{\"success\":true}"); await fx.Client.ChangeUserPasswordAsync(7, new ChangePasswordRequest { Id = 7, OldPassword = "old", NewPassword = "new" }); fx.Handler.Requests.Single().Method.Should().Be(HttpMethod.Post); fx.Handler.Requests.Single().RequestUri!.AbsolutePath.Should().Be("/api/v1/identity/users/7/change-password"); } [Fact] public async Task SearchUsers_GETs_with_query() { // The non-paginated overload rides the paginated endpoint with the server-side cap (200) as // its page size, so the wire shape is PagedResult and the URL carries offset/count (a2d555dc). var paged = new PagedResult { Items = new List { new() { Id = 1, Login = "alice" } }, Total = 1, Offset = 0, Count = 200, }; var fx = new IdentityClientFixture(HttpStatusCode.OK, IdentityClientFixture.Json(paged)); var result = await fx.Client.SearchUsersAsync("ali"); fx.Handler.Requests.Single().RequestUri!.PathAndQuery.Should().Be( "/api/v1/identity/users/search?query=ali&offset=0&count=200"); result.Should().ContainSingle().Which.Login.Should().Be("alice"); } } Path: redb-identity/tests/redb.Identity.Client.Tests/Errors/HttpResponseExtensionsTests.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.Client.Tests/Errors/HttpResponseExtensionsTests.cs ---- using System.Net; using System.Text; using AwesomeAssertions; using redb.Identity.Client.Internal; using redb.Identity.Client.Tests.TestKit; using Xunit; namespace redb.Identity.Client.Tests.Errors; public sealed class HttpResponseExtensionsTests { [Fact] public async Task EnsureSuccess_DoesNothing_On_2xx() { using var resp = FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, "{}"); var act = () => resp.EnsureSuccessOrThrowAsync(); await act.Should().NotThrowAsync(); } [Fact] public async Task EnsureSuccess_Throws_ApiException_On_4xx() { using var resp = FakeHttpMessageHandler.BuildResponse(HttpStatusCode.NotFound, null); var ex = await Assert.ThrowsAsync(() => resp.EnsureSuccessOrThrowAsync()); ex.StatusCode.Should().Be(HttpStatusCode.NotFound); ex.ProblemDetails.Should().BeNull(); } [Fact] public async Task EnsureSuccess_Parses_ProblemDetails_When_ProblemJson() { var body = "{\"type\":\"https://x/y\",\"title\":\"User not found\",\"status\":404,\"detail\":\"id=42\"}"; using var resp = FakeHttpMessageHandler.BuildResponse(HttpStatusCode.NotFound, body, "application/problem+json"); var ex = await Assert.ThrowsAsync(() => resp.EnsureSuccessOrThrowAsync()); ex.StatusCode.Should().Be(HttpStatusCode.NotFound); ex.ProblemDetails.Should().NotBeNull(); ex.ProblemDetails!.Title.Should().Be("User not found"); ex.ProblemDetails!.Detail.Should().Be("id=42"); ex.ProblemDetails!.Status.Should().Be(404); ex.Message.Should().Be("User not found"); ex.RawBody.Should().Be(body); } [Fact] public async Task EnsureSuccess_Parses_ValidationErrors() { var body = """ { "title":"One or more validation errors occurred.", "status":400, "errors":{"Email":["Required."],"Password":["TooShort.","NoDigit."]} } """; using var resp = FakeHttpMessageHandler.BuildResponse(HttpStatusCode.BadRequest, body, "application/problem+json"); var ex = await Assert.ThrowsAsync(() => resp.EnsureSuccessOrThrowAsync()); ex.ProblemDetails!.Errors.Should().NotBeNull(); ex.ProblemDetails!.Errors!["Email"].Should().ContainSingle().Which.Should().Be("Required."); ex.ProblemDetails!.Errors!["Password"].Should().HaveCount(2); } [Fact] public async Task EnsureSuccess_Falls_Back_When_Body_Empty() { using var resp = FakeHttpMessageHandler.BuildResponse(HttpStatusCode.InternalServerError, null); var ex = await Assert.ThrowsAsync(() => resp.EnsureSuccessOrThrowAsync()); ex.Message.Should().Contain("500"); ex.ProblemDetails.Should().BeNull(); } [Fact] public async Task EnsureSuccess_Falls_Back_When_Body_NotJson() { using var resp = new HttpResponseMessage(HttpStatusCode.BadGateway) { Content = new StringContent("nginx 502", Encoding.UTF8, "text/html"), }; var ex = await Assert.ThrowsAsync(() => resp.EnsureSuccessOrThrowAsync()); ex.ProblemDetails.Should().BeNull(); ex.RawBody.Should().Contain("nginx"); ex.Message.Should().Contain("502"); } [Fact] public async Task ReadJson_Throws_ApiException_When_Body_Empty_2xx() { using var resp = new HttpResponseMessage(HttpStatusCode.OK); var ex = await Assert.ThrowsAsync(() => resp.ReadJsonAsync()); ex.StatusCode.Should().Be(HttpStatusCode.OK); } [Fact] public async Task ReadJson_Deserializes_On_Success() { using var resp = FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, "{\"name\":\"Alice\",\"age\":30}"); var s = await resp.ReadJsonAsync(); s.Name.Should().Be("Alice"); s.Age.Should().Be(30); } private sealed record Sample(string Name, int Age); } Path: redb-identity/tests/redb.Identity.Client.Tests/Setup/ServiceCollectionExtensionsTests.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.Client.Tests/Setup/ServiceCollectionExtensionsTests.cs ---- using AwesomeAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using redb.Identity.Client; using redb.Identity.Client.Auth; using Xunit; namespace redb.Identity.Client.Tests.Setup; public sealed class ServiceCollectionExtensionsTests { [Fact] public void AddIdentityClient_Registers_Typed_HttpClient() { var services = new ServiceCollection(); services.AddIdentityClient(o => { o.BaseUrl = new Uri("https://identity.test/"); o.Authority = new Uri("https://identity.test/"); o.Timeout = TimeSpan.FromSeconds(7); }); // Provide a default token provider so the typed-client construction does not fail when used. services.AddSingleton(); using var sp = services.BuildServiceProvider(); var client = sp.GetRequiredService(); client.Should().BeOfType(); } [Fact] public void AddIdentityClient_Configures_BaseAddress_And_Timeout() { var services = new ServiceCollection(); services.AddIdentityClient(o => { o.BaseUrl = new Uri("https://identity.example.com/"); o.Authority = new Uri("https://identity.example.com/"); o.Timeout = TimeSpan.FromSeconds(11); }); services.AddSingleton(); using var sp = services.BuildServiceProvider(); var client = (IdentityClient)sp.GetRequiredService(); // Reach into the typed-client's HttpClient via the private field set in the ctor. var http = (HttpClient)typeof(IdentityClient) .GetField("_http", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)! .GetValue(client)!; http.BaseAddress.Should().Be(new Uri("https://identity.example.com/")); http.Timeout.Should().Be(TimeSpan.FromSeconds(11)); } [Fact] public void IdentityClientOptions_Has_Sensible_Defaults() { var opts = new IdentityClientOptions(); opts.BaseUrl.Should().Be(new Uri("https://localhost/")); opts.Timeout.Should().Be(TimeSpan.FromSeconds(30)); opts.Scopes.Should().ContainSingle().Which.Should().Be("identity:manage"); opts.ClientId.Should().BeNull(); opts.ClientSecret.Should().BeNull(); opts.ScimBaseUrl.Should().BeNull(); } private sealed class NullTokenProvider : IAccessTokenProvider { public Task GetAccessTokenAsync(CancellationToken ct = default) => Task.FromResult(null); } } Path: redb-identity/tests/redb.Identity.Client.Tests/TestKit/FakeHttpMessageHandler.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.Client.Tests/TestKit/FakeHttpMessageHandler.cs ---- using System.Net; using System.Text; namespace redb.Identity.Client.Tests.TestKit; /// /// In-memory driven by a queued response builder. /// Records all incoming requests so tests can assert path / method / body / headers. /// internal sealed class FakeHttpMessageHandler : HttpMessageHandler { private readonly Func> _responder; public List Requests { get; } = new(); public List RequestBodies { get; } = new(); public FakeHttpMessageHandler(Func> responder) { _responder = responder; } public FakeHttpMessageHandler(HttpStatusCode status, string? body = null, string mediaType = "application/json") : this(_ => Task.FromResult(BuildResponse(status, body, mediaType))) { } /// Answers a request with this handler's responder, without recording it. public Task SendForTest(HttpRequestMessage request) => _responder(request); public static HttpResponseMessage BuildResponse(HttpStatusCode status, string? body, string mediaType = "application/json") { var resp = new HttpResponseMessage(status); if (body is not null) { resp.Content = new StringContent(body, Encoding.UTF8, mediaType); } return resp; } protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { Requests.Add(request); if (request.Content is not null) { RequestBodies.Add(await request.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false)); } else { RequestBodies.Add(null); } return await _responder(request).ConfigureAwait(false); } } Path: redb-identity/tests/redb.Identity.Client.Tests/TestKit/IdentityClientFixture.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.Client.Tests/TestKit/IdentityClientFixture.cs ---- using System.Net; using System.Text.Json; using Microsoft.Extensions.Options; using redb.Identity.Client.Auth; using redb.Identity.Client.Tests.TestKit; namespace redb.Identity.Client.Tests.TestKit; /// /// Builds an wired to a captured /// so each endpoint test can assert request URI / method / body and stub a JSON response. /// internal sealed class IdentityClientFixture { public FakeHttpMessageHandler Handler { get; } public IdentityClient Client { get; } /// The issuer; its discovery document names the protocol endpoints on the same host as the API. public const string Authority = "https://identity.test/"; public IdentityClientFixture(Func responder) { Handler = new FakeHttpMessageHandler(req => Task.FromResult(responder(req))); var http = new HttpClient(new DiscoveryAnswer(Handler)) { BaseAddress = new Uri("https://identity.test/") }; var opts = Options.Create(new IdentityClientOptions { BaseUrl = new Uri("https://identity.test/"), Authority = new Uri(Authority), }); Client = new IdentityClient(http, opts); } /// /// Answers the discovery document itself and hands every other request to , so the endpoint /// tests see only the requests they make. /// private sealed class DiscoveryAnswer(HttpMessageHandler inner) : DelegatingHandler(inner) { protected override Task SendAsync(HttpRequestMessage request, CancellationToken ct) { if (request.RequestUri!.ToString() != $"{Authority}.well-known/openid-configuration") return base.SendAsync(request, ct); return Task.FromResult(FakeHttpMessageHandler.BuildResponse(HttpStatusCode.OK, $$""" {"issuer":"{{Authority}}", "token_endpoint":"{{Authority}}connect/token", "introspection_endpoint":"{{Authority}}connect/introspect", "revocation_endpoint":"{{Authority}}connect/revocation", "userinfo_endpoint":"{{Authority}}connect/userinfo", "jwks_uri":"{{Authority}}.well-known/jwks"} """)); } } public IdentityClientFixture(HttpStatusCode status, string? body = null, string mediaType = "application/json") : this(_ => FakeHttpMessageHandler.BuildResponse(status, body, mediaType)) { } public static string Json(T value) => JsonSerializer.Serialize(value, new JsonSerializerOptions(JsonSerializerDefaults.Web) { Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping, }); } Path: redb-identity/tests/redb.Identity.Client.Tests/redb.Identity.Client.Tests.csproj 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.Client.Tests/redb.Identity.Client.Tests.csproj ---- net10.0 false true all runtime; build; native; contentfiles; analyzers; buildtransitive all runtime; build; native; contentfiles; analyzers; buildtransitive